Gowok is a library that contains a lot of functions that help you to build Go project.
It has some utilities like:
- config loader,
- project bootstrapper,
- HTTP response builder,
- nil safety,
- password hash, and so on.
Run this command inside your project.
go get github.com/gowok/gowokIn your main.go, write code like following example:
package main
import "github.com/gowok/gowok"
func main() {
gowok.Run()
}- Create a YAML file named
config.yaml. - Then write this.
web:
enabled: true
host: :8080Run this command inside your project.
go run main.goOr if config file not on root dir, use flag --config
go run main.go --config=folder/gowok.yamlIt will show output like this:
2025/01/13 10:43:09 INFO starting web
Your project now ready to use 🔥
Let's try to send a request using curl!
curl localhost:8080It will show output like this:
404 page not found
It means that your project already run. It can receive actual request and give response to it.
gowok have multiple plugin to help you to build your project, please check here for available plugins.
example we want to use gorm
we can import plugin gorm
import "github.com/gowok/plugins/gorm"after import plugin, we can configure it to main function or function you want to open database connection
func main() {
gowok.Configures(
gorm.Configure(map[string]gorm.Opener{
"postgres": driver.Open,
}),
)
}then you can use gorm example like this:
db, _ := gorm.DB("postgres").Get()
db.WithContext(ctx).First(&user)Feel free to raise an issue or lovely pull request 😊