From 911f8736f1dde7b3d39a058b154b492d24dbf264 Mon Sep 17 00:00:00 2001 From: Ryan Richard Date: Thu, 2 Jul 2020 17:05:59 -0700 Subject: [PATCH] Hello, world! --- .gitignore | 3 +++ cmd/placeholder-name/main.go | 10 ++++++++++ go.mod | 3 +++ pkg/hello/hello.go | 13 +++++++++++++ pkg/hello/hello_test.go | 12 ++++++++++++ 5 files changed, 41 insertions(+) create mode 100644 cmd/placeholder-name/main.go create mode 100644 go.mod create mode 100644 pkg/hello/hello.go create mode 100644 pkg/hello/hello_test.go diff --git a/.gitignore b/.gitignore index 66fd13c9..2aaba826 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ # Dependency directories (remove the comment below to include it) # vendor/ + +# goland +.idea diff --git a/cmd/placeholder-name/main.go b/cmd/placeholder-name/main.go new file mode 100644 index 00000000..604baebc --- /dev/null +++ b/cmd/placeholder-name/main.go @@ -0,0 +1,10 @@ +package main + +import ( + "fmt" + "github.com/suzerain-io/placeholder-name/pkg/hello" +) + +func main() { + fmt.Println(hello.NewHelloSayer().SayHello()) +} diff --git a/go.mod b/go.mod new file mode 100644 index 00000000..390f10c4 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/suzerain-io/placeholder-name + +go 1.14 diff --git a/pkg/hello/hello.go b/pkg/hello/hello.go new file mode 100644 index 00000000..936c05b8 --- /dev/null +++ b/pkg/hello/hello.go @@ -0,0 +1,13 @@ +package hello + +type HelloSayer interface { + SayHello() string +} + +type helloSayerImpl struct{} + +func (helloSayerImpl) SayHello() string { return "hello" } + +func NewHelloSayer() HelloSayer { + return helloSayerImpl{} +} diff --git a/pkg/hello/hello_test.go b/pkg/hello/hello_test.go new file mode 100644 index 00000000..acfe64f4 --- /dev/null +++ b/pkg/hello/hello_test.go @@ -0,0 +1,12 @@ +package hello + +import ( + "testing" +) + +func TestHelloSayerImpl_SayHello(t *testing.T) { + actualGreeting := NewHelloSayer().SayHello() + if actualGreeting != "hello" { + t.Errorf("expected to say hello but said %v", actualGreeting) + } +}