This is a simple go program to demonstrate using the modules feature of golang.
-
latest golang version with support for go modules (1.12.6)
-
Access to internet to clone the github project
-
Development machine
-
Run
git clone https://github.com/jfrogtraining/go-swampup-service
and change to the go-swampup-service directory -
git checkout -b
-
go build -v ./...
-
You can manually run the service by typing ./go-swampup-service
-
Test by running a GET on http://localhost:7888
-
Observe the logs
-
Interrupt the program by typing CTRL-C
-
Remove any go.mod and go.sum files and ensure GO111MODULE environment variable is set to "on" and set GOPROXY to https://gocenter.io
-
Run go mod init go-swampup-service
-
go mod tidy
-
Edit main.go and uncomment the lines as instructed.
-
Also comment out as instructed.
6 Now test again as before and observe the logs.
-
git add main.go; git add go.mod; git add go.sum
-
git commit -m "go modules test"
-
git push If you see an error indicating there is no upstream set, just execute the command displayed. This is likely since we did not fork the github repo for simplicity e.g git push --set-upstream origin
-
Send PR
11 After PR is merged, follow the jenkins pipelines
We imported logrus module from GoCenter and used it in our example. We saw the dependency on logrus module in go.mod