Documentation
¶
Index ¶
- Constants
- Variables
- func FindConfig(filename string, opts *PathOptions) (string, error)
- func FindFreePort(proto string, host string, start int) int
- func FindFreePortListener(proto string, host string, start int) (net.Listener, error)
- func GenerateSelfSignedCertificate(ips []net.IP, domains []string) (pemkey, pemcert []byte, err error)
- func MapForm(form url.Values, dst interface{}) error
- type Configurator
- type PathOptions
- type Scanner
Constants ¶
const ( LocationCWDSub int = 1 << iota LocationHome LocationXDGConfigHome LocationEtc )
Variables ¶
var CertificateTemplate = &x509.Certificate{ SerialNumber: big.NewInt(1), Subject: pkix.Name{ Country: []string{"US"}, Organization: []string{"PLUGGABLE IDEAS™ IMPETUS™ SELF-SIGNED CERTIFICATE"}, OrganizationalUnit: []string{"PLUGGABLE IDEAS™ IMPETUS™ SELF-SIGNED CERTIFICATE"}, Locality: []string{"INVALID"}, Province: []string{"INVALID"}, StreetAddress: []string{"INVALID"}, PostalCode: []string{"INVALID"}, SerialNumber: "1", CommonName: "", }, NotBefore: time.Now().Add(time.Hour * -2), NotAfter: time.Now().Add(time.Hour * 24 * 30 * 3), KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign, ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, IsCA: true, BasicConstraintsValid: true, }
var ErrInvalidType = errors.NewError("invalid type")
var ErrNoSuchConfig = errors.NewError("specified configuration could not be found")
var ErrNoSuchFile = errors.NewError("no such file")
var ErrTypeConversion = errors.NewError("error converting type")
Functions ¶
func FindConfig ¶
func FindConfig(filename string, opts *PathOptions) (string, error)
FindConfig searches for the configuration file `filename` in the location described by `opts`. Depending on the constants included in opts.Locations, this will search the specified subdirectory in the current working directory, the user's home directory, XDG_CONFIG_HOME (Linux), or /etc for `filename` in addition to the current working directory.
func FindFreePort ¶
FindFreePort returns the first free port starting with the port delimited by `start` (inclusive) on the host `host` using the protocol `proto`. If host is the empty string, this will find the first free port that is available on all IP interfaces. Protocols are defined by the networks as understood by Golang's Dial function (e.g. "tcp").
While 0.0.0.0 will get you all IPv4 interfaces, "::" may get you all IPv6 interfaces or it may get you all IPv6 and IPv4 interfaces. How "::" is interpreted will depend on your platform and its configuration.
N.B.: By default, this will only probe 20 ports at a time. If no free port is found, this will return 0. If you need to scan a larger range, you must encapsulate this in a loop.
func FindFreePortListener ¶
func MapForm ¶
MapForm data described by `form` into the destination interface `dst`. `dst` must be a struct with tags describing individual field names. Struct tags may be named "json" or "form" with a preference on "json" for interoperability, e.g.:
type FormData struct { ID int `json:"id"` Name string `json:"name"` }
Precedence will be given to "form" if it appears in the struct tag allowing client code to differentiate between data read from JSON input and form input.
Types ¶
type Configurator ¶
type Configurator struct { // Defaults indicates the filename from which default values should be // extracted. Defaults string // contains filtered or unexported fields }
Configurator provides parsing access to YAML configurations with an option to a) load a predefined configuration from a VFS construct (local directory, zip files, embedded assets, etc), use that configuration as the target defaults, and then replace the values with a configuration file defined elsewhere (current directory, XDG_CONFIG_HOME, /etc, and so forth).
func (*Configurator) AddVFS ¶
func (c *Configurator) AddVFS(fs vfs.VFS)
func (*Configurator) Load ¶
func (c *Configurator) Load(file string, v interface{}) error
func (*Configurator) VFSConfig ¶
func (c *Configurator) VFSConfig(filename string, opts *PathOptions) (vfs.ReadOnlyFile, error)
type PathOptions ¶
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}