https://github.com/way29/optfunc
Optional Parameters for go functions
https://github.com/way29/optfunc
Last synced: 8 months ago
JSON representation
Optional Parameters for go functions
- Host: GitHub
- URL: https://github.com/way29/optfunc
- Owner: WAY29
- Created: 2020-11-19T12:34:13.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-19T13:07:58.000Z (over 5 years ago)
- Last Synced: 2024-12-29T09:25:24.420Z (over 1 year ago)
- Language: Go
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# OPTFUNC
***Optional Parameters for go functions***
## Examples
```go
package main
import (
"fmt"
. "github.com/WAY29/optfunc"
)
/*
Use optfunc.With for options
address string "127.0.0.1"
port string "80"
*/
func NewClient(opts ...Options) {
o := NewOptions(
OptionsParams{
"address": "127.0.0.1",
"port": "80",
},
).Apply(opts...)
fmt.Printf("Address is %s:%s\n", o.Get("address"), o.Get("port"))
}
func main() {
NewClient()
NewClient(With("address", "192.168.1.1"))
}
```