My path learning Golang
In a first shell session, you will start the app, in antoher you will run some tests.
for the tests, you will only need curl
and jq
run the app :
export DESIRED_VERSION=0.0.1
git clone git@github.com:pegasus-io/lets-go.git ~/lets-go
cd ~/lets-go
git checkout ${DESIRED_VERSION}
go run main.go
curl -iv http://localhost:10101/api/v1
# # or
curl -iv http://localhost:10101/api/v1 | tail -n 1 | jq
#
curl -iv -X POST http://localhost:10101/api/v1 | tail -n 1 | jq
#
curl -iv -X PUT http://localhost:10101/api/v1 | tail -n 1 | jq
#
curl -iv -X PATCH http://localhost:10101/api/v1 | tail -n 1 | jq
#
curl -iv -X DELETE http://localhost:10101/api/v1 | tail -n 1 | jq
#
curl -iv -X OPTIONS http://localhost:10101/api/v1 | tail -n 1 | jq
#
curl -iv -X POST http://localhost:10101/api/v1/user/544543434/comment | tail -n 1 | jq
#
curl -iv -X GET http://localhost:10101/api/v1/user/544543434/comment/45446464634 | tail -n 1 | jq
PATH
env. var. for the shell session, to add the golang binary path :export PATH=$PATH:/usr/local/go/bin
export NAME_OF_MY_GOLANG_PROJECT=pegasus-api
go mod init ${NAME_OF_MY_GOLANG_PROJECT}
ENV
at runtimeexport PATH=$PATH:/usr/local/go/bin
go get -u github.com/gorilla/mux
github.com/gorilla/mux
as a dependency, into each source code file where we want to use the dependency. Example :package somepackage
import (
"github.com/gorilla/mux"
)
func myAwesomeFunction() {
r := mux.NewRouter()
}
0.0.1