diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..afdf576 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module hello + +go 1.17 diff --git a/hello.go b/hello.go index 8117330..a53bfbb 100644 --- a/hello.go +++ b/hello.go @@ -2,6 +2,10 @@ package main import "fmt" -func main() { - fmt.Println("Hello, world") +func Hello() string { + return "Hello, world" +} + +func main() { + fmt.Println(Hello()) } diff --git a/hello_test.go b/hello_test.go new file mode 100644 index 0000000..0531825 --- /dev/null +++ b/hello_test.go @@ -0,0 +1,12 @@ +package main + +import "testing" + +func TestHello(t *testing.T) { + got := Hello() + want := "Hello, world" + + if got != want { + t.Errorf("got %q want %q", got, want) + } +}