hello-world
A simple Go Hello World example
hello-world
A simple Go Hello World example
Details
- Language: go
- Environment: go1.21
- Tags: go, hello-world, example
Build Information
- Build Success: ✅ Yes
- Last Built: 2025-08-10T07:39:55.856112-07:00
- Total Duration: 4.321017377s
Execution Output
Hello, World!
Testing Output
=== RUN TestHelloWorld
--- PASS: TestHelloWorld (0.00s)
=== RUN TestHelloWorldNotEmpty
--- PASS: TestHelloWorldNotEmpty (0.00s)
PASS
ok example 0.001s
Source Code
Makefile
build:
go mod init example 2>/dev/null || true
go mod tidy
go build -o main .
run:
./main
test:
go test -v ./...
clean:
rm -f main
go clean
autodoc.yaml
title: hello-world
description: A simple Go Hello World example
tags:
- go
- hello-world
- example
environment: go1.21
created: 2025-08-05T15:44:22.165011-07:00
author: Developer
go.mod
module example
go 1.21.13
main.go
package main
import "fmt"
// HelloWorld returns a greeting message
func HelloWorld() string {
return "Hello, World!"
}
// main demonstrates the HelloWorld function
func main() {
message := HelloWorld()
fmt.Println(message)
}
main_test.go
package main
import (
"testing"
)
func TestHelloWorld(t *testing.T) {
expected := "Hello, World!"
result := HelloWorld()
if result != expected {
t.Errorf("HelloWorld() = %q; want %q", result, expected)
}
}
func TestHelloWorldNotEmpty(t *testing.T) {
result := HelloWorld()
if result == "" {
t.Error("HelloWorld() returned empty string")
}
}
func BenchmarkHelloWorld(b *testing.B) {
for i := 0; i < b.N; i++ {
HelloWorld()
}
}