From 6b03f239167791b48eb824d0b52554cfb987ed2b Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Wed, 10 Mar 2021 09:13:54 +0000 Subject: [PATCH] remote module specification --- go-testing.go | 27 +++++++++++++++++++++++++++ go.mod | 2 +- goroutines.go | 28 ++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 go-testing.go create mode 100644 goroutines.go diff --git a/go-testing.go b/go-testing.go new file mode 100644 index 0000000..d349ce4 --- /dev/null +++ b/go-testing.go @@ -0,0 +1,27 @@ +package main + +import ( + "math" + "os" + "testing" +) + +//TestAbs comment needed +func TestAbs(t *testing.T) { + // TestAbs comment + got := math.Abs(-1) + if got != 1 { + t.Errorf("Abs(-1) = %d; want 1", got) + } +} + +//TestMain comment needed +func TestMain(m *testing.M) { + // call flag.Parse() here if TestMain uses flags + os.Exit(m.Run()) +} + +func main() { + TestAbs(&testing.T{}) + +} diff --git a/go.mod b/go.mod index c7c0da4..104a773 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module go-learn +module bitbucket.org/gmgauthier_ecs/go-learn go 1.16 diff --git a/goroutines.go b/goroutines.go new file mode 100644 index 0000000..78a1c93 --- /dev/null +++ b/goroutines.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "time" +) + +func f(from string) { + for i := 0; i < 3; i++ { + fmt.Println(from, ":", i) + } +} + +func main() { + + f("direct FIRST") + + go f("goroutine one SECOND") + go f("goroutine two THIRD") + + go func(msg string) { + fmt.Println(msg + " ") + go f("goroutine three FOURTH") + }("going") + + time.Sleep(time.Second) + fmt.Println("done") +}