https://github.com/andreas-bauer/simple-go-user-service
Simple Go (User) Micro-Service
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.4%) to scientific vocabulary
Repository
Simple Go (User) Micro-Service
Basic Info
- Host: GitHub
- Owner: andreas-bauer
- License: mit
- Language: Go
- Default Branch: master
- Size: 6.87 MB
Statistics
- Stars: 5
- Watchers: 4
- Forks: 1
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Simple Go (User) Micro-Service
The purpose of this project is to gain experience in Golang for micro-service development. Also, a small comparison with Spring Boot should show how the resource footprint of both technologies differs.
Build and Run
The Makefile provides some shortcuts for common commands.
Use the help argument to display all available commands.
sh
make help
Run the application with go run:
sh
cd cmd/user-service
go run main.go
Build a binary:
sh
cd cmd/user-service
go build
To use the application within a Docker container you can use docker-compose, which will also start a container for MongoDB.
sh
docker-compose up
API Endpoints
| Operation | URI | Description | | --------- | -------------- | -------------------- | | GET | /users/ | Get all users | | GET | /users/{email} | Get user by email | | POST | /users/ | Create new user | | DELETE | /users/{email} | Delete user by email |
Request body for user creation:
JSON
{
"name": "Rick Sanchez",
"email": "rick@internet.com",
"password": "secret pw",
"role": "admin"
}
Footprint
This section should give you an idea how the footprint of a small micro-service written in Go can be. Docker is an essential technology in modern software development, so this micro-service should also run within a Docker container. To keep the footprint small, I used the alpine docker image as the base image for this micro-service.
The following numbers are gathered via the docker stats command.
- RAM usage in idle after startup: ~ 3 MB
- RAM usage after 1000 POST and 1000 GET requests: ~ 8 MB
- Binary size: 14 MB
- Docker image size (binary included): 19 MB
Comparison with Spring Boot 2.0
A very popular framework for micro-service development is Spring Boot 2.0 for Java. The Spring Boot project for this small comparison has similar features and uses the same MongoDB with the same user model structure to store the user objects. For the Docker base image I used adoptopenjdk/openjdk8-openj9:alpine, which contains the cloud-optimized OpenJ9 Java virtual machine implementation, instead of Open JDK. Open J9 helps to reduce the memory footprint of Java applications.
- RAM usage in idle after startup: ~ 110 MB
- RAM usage after 1000 POST and 1000 GET requests: ~ 140 MB
- Jar size: 33 MB
- Docker image size (jar included): 250 MB
License
Copyright (c) 2019-2023 Andreas Bauer
See LICENSE file in the root of this project for license details.
Owner
- Name: Andreas Bauer
- Login: andreas-bauer
- Kind: user
- Location: Germany | Sweden
- Repositories: 5
- Profile: https://github.com/andreas-bauer
GitHub Events
Total
Last Year
Packages
- Total packages: 1
- Total downloads: unknown
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
proxy.golang.org: github.com/andreas-bauer/simple-go-user-service
- Homepage: https://github.com/andreas-bauer/simple-go-user-service
- Documentation: https://pkg.go.dev/github.com/andreas-bauer/simple-go-user-service#section-documentation
- License: MIT
-
Latest release: v0.0.0-20230309182112-f9e20645fd39
published over 3 years ago
Rankings
Dependencies
- github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db
- github.com/google/go-cmp v0.2.0
- github.com/google/pprof v0.0.0-20190109223431-e84dfd68c163
- github.com/gorilla/context v1.1.1
- github.com/gorilla/mux v1.6.2
- github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6
- github.com/mongodb/mongo-go-driver v0.1.0
- github.com/prometheus/common v0.0.0-20190107103113-2998b132700a
- github.com/sirupsen/logrus v1.5.0
- github.com/stretchr/testify v1.3.0
- github.com/tidwall/pretty v0.0.0-20180105212114-65a9db5fad51
- github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c
- github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc
- golang.org/x/arch v0.0.0-20181203225421-5a4828bb7045
- golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc
- golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4
- golang.org/x/text v0.3.0
- github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc
- github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf
- github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973
- github.com/davecgh/go-spew v1.1.0
- github.com/davecgh/go-spew v1.1.1
- github.com/go-kit/kit v0.8.0
- github.com/go-logfmt/logfmt v0.3.0
- github.com/go-stack/stack v1.8.0
- github.com/gogo/protobuf v1.1.1
- github.com/golang/protobuf v1.2.0
- github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db
- github.com/google/go-cmp v0.2.0
- github.com/google/pprof v0.0.0-20190109223431-e84dfd68c163
- github.com/gorilla/context v1.1.1
- github.com/gorilla/mux v1.6.2
- github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6
- github.com/julienschmidt/httprouter v1.2.0
- github.com/konsorten/go-windows-terminal-sequences v1.0.1
- github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515
- github.com/matttproud/golang_protobuf_extensions v1.0.1
- github.com/mongodb/mongo-go-driver v0.1.0
- github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223
- github.com/pkg/errors v0.8.0
- github.com/pmezard/go-difflib v1.0.0
- github.com/prometheus/client_golang v0.9.1
- github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910
- github.com/prometheus/common v0.0.0-20190107103113-2998b132700a
- github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d
- github.com/sirupsen/logrus v1.2.0
- github.com/sirupsen/logrus v1.3.0
- github.com/sirupsen/logrus v1.5.0
- github.com/stretchr/objx v0.1.0
- github.com/stretchr/objx v0.1.1
- github.com/stretchr/testify v1.2.2
- github.com/stretchr/testify v1.3.0
- github.com/tidwall/pretty v0.0.0-20180105212114-65a9db5fad51
- github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c
- github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc
- golang.org/x/arch v0.0.0-20181203225421-5a4828bb7045
- golang.org/x/crypto v0.0.0-20180904163835-0709b304e793
- golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc
- golang.org/x/net v0.0.0-20181114220301-adae6a3d119a
- golang.org/x/sync v0.0.0-20181108010431-42b317875d0f
- golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4
- golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33
- golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5
- golang.org/x/sys v0.0.0-20190109145017-48ac38b7c8cb
- golang.org/x/sys v0.0.0-20190422165155-953cdadca894
- golang.org/x/text v0.3.0
- gopkg.in/alecthomas/kingpin.v2 v2.2.6
- gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
- gopkg.in/yaml.v2 v2.2.1
- alpine latest build
- golang 1.15-alpine build
- mongo latest
- simple-go-user-service latest