From de293b5f376027b0a2af56fe5efcd08c45fd38c1 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 17 Jun 2025 15:45:03 +1000 Subject: [PATCH] Sample go project --- README.md | 10 +++++++++- cmd/sample/main.go | 15 +++++++++++++++ go.mod | 2 ++ internal/greet/greet.go | 5 +++++ pkg/util/util.go | 7 +++++++ 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 cmd/sample/main.go create mode 100644 go.mod create mode 100644 internal/greet/greet.go create mode 100644 pkg/util/util.go diff --git a/README.md b/README.md index 9752505..1f25be5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ # workflow-sample-go -Demonstrates how to configure a typical Go project. \ No newline at end of file +Demonstrates how to configure a typical Go project. + +Project layout based on the +[golang-standards/project-layout](https://github.com/golang-standards/project-layout) +project layout standard (that was a mouthful) as I find it to be the most +comfortable to work within. + +The build pipelines are made for this standard and are probably difficult to +adapt. diff --git a/cmd/sample/main.go b/cmd/sample/main.go new file mode 100644 index 0000000..f911cbc --- /dev/null +++ b/cmd/sample/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "repobase.net/j/internal/greet" + "repobase.net/j/pkg/util" +) + +func main() { + name := "World" + message := greet.Hello(name) + fmt.Println(message) + + util.PrintVersion() +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..b230720 --- /dev/null +++ b/go.mod @@ -0,0 +1,2 @@ +module repobase.net/j/workflow-sample-go +go 1.22 diff --git a/internal/greet/greet.go b/internal/greet/greet.go new file mode 100644 index 0000000..08b50cb --- /dev/null +++ b/internal/greet/greet.go @@ -0,0 +1,5 @@ +package greet + +func Hello(name string) string { + return "Hello, " + name + "!" +} diff --git a/pkg/util/util.go b/pkg/util/util.go new file mode 100644 index 0000000..e4dac5f --- /dev/null +++ b/pkg/util/util.go @@ -0,0 +1,7 @@ +package util + +import fmt + +func PrintVersion() { + fmt.Println("v4.2.0") +}