https://github.com/go-flexible/flex
A collection of packages for building Go services.
https://github.com/go-flexible/flex
12-factor go golang golang-library microservice
Last synced: 2 months ago
JSON representation
A collection of packages for building Go services.
- Host: GitHub
- URL: https://github.com/go-flexible/flex
- Owner: go-flexible
- License: apache-2.0
- Created: 2021-06-11T12:29:06.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-10-31T16:40:07.000Z (5 months ago)
- Last Synced: 2025-10-31T18:22:18.062Z (5 months ago)
- Topics: 12-factor, go, golang, golang-library, microservice
- Language: Go
- Homepage:
- Size: 56.6 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# flex
A collection of packages for building Go services.
## Quick Start
Below is an example for how to get running quickly.
This code can be found in the examples folder.
```go
package main
import (
"context"
"fmt"
"log"
"net/http"
"github.com/go-flexible/flex"
)
func main() {
router := http.NewServeMux()
router.HandleFunc("/", func(rw http.ResponseWriter, r *http.Request) {
fmt.Fprint(rw, "hello, world\n")
})
srv := &http.Server{
Addr: ":8080",
Handler: router,
}
flex.MustStart(
context.Background(),
NewHTTPServer(srv),
)
}
// TODO: this functionality should be provided by a plugin.
// for now this is an example on how to implement our interfaces.
type Server struct{ *http.Server }
func NewHTTPServer(s *http.Server) *Server {
return &Server{Server: s}
}
func (s *Server) Run(_ context.Context) error {
log.Printf("serving on: http://localhost%s\n", s.Addr)
return s.ListenAndServe()
}
func (s *Server) Halt(ctx context.Context) error {
return s.Shutdown(ctx)
}
```
## Contributors
Contributors listed in alphabetical order.
- [Ben Cable](https://github.com/ladydascalie): Author & Maintainer
- [Zee Philip Vieira](https://github.com/zeeraw): Author & Maintainer