Simple web application in Go which accepts math problems via the URL and returns the response in JSON.
Before proceeding to the next steps, make sure you have Go installed and GOPATH environment variable set.
go get https://github.com/igorvarga/simplemath
Server can be configured using environment variables listed below. In case that environment variables are missing the default values will be used.
Variable | Description |
---|---|
SM_ADDR | Server address string in addreess:port format, default value: ":8080" |
SM_CACHE_EXPIRATION | Cache item expiry in seconds, default value: 60 |
SM_CACHE_SWEEPINTERVAL | Expired cache items sweep interval in seconds, default value 5 |
Windows example
SET SM_ADDR=":9090"
SET SM_CACHE_EXPIRATION=30
SET SM_CACHE_SWEEPINTERVAL=5
Linux example
Substitute SET with EXPORT keyword
cd %GOPATH%\src\github.com\igorvarga\simplemath
go run main.go
cd %GOPATH%\src\github.com\igorvarga\simplemath
go build .
curl "http://localhost:8080/add?x=2&y=7"
cd %GOPATH%\src\github.com\igorvarga\simplemath
go test ./...
Connect CircleCI for building and deploying steps to any cloud provider supported by CircleCI.
- Use .env for configuration
- Init project as go module
- Add docker (dev/docker branch)
- Add client cache HTTP headers
- Introduce context cancellation to all layers
- Add leaky bucket feature to cache, map memory limit
- Explore RWMutex
- Refactor server and cache structs and interfaces to be more specific about their functionality
- Explore sync.Map
- Benchmark, sync race and memory profiling tests
- Write better godoc and tests
- REST API versioning