|
| 1 | +<center> |
| 2 | + <img src="docs/logo.png" alt="drawing" width="120" align="center" /> |
| 3 | +</center> |
| 4 | + |
| 5 | +# Pacman - Yet Another Toolkit to Build Golang Application Quickly |
| 6 | + |
| 7 | +[](https://github.com/segmentfault/pacmam/blob/master/LICENSE) |
| 8 | +[](https://golang.org/) |
| 9 | + |
| 10 | +<!-- TOC depthfrom:2 orderedlist:false --> |
| 11 | + |
| 12 | +- [What is Pacman?](#what-is-pacman) |
| 13 | +- [Changelog](#changelog) |
| 14 | +- [Design Philosophy](#design-philosophy) |
| 15 | +- [Requirements and install](#requirements-and-install) |
| 16 | +- [How to Use It](#how-to-use-it) |
| 17 | +- [Contributing](#contributing) |
| 18 | +- [License](#license) |
| 19 | + |
| 20 | +<!-- /TOC --> |
| 21 | + |
| 22 | +Notice: This document also has [Simplified Chinese 中文版本](README_CN.md) Edition. |
| 23 | + |
| 24 | +## What is Pacman? |
| 25 | + |
| 26 | +[Pacman](https://wiki.archlinux.org/title/Pacman) is the package manager of Arch Linux. The goal of Pacman is to make it possible to easily manage packages. |
| 27 | + |
| 28 | +So the goal of this tool is similar, to make it easier to manage golang third-party libraries while building applications quickly. |
| 29 | + |
| 30 | +## Changelog |
| 31 | + |
| 32 | +`20220919` initial release |
| 33 | + |
| 34 | +## Design Philosophy |
| 35 | + |
| 36 | +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: |
| 37 | + |
| 38 | +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; |
| 39 | +2. The upgrade and replacement of third-party dependencies will cause failures, eg. some third-party libraries do not support major version updates. |
| 40 | +3. We're building microservices that may require common features, so we don't need to develop them repeatedly. |
| 41 | + |
| 42 | +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. |
| 43 | + |
| 44 | +## Requirements and install |
| 45 | + |
| 46 | +This project requires golang v1.18 or higher version with new features such as general generic and so on. |
| 47 | + |
| 48 | +## How to Use It |
| 49 | + |
| 50 | +To use this toolkit is very simple and easy. For example, we wanna including the general cache module which has implemented: |
| 51 | + |
| 52 | +First, we import the interface from the definition of the cache module. |
| 53 | + |
| 54 | +```go |
| 55 | +import "github.com/segmentfault/pacman/cache/v2" |
| 56 | +``` |
| 57 | + |
| 58 | +Second, we import the implementation from the other path. |
| 59 | + |
| 60 | +```go |
| 61 | +import "github.com/segmentfault/pacman/contrib/cache/v2" |
| 62 | +``` |
| 63 | + |
| 64 | +Finally, we use it! |
| 65 | + |
| 66 | +```go |
| 67 | +cache := v2.NewCache[int, string]() |
| 68 | +cache.Set(1, "hello") |
| 69 | + |
| 70 | +got, ok := cache.Get(1) |
| 71 | +assert.Equal(t, ok, true) |
| 72 | +assert.Equal(t, got, "hello") |
| 73 | +``` |
| 74 | + |
| 75 | +The cache module should be running correctly. |
| 76 | + |
| 77 | +## Contributing |
| 78 | + |
| 79 | +Contributions are always welcome! |
| 80 | + |
| 81 | +See `contributing.md` for ways to get started. |
| 82 | + |
| 83 | +Please adhere to this project's `code of conduct`. |
| 84 | + |
| 85 | +## License |
| 86 | + |
| 87 | +[MIT](https://github.com/segmentfault/pacmam/blob/master/LICENSE) |
0 commit comments