February 2018
Intermediate to advanced
340 pages
9h 43m
English
package main import ( "encoding/json" "fmt" "os" ) type Client struct { consulIP string connString string } func (c *Client) String() string { return fmt.Sprintf("ConsulIP: %s , Connection String: %s", c.consulIP, c.connString) } var defaultClient = Client{ consulIP: "localhost:9000", connString: "postgres://localhost:5432", } // ConfigFunc works as a type to be used // in functional options type ConfigFunc func(opt *Client) // FromFile func returns the ConfigFunc // type. So this way it could read the configuration // from the json. func FromFile(path string) ConfigFunc { return func(opt ...Read now
Unlock full access