From 12b62ccee49eedacd12aac741e0bf15ebbf268af Mon Sep 17 00:00:00 2001 From: Mike Bloy Date: Sat, 24 Aug 2019 14:12:29 -0500 Subject: [PATCH] hello world --- go.mod | 3 +++ main.go | 11 +++++++++++ main_test.go | 12 ++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 go.mod create mode 100644 main.go create mode 100644 main_test.go diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..4acdb84 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module git.bloy.org/mike/gotest + +go 1.12 diff --git a/main.go b/main.go new file mode 100644 index 0000000..a4227ee --- /dev/null +++ b/main.go @@ -0,0 +1,11 @@ +package main + +import "fmt" + +func main() { + fmt.Println(sayHi("Mike")) +} + +func sayHi(name string) string { + return fmt.Sprintf("Hi %s", name) +} diff --git a/main_test.go b/main_test.go new file mode 100644 index 0000000..3e8f5d4 --- /dev/null +++ b/main_test.go @@ -0,0 +1,12 @@ +package main + +import "testing" + +func TestSayHi(t *testing.T) { + expected := "Hi Testy" + greeting := sayHi("Testy") + if greeting != expected { + t.Errorf("Greeting was incorrect, got: '%s', want: '%s'", + greeting, expected) + } +}