A GoLang (1.15.3
) HTTP API Server with SQLite backend, built using Gorm ORM and Echo Web Framework.
For reference/example purposes.
go run main.go
- Test command:
curl http://localhost:1323/
- Database is created/seeded with dummy data for some tables.
curl \
--header "Content-Type: application/json" \
--request POST \
--data '{
"createdDate": "2019-12-01T12:00:00.0-07:00",
"tests": [
{
"short_name": "world_readable",
"vulnerable": true,
"data": [
{
"path": "/data/data/file1"
},
{
"path": "/data/data/file2"
},
{
"path": "/data/data/file3"
},
{
"path": "/data/data/file4"
}
]
}
]
}' http://localhost:1323/apps/app1/versions/1.0/reports
curl \
--header "Content-Type: application/json" \
--request GET \
http://localhost:1323/apps/app1/versions/1.0/reports
docker run -i -t -p 1323 \
-v ${PWD}:/app/ \
--workdir /app/ \
golang:1.15.3 go run main.go
docker build -t josh-bacon-golang-api:latest .
docker run -p 1323:1323 josh-bacon-golang-api:latest
docker tag josh-bacon-golang-api:latest gcr.io/rich-involution-105622/josh-bacon-golang-api:latest
docker push gcr.io/rich-involution-105622/josh-bacon-golang-api:latest
gcloud run deploy josh-bacon-golang-api \
--image gcr.io/rich-involution-105622/josh-bacon-golang-api:latest \
--platform=managed \
--region=us-west1
go get -u golang.org/x/lint/golint
~/go/bin/golint -set_exit_status ./...
go vet ./... 2> go-vet-report.out
go mod vendor
go test -mod vendor ./... -json > go-test-report.json
go test -mod vendor ./... -coverprofile=go-test-coverage.out
- Test logs are printed to
STDOUT
andgo-test-report.json
- Test coverage report is printed to
go-test-coverage.json
go build -o executable -mod vendor ./...