Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coder2z/g-server
Golang development of public components finishing
https://github.com/coder2z/g-server
go grpc grpc-go microserver server
Last synced: 5 days ago
JSON representation
Golang development of public components finishing
- Host: GitHub
- URL: https://github.com/coder2z/g-server
- Owner: coder2z
- License: mit
- Created: 2020-12-22T09:33:01.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-15T11:45:15.000Z (over 2 years ago)
- Last Synced: 2024-06-21T20:07:52.854Z (5 months ago)
- Topics: go, grpc, grpc-go, microserver, server
- Language: Go
- Homepage:
- Size: 417 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# g-server
Self-use microservice framework
![](https://img.shields.io/badge/windowns10-Development-d0d1d4)
![](https://img.shields.io/badge/golang-1.16-blue)
[![](https://img.shields.io/badge/godoc-reference-3C57C4)](https://pkg.go.dev/github.com/coder2z/g-server)
![](https://img.shields.io/badge/version-1.0.5-r)## :rocket:Installation
`
go get -u github.com/coder2z/g-server
`## :bell:Features
Encapsulate many tool functions and methods, and continue to update. Most of the methods are open source and other open
source projects.```
xapp = > runtime app info
datasource = > xcfg data
xcode = > err coder encapsulation
xgovern = > system monitoring
xgrpc = > grpc encapsulation
xinvoker = > invoker
xmoniter = > prometheus
xregistry = > service registration discovery
xtrace = > trace
xversion = > frame version
```## :anchor:Usage
### config file
```toml
[db]
[db.dev]
password = "root"
dbName = "ndisk"[redis]
[redis.dev]
```### main.go usage
```env
set SERVER_APP_MODE dev
set SERVER_APP_ID 79@sh$x3@
set SERVER_APP_DEBUG false
``````go
package mainimport (
"github.com/coder2z/g-saber/xconsole"
"github.com/coder2z/g-saber/xflag"
"github.com/coder2z/g-server/xapp"
)func main() {
xflag.NewRootCommand(
&xflag.CommandNode{
Name: "main",
Command: &xflag.Command{
Use: "main",
DisableSuggestions: false,
Run: func(cmd *xflag.Command, args []string) {
RunApp()
},
},
Flags: func(c *xflag.Command) {
c.Flags().StringP("xcfg", "c", "", "配置文件")
_ = c.MarkFlagRequired("config")
},
},
)
_ = xflag.Parse()
}func RunApp() {
xapp.PrintVersion()
xconsole.Green("running")
}
```### run
```bash
go build -o mainApp -ldflags "-X github.com/coder2z/g-server/xapp.appName=app_name -X github.com/coder2z/g-server/xapp.buildAppVersion=v1.0 -X github.com/coder2z/g-server/xapp.buildHost=`hostname`" main.go
./mainApp -c=test.toml
```## :tada:Contribute code
Open source projects are inseparable from everyone’s support. If you have a good idea, encountered some bugs and fixed
them, and corrected the errors in the document, please submit a Pull Request~1. Fork this project to your own repo
2. Clone the project in the past, that is, the project in your warehouse, to your local
3. Modify the code
4. Push to your own library after commit
5. Initiate a PR (pull request) request and submit it to the `provide` branch
6. Waiting to merge## :closed_book:License
Distributed under MIT License, please see license file within the code for more details.