bud

command module
v0.0.0-...-2f30d10 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 4 Imported by: 0

README

bud: Simplify and Graceful Golang Code

Simplify and Graceful Golang Code. Features include: auto-wiring, stream api, ... more TODO

Feature List

  • wire: Runtime Dynamic Auto-Wiring Using Dependency Injection
  • stream: stream api like java to deal with slice
  • enum: TODO
  • trace-log: TODO
  • config: TODO
  • plugin: TODO
  • util: TODO
  • remote: TODO:
  • sys info: TODO: github.com/shirou/gopsutil

wire

Runtime Dynamic Auto-Wiring Using Dependency Injection

Wire is a tool for automating the wiring of components at runtime using dependency injection. The dependencies between components can be defined by the tag marked on the field of the struct, or by the parameters of the Init method.

easy start

repository struct looks like

package repo

import "github.com/peace0phmind/bud/factory"

func init() {
	factory.Singleton[MyRepo]() // registry MyRepo as a singleton service
}

// MyRepo to control model with db
type MyRepo struct {
	//...
}

func (mr *MyRepo) SaveData() {
	//...
}

service struct looks like


package service

import "github.com/peace0phmind/bud/factory"
import "repo"

func init() {
	factory.Singleton[MyService]() // registry MyRepo as a singleton service
}

type MyService struct {
	myRepo *repo.MyRepo `wire:"auto"`
}

func (ms *MyService) DoSomething() {
	// ...
	ms.myRepo.SaveDate()
	// ...
}

main.go

package main

import "github.com/peace0phmind/bud/factory"
import "service"

func main() {
	serv := factory.Get[servcie.MyService]()

	serv.DoSomething()
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
bud
ast
example
mvc
proto
ext
opt

Jump to

Keyboard shortcuts

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