v0.0.0-...-2262de7 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2023 License: NCSA Imports: 22 Imported by: 0




View Source
const (
	LocationCWDSub int = 1 << iota


View Source
var CertificateTemplate = &x509.Certificate{
	SerialNumber: big.NewInt(1),
	Subject: pkix.Name{
		Country:            []string{"US"},
		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,
View Source
var ErrInvalidType = errors.NewError("invalid type")
View Source
var ErrNoSuchConfig = errors.NewError("specified configuration could not be found")
View Source
var ErrNoSuchFile = errors.NewError("no such file")
View Source
var ErrTypeConversion = errors.NewError("error converting type")


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

func FindFreePort(proto string, host string, start int) int

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 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 FindFreePortListener(proto string, host string, start int) (net.Listener, error)

func GenerateSelfSignedCertificate

func GenerateSelfSignedCertificate(ips []net.IP, domains []string) (pemkey, pemcert []byte, err error)

func MapForm

func MapForm(form url.Values, dst interface{}) error

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.


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 PathOptions struct {
	Locations     int
	BaseDirectory string

type Scanner

type Scanner struct {
	// contains filtered or unexported fields

func NewScanner

func NewScanner(in io.Reader) *Scanner

func (*Scanner) Scan

func (s *Scanner) Scan() ([]byte, error)

func (*Scanner) ScanBool

func (s *Scanner) ScanBool() *bool

func (*Scanner) ScanBoolDefault

func (s *Scanner) ScanBoolDefault(b bool) bool

func (*Scanner) ScanInt

func (s *Scanner) ScanInt() *int

func (*Scanner) ScanIntDefault

func (s *Scanner) ScanIntDefault(i int) int

func (*Scanner) ScanString

func (s *Scanner) ScanString() *string

func (*Scanner) ScanStringDefault

func (s *Scanner) ScanStringDefault(str string) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL