No description
Find a file
2025-03-23 23:45:38 +01:00
cache fix: file cache get 2025-03-23 23:45:38 +01:00
database Imported from hako 2024-11-20 23:21:03 +01:00
encoding encoding package 2024-11-23 19:41:21 +01:00
model tests: cache 2025-03-23 23:37:26 +01:00
paths feat: paths 2025-03-23 21:00:03 +01:00
server/http Imported from hako 2024-11-20 23:21:03 +01:00
service Imported from hako 2024-11-20 23:21:03 +01:00
template Imported from hako 2024-11-20 23:21:03 +01:00
.gitignore Initial commit 2024-11-20 18:07:52 +01:00
go.mod tests: cache 2025-03-23 23:37:26 +01:00
go.sum tests: cache 2025-03-23 23:37:26 +01:00
LICENSE Initial commit 2024-11-20 18:07:52 +01:00
README.md Imported from hako 2024-11-20 23:21:03 +01:00

gotoolkit

A set of basic tools to develop Go applications.

Database

A basic database engine to manage the connection to a database.

db, err := database.New("postgres://user:password@localhost:5432/dbname")
if err != nil {
	// ...
}

Service & Servers

A basic way to expose servers within one service.

A service is the main point of the application, and it can expose multiple servers. Using the provided interfaces you can create a new service with multiple servers.

A simple example with one single HTTP server:


import "git.nakama.town/fmartingr/gotoolkit/model"

type httpServer struct {}

func (s *httpServer) IsEnabled() bool {
	return true
}

func (s *httpServer) Start(_ context.Context) error {
	return s.http.ListenAndServe()
}

func (s *httpServer) Stop(ctx context.Context) error {
	return s.http.Shutdown(ctx)
}

func newHttpServer() (servers.Server, error) {
	httpServer := &httpServer{}
	// http server logic
	return httpServer, nil
}

func main() {
	httpServer, _ := newHttpServer()
	svc := service.New([]model.Server{server})
	svc.Start(context.Background())
	svc.WaitStop()
}

Template

A basic template engine to render html templates.

//go:embed templates/*.html
var Templates embed.FS
// ...
engine, _ := template.NewEngine(Templates)
result, _ := engine.Render("template.html", struct {
	Message string
}{
	Message: "nometokens"
})