gowok

package module
v0.4.29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 38 Imported by: 27

README

Gowok is a library that contains a lot of functions that help you to build Go project.

codecov

It has some utilities like:

  • config loader,
  • project bootstrapper,
  • HTTP response builder,
  • nil safety,
  • password hash, and so on.

Getting Started

Installation

Run this command inside your project.

go get github.com/gowok/gowok

Import in Project

In your main.go, write code like following example:

package main

import "github.com/gowok/gowok"

func main() {
	gowok.Run()
}

Create Configuration

  1. Create a YAML file named config.yaml.
  2. Then write this.
web:
  enabled: true
  host: :8080

Running the Project

Run this command inside your project.

go run main.go

Or if config file not on root dir, use flag --config

go run main.go --config=folder/gowok.yaml

It 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:8080

It 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.

Apply Plugin

gowok have multiple plugin to help you to build your project, please check here for available plugins.

How to use plugin

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)

How to Contribute

Feel free to raise an issue or lovely pull request 😊

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Async = &_async{}
View Source
var CMD = &_cmd{
	Command: &cobra.Command{},
}
View Source
var Config = &config.Config{}
View Source
var GRPC = _grpc{
	Server: grpc.NewServer(),
}
View Source
var Hash = _hash{}
View Source
var Health = _health{
	// contains filtered or unexported fields
}
View Source
var Hooks = &_hooks{&runtime.Hooks{}}
View Source
var Net = &_net{
	handler: func(l net.Conn) {},
}
View Source
var SQL = _sql{
	// contains filtered or unexported fields
}
View Source
var Web = &_web{
	HttpServeMux: ngamux.NewHttpServeMux(),
	Server:       &http.Server{},
	Handler:      &_webHandler{},
	Response:     &_webResponse{},
	Request:      &_webRequest{},
	Resource:     &_webResource{},
}

Functions

func DD

func DD(input any) error

func Flags

func Flags() *flags

func Must added in v0.4.22

func Must[T any](res T, err error) T

func Run added in v0.3.94

func Run(config ...any)

func Shutdown added in v0.4.26

func Shutdown()

func ToPtr

func ToPtr[T any](v T) *T

Types

type ConfigureFunc

type ConfigureFunc func()

type Password added in v0.4.22

type Password struct {
	Hashed string
	Salt   string
}

type Project

type Project struct {
	// contains filtered or unexported fields
}

func Configures added in v0.3.94

func Configures(configures ...ConfigureFunc) *Project

func (*Project) Run

func (p *Project) Run(config ...any)

Directories

Path Synopsis
web

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL