From bd9bba54ba435850624e8549f31ad7cbdcf75e13 Mon Sep 17 00:00:00 2001 From: Melora Hugues Date: Thu, 5 Jan 2023 18:51:53 +0100 Subject: [PATCH] Create initial Go module Ref #1 Create an initial Go module with a simple unit test and a makefile. This can be tested using a CI pipeline, which will ensure that the following commits don't break anything. --- .gitignore | 3 +++ tracker/Makefile | 7 +++++++ tracker/go.mod | 3 +++ tracker/main.go | 11 +++++++++++ tracker/main_test.go | 9 +++++++++ 5 files changed, 33 insertions(+) create mode 100644 tracker/Makefile create mode 100644 tracker/go.mod create mode 100644 tracker/main.go create mode 100644 tracker/main_test.go diff --git a/.gitignore b/.gitignore index adf8f72..8da22dc 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,9 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +# build directory +tracker/build + # Dependency directories (remove the comment below to include it) # vendor/ diff --git a/tracker/Makefile b/tracker/Makefile new file mode 100644 index 0000000..a39e6c4 --- /dev/null +++ b/tracker/Makefile @@ -0,0 +1,7 @@ +.PHONY: build test + +build: + go build -o build/ + +test: + go test -v ./... diff --git a/tracker/go.mod b/tracker/go.mod new file mode 100644 index 0000000..54b9f30 --- /dev/null +++ b/tracker/go.mod @@ -0,0 +1,3 @@ +module git.faercol.me/faercol/public-ip-tracker/tracker + +go 1.16 diff --git a/tracker/main.go b/tracker/main.go new file mode 100644 index 0000000..bfe65b2 --- /dev/null +++ b/tracker/main.go @@ -0,0 +1,11 @@ +package main + +import "fmt" + +func testMethod(a int) int { + return a + 2 +} + +func main() { + fmt.Println("public ip tracker") +} diff --git a/tracker/main_test.go b/tracker/main_test.go new file mode 100644 index 0000000..3fefe71 --- /dev/null +++ b/tracker/main_test.go @@ -0,0 +1,9 @@ +package main + +import "testing" + +func TestTestMethod(t *testing.T) { + if testMethod(12) != 14 { + t.Fatalf("Unexpected result %d", testMethod((12))) + } +}