From c4bf94b6da48d92bf9b51d38aed3b719366d8fae Mon Sep 17 00:00:00 2001 From: Pedro Correa Date: Mon, 4 Mar 2024 15:20:11 -0300 Subject: [PATCH] :sparkles: (Go) First test --- Go/go.mod | 3 +++ Go/hello.go | 13 +++++++++++++ Go/hello_test.go | 12 ++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 Go/go.mod create mode 100644 Go/hello.go create mode 100644 Go/hello_test.go diff --git a/Go/go.mod b/Go/go.mod new file mode 100644 index 0000000..ba8b186 --- /dev/null +++ b/Go/go.mod @@ -0,0 +1,3 @@ +module learn.go.with.tests + +go 1.21.7 diff --git a/Go/hello.go b/Go/hello.go new file mode 100644 index 0000000..b8616ef --- /dev/null +++ b/Go/hello.go @@ -0,0 +1,13 @@ +package main + +import "fmt" + +const englishHelloPrefix = "Hello, " + +func Hello(name string) string { + return englishHelloPrefix + name +} + +func main() { + fmt.Println(Hello("world")) +} diff --git a/Go/hello_test.go b/Go/hello_test.go new file mode 100644 index 0000000..8af0a6f --- /dev/null +++ b/Go/hello_test.go @@ -0,0 +1,12 @@ +package main + +import "testing" + +func TestHello(t *testing.T) { + got := Hello("Pedro") + want := "Hello, Pedro" + + if got != want { + t.Errorf("got %q want %q", got, want) + } +} -- 2.51.2