pacman

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 7 Imported by: 5

README

drawing

Pacman - Yet Another Toolkit to Build Golang Application Quickly

LICENSE Language

Notice: This document also has Simplified Chinese 中文版本 Edition.

What is Pacman?

Pacman is the package manager of Arch Linux. The goal of Pacman is to make it possible to easily manage packages.

So the goal of this tool is similar, to make it easier to manage golang third-party libraries while building applications quickly.

Changelog

20220919 initial release

Design Philosophy

Golang is very stable and powerful for server-side application development. But some general issues are confusing and blocking the progress of development, such as:

  1. We need many third-party libraries to build the application. We need to choose a suitable one or multiple solutions at the same time, but do not want to be too dependent on them;
  2. The upgrade and replacement of third-party dependencies will cause failures, eg. some third-party libraries do not support major version updates.
  3. We're building microservices that may require common features, so we don't need to develop them repeatedly.

Based on above the issues, we began to think about how to manage third-party libraries. Far as we are aware of the Spring Boot which famous framework from Java world managing the third-party libraries or dependencies by Bean. This is the appropriate implementation for Ioc - The injection of dependencies.

Requirements and install

This project requires golang v1.18 or higher version with new features such as general generic and so on.

How to Use It

To use this toolkit is very simple and easy. For example, we wanna including the general cache module which has implemented:

First, we import the interface from the definition of the cache module.

import "github.com/segmentfault/pacman/cache/v2"

Second, we import the implementation from the other path.

import "github.com/segmentfault/pacman/contrib/cache/v2"

Finally, we use it!

cache := v2.NewCache[int, string]()
cache.Set(1, "hello")

got, ok := cache.Get(1)
assert.Equal(t, ok, true)
assert.Equal(t, got, "hello")

The cache module should be running correctly.

Contributing

Contributions are always welcome!

See contributing.md for ways to get started.

Please adhere to this project's code of conduct.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithID

func WithID(id string) func(application *Application)

WithID application add id

func WithName

func WithName(name string) func(application *Application)

WithName application add name

func WithServer

func WithServer(servers ...server.Server) func(application *Application)

WithServer application add server

func WithSignals

func WithSignals(signals []os.Signal) func(application *Application)

WithSignals application add listen signals

func WithVersion

func WithVersion(version string) func(application *Application)

WithVersion application add version

Types

type Application

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

Application is the main struct of the application

func NewApp

func NewApp(ops ...Option) *Application

NewApp creates a new Application

func (*Application) Run

func (app *Application) Run() error

Run application run

func (*Application) Stop

func (app *Application) Stop() error

Stop application stop

type Option

type Option func(application *Application)

Option application support option

Directories

Path Synopsis
v2
contrib
cache Module
cache/memory Module
cache/redis Module
conf/viper Module
i18n Module
log/zap Module
server/grpc Module
server/http Module

Jump to

Keyboard shortcuts

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