https://github.com/jingyuexing/go-utils
https://github.com/jingyuexing/go-utils
cookie go template-string time time-duration utils-library
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jingyuexing/go-utils
- Owner: jingyuexing
- License: mit
- Created: 2023-03-08T20:05:43.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2025-01-17T02:56:22.000Z (about 1 year ago)
- Last Synced: 2025-01-17T03:30:23.263Z (about 1 year ago)
- Topics: cookie, go, template-string, time, time-duration, utils-library
- Language: Go
- Homepage:
- Size: 127 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## go-utils
This is a method or function that I often use
## usage
```go
func Template(source string, data map[string]string, placeholder string) string
```
- This function can perform template string substitution
[see test case](utils_test.go#L10-L82)
```go
func GetPathValue(raw string, realPath string) map[string]string
```
- This string will directly get the value corresponding to the template [see test case](utils_test.go#L91-L100)
```go
func (c *Cookie) NewCookie(cookie string, delimiter string, joiner string) *Cookie
```
- This can parse the Cookie string or parse the Query string, you can specify separators and connectors for parsing [see test case](utils_test.go#L84-L89)
```go
func Map2Struct(source map[string]any, bindingTarget any)
```
- You can bind the value of the map to the structure, provided that the fields of the structure and the fields of the map are consistent in lowercase [see test case](utils_test.go#L102-L105)