Go API Core 
Based on common API stack, here is a list of enhanced packages to simplify your go (or 'golang') API development.
Contents
Getting started
You have an option, you can use core Config or your own config.
Here if you use core Config:
- Download core by using:
$ go get -u github.com/tossaro/go-api-core
-
Add file .env
on your main.go
folder, see .env
-
Import the following package:
import core "github.com/tossaro/go-api-core"
- Initial the config in
main.go
code:
func main() {
cfg, err := core.NewConfig()
if err != nil {
log.Fatal("Config error: %s", err)
}
//...
}
- Add every package that you need for your API as example
gin
:
cap := true
grpcUrl := ":" + cfg.GRPC.Port
g := gin.New(&gin.Options{
Mode: cfg.HTTP.Mode,
Version: cfg.App.Version,
BaseUrl: cfg.App.Name,
Logger: l,
// if session from redis
// Redis: rdb,
// if session from another grpc service
AuthService: &grpcUrl,
AccessToken: cfg.TOKEN.Access,
RefreshToken: cfg.TOKEN.Refresh,
Captcha: &cap,
})
Enhanced Packages
License
The MIT License (MIT)
Copyright © 2022
Hamzah Tossaro
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.