Skip to content

amitkumardube/golang-api

Repository files navigation

golang - api

golang API to perform the CRUD operations

  • C : create
  • R : read
  • U : update
  • D : delete

What these APIs do?

  • The APIs perform CRUD operations on the string
  • To keep it lightweight project, the APIs don't connect to database

How to use this project?

  • install go binary and configure GOROOT env variable as per the location of GO binary
  • create a directory structure dir_path/src. Where dir_path should be set as GOPATH env variable
  • clone this code under src repo
  • run go run main.go and the application will start on port 8000

List of APIs

How to use automated testing

  • The go testing package supports automated testing.
  • In order to run test testcases , please run go test -v ./...
  • This will trigger test cases in all the packages ( root and sub packages ).
  • To see the test coverage, please use flags like -cover and -coverprofile while running to test command.
  • Commands are go test -v -cover ./... or go test -v -coverprofile=cover.txt ./...
  • Once you have cover.txt file, you can use a built in tool called cover to create an html report from this txt file.
  • Command is - go tool cover -html=cover.txt -o cover.html.
  • Open cover.html in browser to review the test coverage.

Dockerfile

  • Application is using go module.
  • It's important to copy go.mod and go.sum along with main.go in image for go to download dependencies at run time.
  • This file completely defines the structure of your application.

docker-compose.yml

  • This is declarative way of writing docker image.
  • We can create multi container applications using docker-compose.
  • docker-compose up will start the container application.
  • docker-compose down will stop all the container application.
  • docker-compose build will build all the images from docker file.
  • docker-compose logs will show logs for all the running services.

About

Here we will work on some golang activities on google cloud

Resources

Stars

Watchers

Forks

Packages

No packages published