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.
This commit is contained in:
parent
0e1f5f15de
commit
bd9bba54ba
5 changed files with 33 additions and 0 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -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/
|
||||
|
||||
|
|
7
tracker/Makefile
Normal file
7
tracker/Makefile
Normal file
|
@ -0,0 +1,7 @@
|
|||
.PHONY: build test
|
||||
|
||||
build:
|
||||
go build -o build/
|
||||
|
||||
test:
|
||||
go test -v ./...
|
3
tracker/go.mod
Normal file
3
tracker/go.mod
Normal file
|
@ -0,0 +1,3 @@
|
|||
module git.faercol.me/faercol/public-ip-tracker/tracker
|
||||
|
||||
go 1.16
|
11
tracker/main.go
Normal file
11
tracker/main.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func testMethod(a int) int {
|
||||
return a + 2
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("public ip tracker")
|
||||
}
|
9
tracker/main_test.go
Normal file
9
tracker/main_test.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestTestMethod(t *testing.T) {
|
||||
if testMethod(12) != 14 {
|
||||
t.Fatalf("Unexpected result %d", testMethod((12)))
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue