repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
docker/libnetwork
drvregistry/drvregistry.go
WalkDrivers
func (r *DrvRegistry) WalkDrivers(dfn DriverWalkFunc) { type driverVal struct { name string data *driverData } r.Lock() dvl := make([]driverVal, 0, len(r.drivers)) for k, v := range r.drivers { dvl = append(dvl, driverVal{name: k, data: v}) } r.Unlock() for _, dv := range dvl { if dfn(dv.name, dv.data.driver, dv.data.capability) { break } } }
go
func (r *DrvRegistry) WalkDrivers(dfn DriverWalkFunc) { type driverVal struct { name string data *driverData } r.Lock() dvl := make([]driverVal, 0, len(r.drivers)) for k, v := range r.drivers { dvl = append(dvl, driverVal{name: k, data: v}) } r.Unlock() for _, dv := range dvl { if dfn(dv.name, dv.data.driver, dv.data.capability) { break } } }
[ "func", "(", "r", "*", "DrvRegistry", ")", "WalkDrivers", "(", "dfn", "DriverWalkFunc", ")", "{", "type", "driverVal", "struct", "{", "name", "string", "\n", "data", "*", "driverData", "\n", "}", "\n", "r", ".", "Lock", "(", ")", "\n", "dvl", ":=", "make", "(", "[", "]", "driverVal", ",", "0", ",", "len", "(", "r", ".", "drivers", ")", ")", "\n", "for", "k", ",", "v", ":=", "range", "r", ".", "drivers", "{", "dvl", "=", "append", "(", "dvl", ",", "driverVal", "{", "name", ":", "k", ",", "data", ":", "v", "}", ")", "\n", "}", "\n", "r", ".", "Unlock", "(", ")", "\n", "for", "_", ",", "dv", ":=", "range", "dvl", "{", "if", "dfn", "(", "dv", ".", "name", ",", "dv", ".", "data", ".", "driver", ",", "dv", ".", "data", ".", "capability", ")", "{", "break", "\n", "}", "\n", "}", "\n", "}" ]
// WalkDrivers walks the network drivers registered in the registry and invokes the passed walk function and each one of them.
[ "WalkDrivers", "walks", "the", "network", "drivers", "registered", "in", "the", "registry", "and", "invokes", "the", "passed", "walk", "function", "and", "each", "one", "of", "them", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L97-L115
train
docker/libnetwork
drvregistry/drvregistry.go
Driver
func (r *DrvRegistry) Driver(name string) (driverapi.Driver, *driverapi.Capability) { r.Lock() defer r.Unlock() d, ok := r.drivers[name] if !ok { return nil, nil } return d.driver, &d.capability }
go
func (r *DrvRegistry) Driver(name string) (driverapi.Driver, *driverapi.Capability) { r.Lock() defer r.Unlock() d, ok := r.drivers[name] if !ok { return nil, nil } return d.driver, &d.capability }
[ "func", "(", "r", "*", "DrvRegistry", ")", "Driver", "(", "name", "string", ")", "(", "driverapi", ".", "Driver", ",", "*", "driverapi", ".", "Capability", ")", "{", "r", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Unlock", "(", ")", "\n", "d", ",", "ok", ":=", "r", ".", "drivers", "[", "name", "]", "\n", "if", "!", "ok", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "return", "d", ".", "driver", ",", "&", "d", ".", "capability", "\n", "}" ]
// Driver returns the actual network driver instance and its capability which registered with the passed name.
[ "Driver", "returns", "the", "actual", "network", "driver", "instance", "and", "its", "capability", "which", "registered", "with", "the", "passed", "name", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L118-L128
train
docker/libnetwork
drvregistry/drvregistry.go
IPAM
func (r *DrvRegistry) IPAM(name string) (ipamapi.Ipam, *ipamapi.Capability) { r.Lock() defer r.Unlock() i, ok := r.ipamDrivers[name] if !ok { return nil, nil } return i.driver, i.capability }
go
func (r *DrvRegistry) IPAM(name string) (ipamapi.Ipam, *ipamapi.Capability) { r.Lock() defer r.Unlock() i, ok := r.ipamDrivers[name] if !ok { return nil, nil } return i.driver, i.capability }
[ "func", "(", "r", "*", "DrvRegistry", ")", "IPAM", "(", "name", "string", ")", "(", "ipamapi", ".", "Ipam", ",", "*", "ipamapi", ".", "Capability", ")", "{", "r", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Unlock", "(", ")", "\n", "i", ",", "ok", ":=", "r", ".", "ipamDrivers", "[", "name", "]", "\n", "if", "!", "ok", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "return", "i", ".", "driver", ",", "i", ".", "capability", "\n", "}" ]
// IPAM returns the actual IPAM driver instance and its capability which registered with the passed name.
[ "IPAM", "returns", "the", "actual", "IPAM", "driver", "instance", "and", "its", "capability", "which", "registered", "with", "the", "passed", "name", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L131-L141
train
docker/libnetwork
drvregistry/drvregistry.go
IPAMDefaultAddressSpaces
func (r *DrvRegistry) IPAMDefaultAddressSpaces(name string) (string, string, error) { r.Lock() defer r.Unlock() i, ok := r.ipamDrivers[name] if !ok { return "", "", fmt.Errorf("ipam %s not found", name) } return i.defaultLocalAddressSpace, i.defaultGlobalAddressSpace, nil }
go
func (r *DrvRegistry) IPAMDefaultAddressSpaces(name string) (string, string, error) { r.Lock() defer r.Unlock() i, ok := r.ipamDrivers[name] if !ok { return "", "", fmt.Errorf("ipam %s not found", name) } return i.defaultLocalAddressSpace, i.defaultGlobalAddressSpace, nil }
[ "func", "(", "r", "*", "DrvRegistry", ")", "IPAMDefaultAddressSpaces", "(", "name", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "r", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Unlock", "(", ")", "\n", "i", ",", "ok", ":=", "r", ".", "ipamDrivers", "[", "name", "]", "\n", "if", "!", "ok", "{", "return", "\"\"", ",", "\"\"", ",", "fmt", ".", "Errorf", "(", "\"ipam %s not found\"", ",", "name", ")", "\n", "}", "\n", "return", "i", ".", "defaultLocalAddressSpace", ",", "i", ".", "defaultGlobalAddressSpace", ",", "nil", "\n", "}" ]
// IPAMDefaultAddressSpaces returns the default address space strings for the passed IPAM driver name.
[ "IPAMDefaultAddressSpaces", "returns", "the", "default", "address", "space", "strings", "for", "the", "passed", "IPAM", "driver", "name", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L144-L154
train
docker/libnetwork
drvregistry/drvregistry.go
RegisterDriver
func (r *DrvRegistry) RegisterDriver(ntype string, driver driverapi.Driver, capability driverapi.Capability) error { if strings.TrimSpace(ntype) == "" { return errors.New("network type string cannot be empty") } r.Lock() dd, ok := r.drivers[ntype] r.Unlock() if ok && dd.driver.IsBuiltIn() { return driverapi.ErrActiveRegistration(ntype) } if r.dfn != nil { if err := r.dfn(ntype, driver, capability); err != nil { return err } } dData := &driverData{driver, capability} r.Lock() r.drivers[ntype] = dData r.Unlock() return nil }
go
func (r *DrvRegistry) RegisterDriver(ntype string, driver driverapi.Driver, capability driverapi.Capability) error { if strings.TrimSpace(ntype) == "" { return errors.New("network type string cannot be empty") } r.Lock() dd, ok := r.drivers[ntype] r.Unlock() if ok && dd.driver.IsBuiltIn() { return driverapi.ErrActiveRegistration(ntype) } if r.dfn != nil { if err := r.dfn(ntype, driver, capability); err != nil { return err } } dData := &driverData{driver, capability} r.Lock() r.drivers[ntype] = dData r.Unlock() return nil }
[ "func", "(", "r", "*", "DrvRegistry", ")", "RegisterDriver", "(", "ntype", "string", ",", "driver", "driverapi", ".", "Driver", ",", "capability", "driverapi", ".", "Capability", ")", "error", "{", "if", "strings", ".", "TrimSpace", "(", "ntype", ")", "==", "\"\"", "{", "return", "errors", ".", "New", "(", "\"network type string cannot be empty\"", ")", "\n", "}", "\n", "r", ".", "Lock", "(", ")", "\n", "dd", ",", "ok", ":=", "r", ".", "drivers", "[", "ntype", "]", "\n", "r", ".", "Unlock", "(", ")", "\n", "if", "ok", "&&", "dd", ".", "driver", ".", "IsBuiltIn", "(", ")", "{", "return", "driverapi", ".", "ErrActiveRegistration", "(", "ntype", ")", "\n", "}", "\n", "if", "r", ".", "dfn", "!=", "nil", "{", "if", "err", ":=", "r", ".", "dfn", "(", "ntype", ",", "driver", ",", "capability", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "dData", ":=", "&", "driverData", "{", "driver", ",", "capability", "}", "\n", "r", ".", "Lock", "(", ")", "\n", "r", ".", "drivers", "[", "ntype", "]", "=", "dData", "\n", "r", ".", "Unlock", "(", ")", "\n", "return", "nil", "\n", "}" ]
// RegisterDriver registers the network driver when it gets discovered.
[ "RegisterDriver", "registers", "the", "network", "driver", "when", "it", "gets", "discovered", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L162-L188
train
docker/libnetwork
drvregistry/drvregistry.go
RegisterIpamDriver
func (r *DrvRegistry) RegisterIpamDriver(name string, driver ipamapi.Ipam) error { return r.registerIpamDriver(name, driver, &ipamapi.Capability{}) }
go
func (r *DrvRegistry) RegisterIpamDriver(name string, driver ipamapi.Ipam) error { return r.registerIpamDriver(name, driver, &ipamapi.Capability{}) }
[ "func", "(", "r", "*", "DrvRegistry", ")", "RegisterIpamDriver", "(", "name", "string", ",", "driver", "ipamapi", ".", "Ipam", ")", "error", "{", "return", "r", ".", "registerIpamDriver", "(", "name", ",", "driver", ",", "&", "ipamapi", ".", "Capability", "{", "}", ")", "\n", "}" ]
// RegisterIpamDriver registers the IPAM driver discovered with default capabilities.
[ "RegisterIpamDriver", "registers", "the", "IPAM", "driver", "discovered", "with", "default", "capabilities", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L221-L223
train
docker/libnetwork
drvregistry/drvregistry.go
RegisterIpamDriverWithCapabilities
func (r *DrvRegistry) RegisterIpamDriverWithCapabilities(name string, driver ipamapi.Ipam, caps *ipamapi.Capability) error { return r.registerIpamDriver(name, driver, caps) }
go
func (r *DrvRegistry) RegisterIpamDriverWithCapabilities(name string, driver ipamapi.Ipam, caps *ipamapi.Capability) error { return r.registerIpamDriver(name, driver, caps) }
[ "func", "(", "r", "*", "DrvRegistry", ")", "RegisterIpamDriverWithCapabilities", "(", "name", "string", ",", "driver", "ipamapi", ".", "Ipam", ",", "caps", "*", "ipamapi", ".", "Capability", ")", "error", "{", "return", "r", ".", "registerIpamDriver", "(", "name", ",", "driver", ",", "caps", ")", "\n", "}" ]
// RegisterIpamDriverWithCapabilities registers the IPAM driver discovered with specified capabilities.
[ "RegisterIpamDriverWithCapabilities", "registers", "the", "IPAM", "driver", "discovered", "with", "specified", "capabilities", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drvregistry/drvregistry.go#L226-L228
train
docker/libnetwork
drivers/bridge/netlink_deprecated_linux.go
getIfSocket
func getIfSocket() (fd int, err error) { for _, socket := range []int{ syscall.AF_INET, syscall.AF_PACKET, syscall.AF_INET6, } { if fd, err = syscall.Socket(socket, syscall.SOCK_DGRAM, 0); err == nil { break } } if err == nil { return fd, nil } return -1, err }
go
func getIfSocket() (fd int, err error) { for _, socket := range []int{ syscall.AF_INET, syscall.AF_PACKET, syscall.AF_INET6, } { if fd, err = syscall.Socket(socket, syscall.SOCK_DGRAM, 0); err == nil { break } } if err == nil { return fd, nil } return -1, err }
[ "func", "getIfSocket", "(", ")", "(", "fd", "int", ",", "err", "error", ")", "{", "for", "_", ",", "socket", ":=", "range", "[", "]", "int", "{", "syscall", ".", "AF_INET", ",", "syscall", ".", "AF_PACKET", ",", "syscall", ".", "AF_INET6", ",", "}", "{", "if", "fd", ",", "err", "=", "syscall", ".", "Socket", "(", "socket", ",", "syscall", ".", "SOCK_DGRAM", ",", "0", ")", ";", "err", "==", "nil", "{", "break", "\n", "}", "\n", "}", "\n", "if", "err", "==", "nil", "{", "return", "fd", ",", "nil", "\n", "}", "\n", "return", "-", "1", ",", "err", "\n", "}" ]
// THIS CODE DOES NOT COMMUNICATE WITH KERNEL VIA RTNETLINK INTERFACE // IT IS HERE FOR BACKWARDS COMPATIBILITY WITH OLDER LINUX KERNELS // WHICH SHIP WITH OLDER NOT ENTIRELY FUNCTIONAL VERSION OF NETLINK
[ "THIS", "CODE", "DOES", "NOT", "COMMUNICATE", "WITH", "KERNEL", "VIA", "RTNETLINK", "INTERFACE", "IT", "IS", "HERE", "FOR", "BACKWARDS", "COMPATIBILITY", "WITH", "OLDER", "LINUX", "KERNELS", "WHICH", "SHIP", "WITH", "OLDER", "NOT", "ENTIRELY", "FUNCTIONAL", "VERSION", "OF", "NETLINK" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/bridge/netlink_deprecated_linux.go#L35-L49
train
docker/libnetwork
drivers/bridge/netlink_deprecated_linux.go
ioctlAddToBridge
func ioctlAddToBridge(iface, master *net.Interface) error { return ifIoctBridge(iface, master, ioctlBrAddIf) }
go
func ioctlAddToBridge(iface, master *net.Interface) error { return ifIoctBridge(iface, master, ioctlBrAddIf) }
[ "func", "ioctlAddToBridge", "(", "iface", ",", "master", "*", "net", ".", "Interface", ")", "error", "{", "return", "ifIoctBridge", "(", "iface", ",", "master", ",", "ioctlBrAddIf", ")", "\n", "}" ]
// Add a slave to a bridge device. This is more backward-compatible than // netlink.NetworkSetMaster and works on RHEL 6.
[ "Add", "a", "slave", "to", "a", "bridge", "device", ".", "This", "is", "more", "backward", "-", "compatible", "than", "netlink", ".", "NetworkSetMaster", "and", "works", "on", "RHEL", "6", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/bridge/netlink_deprecated_linux.go#L75-L77
train
docker/libnetwork
sandbox.go
OptionHostname
func OptionHostname(name string) SandboxOption { return func(sb *sandbox) { sb.config.hostName = name } }
go
func OptionHostname(name string) SandboxOption { return func(sb *sandbox) { sb.config.hostName = name } }
[ "func", "OptionHostname", "(", "name", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "hostName", "=", "name", "\n", "}", "\n", "}" ]
// OptionHostname function returns an option setter for hostname option to // be passed to NewSandbox method.
[ "OptionHostname", "function", "returns", "an", "option", "setter", "for", "hostname", "option", "to", "be", "passed", "to", "NewSandbox", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1038-L1042
train
docker/libnetwork
sandbox.go
OptionDomainname
func OptionDomainname(name string) SandboxOption { return func(sb *sandbox) { sb.config.domainName = name } }
go
func OptionDomainname(name string) SandboxOption { return func(sb *sandbox) { sb.config.domainName = name } }
[ "func", "OptionDomainname", "(", "name", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "domainName", "=", "name", "\n", "}", "\n", "}" ]
// OptionDomainname function returns an option setter for domainname option to // be passed to NewSandbox method.
[ "OptionDomainname", "function", "returns", "an", "option", "setter", "for", "domainname", "option", "to", "be", "passed", "to", "NewSandbox", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1046-L1050
train
docker/libnetwork
sandbox.go
OptionHostsPath
func OptionHostsPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.hostsPath = path } }
go
func OptionHostsPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.hostsPath = path } }
[ "func", "OptionHostsPath", "(", "path", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "hostsPath", "=", "path", "\n", "}", "\n", "}" ]
// OptionHostsPath function returns an option setter for hostspath option to // be passed to NewSandbox method.
[ "OptionHostsPath", "function", "returns", "an", "option", "setter", "for", "hostspath", "option", "to", "be", "passed", "to", "NewSandbox", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1054-L1058
train
docker/libnetwork
sandbox.go
OptionOriginHostsPath
func OptionOriginHostsPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.originHostsPath = path } }
go
func OptionOriginHostsPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.originHostsPath = path } }
[ "func", "OptionOriginHostsPath", "(", "path", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "originHostsPath", "=", "path", "\n", "}", "\n", "}" ]
// OptionOriginHostsPath function returns an option setter for origin hosts file path // to be passed to NewSandbox method.
[ "OptionOriginHostsPath", "function", "returns", "an", "option", "setter", "for", "origin", "hosts", "file", "path", "to", "be", "passed", "to", "NewSandbox", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1062-L1066
train
docker/libnetwork
sandbox.go
OptionParentUpdate
func OptionParentUpdate(cid string, name, ip string) SandboxOption { return func(sb *sandbox) { sb.config.parentUpdates = append(sb.config.parentUpdates, parentUpdate{cid: cid, name: name, ip: ip}) } }
go
func OptionParentUpdate(cid string, name, ip string) SandboxOption { return func(sb *sandbox) { sb.config.parentUpdates = append(sb.config.parentUpdates, parentUpdate{cid: cid, name: name, ip: ip}) } }
[ "func", "OptionParentUpdate", "(", "cid", "string", ",", "name", ",", "ip", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "parentUpdates", "=", "append", "(", "sb", ".", "config", ".", "parentUpdates", ",", "parentUpdate", "{", "cid", ":", "cid", ",", "name", ":", "name", ",", "ip", ":", "ip", "}", ")", "\n", "}", "\n", "}" ]
// OptionParentUpdate function returns an option setter for parent container // which needs to update the IP address for the linked container.
[ "OptionParentUpdate", "function", "returns", "an", "option", "setter", "for", "parent", "container", "which", "needs", "to", "update", "the", "IP", "address", "for", "the", "linked", "container", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1078-L1082
train
docker/libnetwork
sandbox.go
OptionResolvConfPath
func OptionResolvConfPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.resolvConfPath = path } }
go
func OptionResolvConfPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.resolvConfPath = path } }
[ "func", "OptionResolvConfPath", "(", "path", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "resolvConfPath", "=", "path", "\n", "}", "\n", "}" ]
// OptionResolvConfPath function returns an option setter for resolvconfpath option to // be passed to net container methods.
[ "OptionResolvConfPath", "function", "returns", "an", "option", "setter", "for", "resolvconfpath", "option", "to", "be", "passed", "to", "net", "container", "methods", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1086-L1090
train
docker/libnetwork
sandbox.go
OptionOriginResolvConfPath
func OptionOriginResolvConfPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.originResolvConfPath = path } }
go
func OptionOriginResolvConfPath(path string) SandboxOption { return func(sb *sandbox) { sb.config.originResolvConfPath = path } }
[ "func", "OptionOriginResolvConfPath", "(", "path", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "originResolvConfPath", "=", "path", "\n", "}", "\n", "}" ]
// OptionOriginResolvConfPath function returns an option setter to set the path to the // origin resolv.conf file to be passed to net container methods.
[ "OptionOriginResolvConfPath", "function", "returns", "an", "option", "setter", "to", "set", "the", "path", "to", "the", "origin", "resolv", ".", "conf", "file", "to", "be", "passed", "to", "net", "container", "methods", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1094-L1098
train
docker/libnetwork
sandbox.go
OptionDNS
func OptionDNS(dns string) SandboxOption { return func(sb *sandbox) { sb.config.dnsList = append(sb.config.dnsList, dns) } }
go
func OptionDNS(dns string) SandboxOption { return func(sb *sandbox) { sb.config.dnsList = append(sb.config.dnsList, dns) } }
[ "func", "OptionDNS", "(", "dns", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "dnsList", "=", "append", "(", "sb", ".", "config", ".", "dnsList", ",", "dns", ")", "\n", "}", "\n", "}" ]
// OptionDNS function returns an option setter for dns entry option to // be passed to container Create method.
[ "OptionDNS", "function", "returns", "an", "option", "setter", "for", "dns", "entry", "option", "to", "be", "passed", "to", "container", "Create", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1102-L1106
train
docker/libnetwork
sandbox.go
OptionDNSSearch
func OptionDNSSearch(search string) SandboxOption { return func(sb *sandbox) { sb.config.dnsSearchList = append(sb.config.dnsSearchList, search) } }
go
func OptionDNSSearch(search string) SandboxOption { return func(sb *sandbox) { sb.config.dnsSearchList = append(sb.config.dnsSearchList, search) } }
[ "func", "OptionDNSSearch", "(", "search", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "dnsSearchList", "=", "append", "(", "sb", ".", "config", ".", "dnsSearchList", ",", "search", ")", "\n", "}", "\n", "}" ]
// OptionDNSSearch function returns an option setter for dns search entry option to // be passed to container Create method.
[ "OptionDNSSearch", "function", "returns", "an", "option", "setter", "for", "dns", "search", "entry", "option", "to", "be", "passed", "to", "container", "Create", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1110-L1114
train
docker/libnetwork
sandbox.go
OptionDNSOptions
func OptionDNSOptions(options string) SandboxOption { return func(sb *sandbox) { sb.config.dnsOptionsList = append(sb.config.dnsOptionsList, options) } }
go
func OptionDNSOptions(options string) SandboxOption { return func(sb *sandbox) { sb.config.dnsOptionsList = append(sb.config.dnsOptionsList, options) } }
[ "func", "OptionDNSOptions", "(", "options", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "config", ".", "dnsOptionsList", "=", "append", "(", "sb", ".", "config", ".", "dnsOptionsList", ",", "options", ")", "\n", "}", "\n", "}" ]
// OptionDNSOptions function returns an option setter for dns options entry option to // be passed to container Create method.
[ "OptionDNSOptions", "function", "returns", "an", "option", "setter", "for", "dns", "options", "entry", "option", "to", "be", "passed", "to", "container", "Create", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1118-L1122
train
docker/libnetwork
sandbox.go
OptionGeneric
func OptionGeneric(generic map[string]interface{}) SandboxOption { return func(sb *sandbox) { if sb.config.generic == nil { sb.config.generic = make(map[string]interface{}, len(generic)) } for k, v := range generic { sb.config.generic[k] = v } } }
go
func OptionGeneric(generic map[string]interface{}) SandboxOption { return func(sb *sandbox) { if sb.config.generic == nil { sb.config.generic = make(map[string]interface{}, len(generic)) } for k, v := range generic { sb.config.generic[k] = v } } }
[ "func", "OptionGeneric", "(", "generic", "map", "[", "string", "]", "interface", "{", "}", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "if", "sb", ".", "config", ".", "generic", "==", "nil", "{", "sb", ".", "config", ".", "generic", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "len", "(", "generic", ")", ")", "\n", "}", "\n", "for", "k", ",", "v", ":=", "range", "generic", "{", "sb", ".", "config", ".", "generic", "[", "k", "]", "=", "v", "\n", "}", "\n", "}", "\n", "}" ]
// OptionGeneric function returns an option setter for Generic configuration // that is not managed by libNetwork but can be used by the Drivers during the call to // net container creation method. Container Labels are a good example.
[ "OptionGeneric", "function", "returns", "an", "option", "setter", "for", "Generic", "configuration", "that", "is", "not", "managed", "by", "libNetwork", "but", "can", "be", "used", "by", "the", "Drivers", "during", "the", "call", "to", "net", "container", "creation", "method", ".", "Container", "Labels", "are", "a", "good", "example", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1143-L1152
train
docker/libnetwork
sandbox.go
OptionExposedPorts
func OptionExposedPorts(exposedPorts []types.TransportPort) SandboxOption { return func(sb *sandbox) { if sb.config.generic == nil { sb.config.generic = make(map[string]interface{}) } // Defensive copy eps := make([]types.TransportPort, len(exposedPorts)) copy(eps, exposedPorts) // Store endpoint label and in generic because driver needs it sb.config.exposedPorts = eps sb.config.generic[netlabel.ExposedPorts] = eps } }
go
func OptionExposedPorts(exposedPorts []types.TransportPort) SandboxOption { return func(sb *sandbox) { if sb.config.generic == nil { sb.config.generic = make(map[string]interface{}) } // Defensive copy eps := make([]types.TransportPort, len(exposedPorts)) copy(eps, exposedPorts) // Store endpoint label and in generic because driver needs it sb.config.exposedPorts = eps sb.config.generic[netlabel.ExposedPorts] = eps } }
[ "func", "OptionExposedPorts", "(", "exposedPorts", "[", "]", "types", ".", "TransportPort", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "if", "sb", ".", "config", ".", "generic", "==", "nil", "{", "sb", ".", "config", ".", "generic", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "}", "\n", "eps", ":=", "make", "(", "[", "]", "types", ".", "TransportPort", ",", "len", "(", "exposedPorts", ")", ")", "\n", "copy", "(", "eps", ",", "exposedPorts", ")", "\n", "sb", ".", "config", ".", "exposedPorts", "=", "eps", "\n", "sb", ".", "config", ".", "generic", "[", "netlabel", ".", "ExposedPorts", "]", "=", "eps", "\n", "}", "\n", "}" ]
// OptionExposedPorts function returns an option setter for the container exposed // ports option to be passed to container Create method.
[ "OptionExposedPorts", "function", "returns", "an", "option", "setter", "for", "the", "container", "exposed", "ports", "option", "to", "be", "passed", "to", "container", "Create", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1156-L1168
train
docker/libnetwork
sandbox.go
OptionPortMapping
func OptionPortMapping(portBindings []types.PortBinding) SandboxOption { return func(sb *sandbox) { if sb.config.generic == nil { sb.config.generic = make(map[string]interface{}) } // Store a copy of the bindings as generic data to pass to the driver pbs := make([]types.PortBinding, len(portBindings)) copy(pbs, portBindings) sb.config.generic[netlabel.PortMap] = pbs } }
go
func OptionPortMapping(portBindings []types.PortBinding) SandboxOption { return func(sb *sandbox) { if sb.config.generic == nil { sb.config.generic = make(map[string]interface{}) } // Store a copy of the bindings as generic data to pass to the driver pbs := make([]types.PortBinding, len(portBindings)) copy(pbs, portBindings) sb.config.generic[netlabel.PortMap] = pbs } }
[ "func", "OptionPortMapping", "(", "portBindings", "[", "]", "types", ".", "PortBinding", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "if", "sb", ".", "config", ".", "generic", "==", "nil", "{", "sb", ".", "config", ".", "generic", "=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "}", "\n", "pbs", ":=", "make", "(", "[", "]", "types", ".", "PortBinding", ",", "len", "(", "portBindings", ")", ")", "\n", "copy", "(", "pbs", ",", "portBindings", ")", "\n", "sb", ".", "config", ".", "generic", "[", "netlabel", ".", "PortMap", "]", "=", "pbs", "\n", "}", "\n", "}" ]
// OptionPortMapping function returns an option setter for the mapping // ports option to be passed to container Create method.
[ "OptionPortMapping", "function", "returns", "an", "option", "setter", "for", "the", "mapping", "ports", "option", "to", "be", "passed", "to", "container", "Create", "method", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1172-L1182
train
docker/libnetwork
sandbox.go
OptionIngress
func OptionIngress() SandboxOption { return func(sb *sandbox) { sb.ingress = true sb.oslTypes = append(sb.oslTypes, osl.SandboxTypeIngress) } }
go
func OptionIngress() SandboxOption { return func(sb *sandbox) { sb.ingress = true sb.oslTypes = append(sb.oslTypes, osl.SandboxTypeIngress) } }
[ "func", "OptionIngress", "(", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "ingress", "=", "true", "\n", "sb", ".", "oslTypes", "=", "append", "(", "sb", ".", "oslTypes", ",", "osl", ".", "SandboxTypeIngress", ")", "\n", "}", "\n", "}" ]
// OptionIngress function returns an option setter for marking a // sandbox as the controller's ingress sandbox.
[ "OptionIngress", "function", "returns", "an", "option", "setter", "for", "marking", "a", "sandbox", "as", "the", "controller", "s", "ingress", "sandbox", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1186-L1191
train
docker/libnetwork
sandbox.go
OptionLoadBalancer
func OptionLoadBalancer(nid string) SandboxOption { return func(sb *sandbox) { sb.loadBalancerNID = nid sb.oslTypes = append(sb.oslTypes, osl.SandboxTypeLoadBalancer) } }
go
func OptionLoadBalancer(nid string) SandboxOption { return func(sb *sandbox) { sb.loadBalancerNID = nid sb.oslTypes = append(sb.oslTypes, osl.SandboxTypeLoadBalancer) } }
[ "func", "OptionLoadBalancer", "(", "nid", "string", ")", "SandboxOption", "{", "return", "func", "(", "sb", "*", "sandbox", ")", "{", "sb", ".", "loadBalancerNID", "=", "nid", "\n", "sb", ".", "oslTypes", "=", "append", "(", "sb", ".", "oslTypes", ",", "osl", ".", "SandboxTypeLoadBalancer", ")", "\n", "}", "\n", "}" ]
// OptionLoadBalancer function returns an option setter for marking a // sandbox as a load balancer sandbox.
[ "OptionLoadBalancer", "function", "returns", "an", "option", "setter", "for", "marking", "a", "sandbox", "as", "a", "load", "balancer", "sandbox", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/sandbox.go#L1195-L1200
train
docker/libnetwork
ns/init_linux.go
Init
func Init() { var err error initNs, err = netns.Get() if err != nil { logrus.Errorf("could not get initial namespace: %v", err) } initNl, err = netlink.NewHandle(getSupportedNlFamilies()...) if err != nil { logrus.Errorf("could not create netlink handle on initial namespace: %v", err) } err = initNl.SetSocketTimeout(NetlinkSocketsTimeout) if err != nil { logrus.Warnf("Failed to set the timeout on the default netlink handle sockets: %v", err) } }
go
func Init() { var err error initNs, err = netns.Get() if err != nil { logrus.Errorf("could not get initial namespace: %v", err) } initNl, err = netlink.NewHandle(getSupportedNlFamilies()...) if err != nil { logrus.Errorf("could not create netlink handle on initial namespace: %v", err) } err = initNl.SetSocketTimeout(NetlinkSocketsTimeout) if err != nil { logrus.Warnf("Failed to set the timeout on the default netlink handle sockets: %v", err) } }
[ "func", "Init", "(", ")", "{", "var", "err", "error", "\n", "initNs", ",", "err", "=", "netns", ".", "Get", "(", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "Errorf", "(", "\"could not get initial namespace: %v\"", ",", "err", ")", "\n", "}", "\n", "initNl", ",", "err", "=", "netlink", ".", "NewHandle", "(", "getSupportedNlFamilies", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "Errorf", "(", "\"could not create netlink handle on initial namespace: %v\"", ",", "err", ")", "\n", "}", "\n", "err", "=", "initNl", ".", "SetSocketTimeout", "(", "NetlinkSocketsTimeout", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "Warnf", "(", "\"Failed to set the timeout on the default netlink handle sockets: %v\"", ",", "err", ")", "\n", "}", "\n", "}" ]
// Init initializes a new network namespace
[ "Init", "initializes", "a", "new", "network", "namespace" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ns/init_linux.go#L26-L40
train
docker/libnetwork
ns/init_linux.go
SetNamespace
func SetNamespace() error { initOnce.Do(Init) if err := netns.Set(initNs); err != nil { linkInfo, linkErr := getLink() if linkErr != nil { linkInfo = linkErr.Error() } return fmt.Errorf("failed to set to initial namespace, %v, initns fd %d: %v", linkInfo, initNs, err) } return nil }
go
func SetNamespace() error { initOnce.Do(Init) if err := netns.Set(initNs); err != nil { linkInfo, linkErr := getLink() if linkErr != nil { linkInfo = linkErr.Error() } return fmt.Errorf("failed to set to initial namespace, %v, initns fd %d: %v", linkInfo, initNs, err) } return nil }
[ "func", "SetNamespace", "(", ")", "error", "{", "initOnce", ".", "Do", "(", "Init", ")", "\n", "if", "err", ":=", "netns", ".", "Set", "(", "initNs", ")", ";", "err", "!=", "nil", "{", "linkInfo", ",", "linkErr", ":=", "getLink", "(", ")", "\n", "if", "linkErr", "!=", "nil", "{", "linkInfo", "=", "linkErr", ".", "Error", "(", ")", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"failed to set to initial namespace, %v, initns fd %d: %v\"", ",", "linkInfo", ",", "initNs", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// SetNamespace sets the initial namespace handler
[ "SetNamespace", "sets", "the", "initial", "namespace", "handler" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ns/init_linux.go#L43-L53
train
docker/libnetwork
osl/route_linux.go
programRoute
func (n *networkNamespace) programRoute(path string, dest *net.IPNet, nh net.IP) error { gwRoutes, err := n.nlHandle.RouteGet(nh) if err != nil { return fmt.Errorf("route for the next hop %s could not be found: %v", nh, err) } return n.nlHandle.RouteAdd(&netlink.Route{ Scope: netlink.SCOPE_UNIVERSE, LinkIndex: gwRoutes[0].LinkIndex, Gw: nh, Dst: dest, }) }
go
func (n *networkNamespace) programRoute(path string, dest *net.IPNet, nh net.IP) error { gwRoutes, err := n.nlHandle.RouteGet(nh) if err != nil { return fmt.Errorf("route for the next hop %s could not be found: %v", nh, err) } return n.nlHandle.RouteAdd(&netlink.Route{ Scope: netlink.SCOPE_UNIVERSE, LinkIndex: gwRoutes[0].LinkIndex, Gw: nh, Dst: dest, }) }
[ "func", "(", "n", "*", "networkNamespace", ")", "programRoute", "(", "path", "string", ",", "dest", "*", "net", ".", "IPNet", ",", "nh", "net", ".", "IP", ")", "error", "{", "gwRoutes", ",", "err", ":=", "n", ".", "nlHandle", ".", "RouteGet", "(", "nh", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"route for the next hop %s could not be found: %v\"", ",", "nh", ",", "err", ")", "\n", "}", "\n", "return", "n", ".", "nlHandle", ".", "RouteAdd", "(", "&", "netlink", ".", "Route", "{", "Scope", ":", "netlink", ".", "SCOPE_UNIVERSE", ",", "LinkIndex", ":", "gwRoutes", "[", "0", "]", ".", "LinkIndex", ",", "Gw", ":", "nh", ",", "Dst", ":", "dest", ",", "}", ")", "\n", "}" ]
// Program a route in to the namespace routing table.
[ "Program", "a", "route", "in", "to", "the", "namespace", "routing", "table", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/route_linux.go#L114-L126
train
docker/libnetwork
cmd/proxy/sctp_proxy.go
NewSCTPProxy
func NewSCTPProxy(frontendAddr, backendAddr *sctp.SCTPAddr) (*SCTPProxy, error) { listener, err := sctp.ListenSCTP("sctp", frontendAddr) if err != nil { return nil, err } // If the port in frontendAddr was 0 then ListenSCTP will have a picked // a port to listen on, hence the call to Addr to get that actual port: return &SCTPProxy{ listener: listener, frontendAddr: listener.Addr().(*sctp.SCTPAddr), backendAddr: backendAddr, }, nil }
go
func NewSCTPProxy(frontendAddr, backendAddr *sctp.SCTPAddr) (*SCTPProxy, error) { listener, err := sctp.ListenSCTP("sctp", frontendAddr) if err != nil { return nil, err } // If the port in frontendAddr was 0 then ListenSCTP will have a picked // a port to listen on, hence the call to Addr to get that actual port: return &SCTPProxy{ listener: listener, frontendAddr: listener.Addr().(*sctp.SCTPAddr), backendAddr: backendAddr, }, nil }
[ "func", "NewSCTPProxy", "(", "frontendAddr", ",", "backendAddr", "*", "sctp", ".", "SCTPAddr", ")", "(", "*", "SCTPProxy", ",", "error", ")", "{", "listener", ",", "err", ":=", "sctp", ".", "ListenSCTP", "(", "\"sctp\"", ",", "frontendAddr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "SCTPProxy", "{", "listener", ":", "listener", ",", "frontendAddr", ":", "listener", ".", "Addr", "(", ")", ".", "(", "*", "sctp", ".", "SCTPAddr", ")", ",", "backendAddr", ":", "backendAddr", ",", "}", ",", "nil", "\n", "}" ]
// NewSCTPProxy creates a new SCTPProxy.
[ "NewSCTPProxy", "creates", "a", "new", "SCTPProxy", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/cmd/proxy/sctp_proxy.go#L21-L33
train
docker/libnetwork
cmd/proxy/sctp_proxy.go
Run
func (proxy *SCTPProxy) Run() { quit := make(chan bool) defer close(quit) for { client, err := proxy.listener.Accept() if err != nil { log.Printf("Stopping proxy on sctp/%v for sctp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err) return } go proxy.clientLoop(client.(*sctp.SCTPConn), quit) } }
go
func (proxy *SCTPProxy) Run() { quit := make(chan bool) defer close(quit) for { client, err := proxy.listener.Accept() if err != nil { log.Printf("Stopping proxy on sctp/%v for sctp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err) return } go proxy.clientLoop(client.(*sctp.SCTPConn), quit) } }
[ "func", "(", "proxy", "*", "SCTPProxy", ")", "Run", "(", ")", "{", "quit", ":=", "make", "(", "chan", "bool", ")", "\n", "defer", "close", "(", "quit", ")", "\n", "for", "{", "client", ",", "err", ":=", "proxy", ".", "listener", ".", "Accept", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"Stopping proxy on sctp/%v for sctp/%v (%s)\"", ",", "proxy", ".", "frontendAddr", ",", "proxy", ".", "backendAddr", ",", "err", ")", "\n", "return", "\n", "}", "\n", "go", "proxy", ".", "clientLoop", "(", "client", ".", "(", "*", "sctp", ".", "SCTPConn", ")", ",", "quit", ")", "\n", "}", "\n", "}" ]
// Run starts forwarding the traffic using SCTP.
[ "Run", "starts", "forwarding", "the", "traffic", "using", "SCTP", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/cmd/proxy/sctp_proxy.go#L73-L84
train
docker/libnetwork
drivers/windows/port_mapping.go
AllocatePorts
func AllocatePorts(portMapper *portmapper.PortMapper, bindings []types.PortBinding, containerIP net.IP) ([]types.PortBinding, error) { bs := make([]types.PortBinding, 0, len(bindings)) for _, c := range bindings { b := c.GetCopy() if err := allocatePort(portMapper, &b, containerIP); err != nil { // On allocation failure, release previously allocated ports. On cleanup error, just log a warning message if cuErr := ReleasePorts(portMapper, bs); cuErr != nil { logrus.Warnf("Upon allocation failure for %v, failed to clear previously allocated port bindings: %v", b, cuErr) } return nil, err } bs = append(bs, b) } return bs, nil }
go
func AllocatePorts(portMapper *portmapper.PortMapper, bindings []types.PortBinding, containerIP net.IP) ([]types.PortBinding, error) { bs := make([]types.PortBinding, 0, len(bindings)) for _, c := range bindings { b := c.GetCopy() if err := allocatePort(portMapper, &b, containerIP); err != nil { // On allocation failure, release previously allocated ports. On cleanup error, just log a warning message if cuErr := ReleasePorts(portMapper, bs); cuErr != nil { logrus.Warnf("Upon allocation failure for %v, failed to clear previously allocated port bindings: %v", b, cuErr) } return nil, err } bs = append(bs, b) } return bs, nil }
[ "func", "AllocatePorts", "(", "portMapper", "*", "portmapper", ".", "PortMapper", ",", "bindings", "[", "]", "types", ".", "PortBinding", ",", "containerIP", "net", ".", "IP", ")", "(", "[", "]", "types", ".", "PortBinding", ",", "error", ")", "{", "bs", ":=", "make", "(", "[", "]", "types", ".", "PortBinding", ",", "0", ",", "len", "(", "bindings", ")", ")", "\n", "for", "_", ",", "c", ":=", "range", "bindings", "{", "b", ":=", "c", ".", "GetCopy", "(", ")", "\n", "if", "err", ":=", "allocatePort", "(", "portMapper", ",", "&", "b", ",", "containerIP", ")", ";", "err", "!=", "nil", "{", "if", "cuErr", ":=", "ReleasePorts", "(", "portMapper", ",", "bs", ")", ";", "cuErr", "!=", "nil", "{", "logrus", ".", "Warnf", "(", "\"Upon allocation failure for %v, failed to clear previously allocated port bindings: %v\"", ",", "b", ",", "cuErr", ")", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "bs", "=", "append", "(", "bs", ",", "b", ")", "\n", "}", "\n", "return", "bs", ",", "nil", "\n", "}" ]
// AllocatePorts allocates ports specified in bindings from the portMapper
[ "AllocatePorts", "allocates", "ports", "specified", "in", "bindings", "from", "the", "portMapper" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/windows/port_mapping.go#L29-L43
train
docker/libnetwork
drivers/windows/port_mapping.go
ReleasePorts
func ReleasePorts(portMapper *portmapper.PortMapper, bindings []types.PortBinding) error { var errorBuf bytes.Buffer // Attempt to release all port bindings, do not stop on failure for _, m := range bindings { if err := releasePort(portMapper, m); err != nil { errorBuf.WriteString(fmt.Sprintf("\ncould not release %v because of %v", m, err)) } } if errorBuf.Len() != 0 { return errors.New(errorBuf.String()) } return nil }
go
func ReleasePorts(portMapper *portmapper.PortMapper, bindings []types.PortBinding) error { var errorBuf bytes.Buffer // Attempt to release all port bindings, do not stop on failure for _, m := range bindings { if err := releasePort(portMapper, m); err != nil { errorBuf.WriteString(fmt.Sprintf("\ncould not release %v because of %v", m, err)) } } if errorBuf.Len() != 0 { return errors.New(errorBuf.String()) } return nil }
[ "func", "ReleasePorts", "(", "portMapper", "*", "portmapper", ".", "PortMapper", ",", "bindings", "[", "]", "types", ".", "PortBinding", ")", "error", "{", "var", "errorBuf", "bytes", ".", "Buffer", "\n", "for", "_", ",", "m", ":=", "range", "bindings", "{", "if", "err", ":=", "releasePort", "(", "portMapper", ",", "m", ")", ";", "err", "!=", "nil", "{", "errorBuf", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"\\ncould not release %v because of %v\"", ",", "\\n", ",", "m", ")", ")", "\n", "}", "\n", "}", "\n", "err", "\n", "if", "errorBuf", ".", "Len", "(", ")", "!=", "0", "{", "return", "errors", ".", "New", "(", "errorBuf", ".", "String", "(", ")", ")", "\n", "}", "\n", "}" ]
// ReleasePorts releases ports specified in bindings from the portMapper
[ "ReleasePorts", "releases", "ports", "specified", "in", "bindings", "from", "the", "portMapper" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/drivers/windows/port_mapping.go#L102-L116
train
docker/libnetwork
api/api.go
NewHTTPHandler
func NewHTTPHandler(c libnetwork.NetworkController) func(w http.ResponseWriter, req *http.Request) { h := &httpHandler{c: c} h.initRouter() return h.handleRequest }
go
func NewHTTPHandler(c libnetwork.NetworkController) func(w http.ResponseWriter, req *http.Request) { h := &httpHandler{c: c} h.initRouter() return h.handleRequest }
[ "func", "NewHTTPHandler", "(", "c", "libnetwork", ".", "NetworkController", ")", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "h", ":=", "&", "httpHandler", "{", "c", ":", "c", "}", "\n", "h", ".", "initRouter", "(", ")", "\n", "return", "h", ".", "handleRequest", "\n", "}" ]
// NewHTTPHandler creates and initialize the HTTP handler to serve the requests for libnetwork
[ "NewHTTPHandler", "creates", "and", "initialize", "the", "HTTP", "handler", "to", "serve", "the", "requests", "for", "libnetwork" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/api/api.go#L60-L64
train
docker/libnetwork
networkdb/nodemgmt.go
findNode
func (nDB *NetworkDB) findNode(nodeName string) (*node, nodeState, map[string]*node) { for i, nodes := range []map[string]*node{ nDB.nodes, nDB.leftNodes, nDB.failedNodes, } { if n, ok := nodes[nodeName]; ok { return n, nodeState(i), nodes } } return nil, nodeNotFound, nil }
go
func (nDB *NetworkDB) findNode(nodeName string) (*node, nodeState, map[string]*node) { for i, nodes := range []map[string]*node{ nDB.nodes, nDB.leftNodes, nDB.failedNodes, } { if n, ok := nodes[nodeName]; ok { return n, nodeState(i), nodes } } return nil, nodeNotFound, nil }
[ "func", "(", "nDB", "*", "NetworkDB", ")", "findNode", "(", "nodeName", "string", ")", "(", "*", "node", ",", "nodeState", ",", "map", "[", "string", "]", "*", "node", ")", "{", "for", "i", ",", "nodes", ":=", "range", "[", "]", "map", "[", "string", "]", "*", "node", "{", "nDB", ".", "nodes", ",", "nDB", ".", "leftNodes", ",", "nDB", ".", "failedNodes", ",", "}", "{", "if", "n", ",", "ok", ":=", "nodes", "[", "nodeName", "]", ";", "ok", "{", "return", "n", ",", "nodeState", "(", "i", ")", ",", "nodes", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "nodeNotFound", ",", "nil", "\n", "}" ]
// findNode search the node into the 3 node lists and returns the node pointer and the list // where it got found
[ "findNode", "search", "the", "node", "into", "the", "3", "node", "lists", "and", "returns", "the", "node", "pointer", "and", "the", "list", "where", "it", "got", "found" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/nodemgmt.go#L28-L39
train
docker/libnetwork
networkdb/nodemgmt.go
changeNodeState
func (nDB *NetworkDB) changeNodeState(nodeName string, newState nodeState) (bool, error) { n, currState, m := nDB.findNode(nodeName) if n == nil { return false, fmt.Errorf("node %s not found", nodeName) } switch newState { case nodeActiveState: if currState == nodeActiveState { return false, nil } delete(m, nodeName) // reset the node reap time n.reapTime = 0 nDB.nodes[nodeName] = n case nodeLeftState: if currState == nodeLeftState { return false, nil } delete(m, nodeName) nDB.leftNodes[nodeName] = n case nodeFailedState: if currState == nodeFailedState { return false, nil } delete(m, nodeName) nDB.failedNodes[nodeName] = n } logrus.Infof("Node %s change state %s --> %s", nodeName, nodeStateName[currState], nodeStateName[newState]) if newState == nodeLeftState || newState == nodeFailedState { // set the node reap time, if not already set // It is possible that a node passes from failed to left and the reaptime was already set so keep that value if n.reapTime == 0 { n.reapTime = nodeReapInterval } // The node leave or fails, delete all the entries created by it. // If the node was temporary down, deleting the entries will guarantee that the CREATE events will be accepted // If the node instead left because was going down, then it makes sense to just delete all its state nDB.deleteNodeFromNetworks(n.Name) nDB.deleteNodeTableEntries(n.Name) } return true, nil }
go
func (nDB *NetworkDB) changeNodeState(nodeName string, newState nodeState) (bool, error) { n, currState, m := nDB.findNode(nodeName) if n == nil { return false, fmt.Errorf("node %s not found", nodeName) } switch newState { case nodeActiveState: if currState == nodeActiveState { return false, nil } delete(m, nodeName) // reset the node reap time n.reapTime = 0 nDB.nodes[nodeName] = n case nodeLeftState: if currState == nodeLeftState { return false, nil } delete(m, nodeName) nDB.leftNodes[nodeName] = n case nodeFailedState: if currState == nodeFailedState { return false, nil } delete(m, nodeName) nDB.failedNodes[nodeName] = n } logrus.Infof("Node %s change state %s --> %s", nodeName, nodeStateName[currState], nodeStateName[newState]) if newState == nodeLeftState || newState == nodeFailedState { // set the node reap time, if not already set // It is possible that a node passes from failed to left and the reaptime was already set so keep that value if n.reapTime == 0 { n.reapTime = nodeReapInterval } // The node leave or fails, delete all the entries created by it. // If the node was temporary down, deleting the entries will guarantee that the CREATE events will be accepted // If the node instead left because was going down, then it makes sense to just delete all its state nDB.deleteNodeFromNetworks(n.Name) nDB.deleteNodeTableEntries(n.Name) } return true, nil }
[ "func", "(", "nDB", "*", "NetworkDB", ")", "changeNodeState", "(", "nodeName", "string", ",", "newState", "nodeState", ")", "(", "bool", ",", "error", ")", "{", "n", ",", "currState", ",", "m", ":=", "nDB", ".", "findNode", "(", "nodeName", ")", "\n", "if", "n", "==", "nil", "{", "return", "false", ",", "fmt", ".", "Errorf", "(", "\"node %s not found\"", ",", "nodeName", ")", "\n", "}", "\n", "switch", "newState", "{", "case", "nodeActiveState", ":", "if", "currState", "==", "nodeActiveState", "{", "return", "false", ",", "nil", "\n", "}", "\n", "delete", "(", "m", ",", "nodeName", ")", "\n", "n", ".", "reapTime", "=", "0", "\n", "nDB", ".", "nodes", "[", "nodeName", "]", "=", "n", "\n", "case", "nodeLeftState", ":", "if", "currState", "==", "nodeLeftState", "{", "return", "false", ",", "nil", "\n", "}", "\n", "delete", "(", "m", ",", "nodeName", ")", "\n", "nDB", ".", "leftNodes", "[", "nodeName", "]", "=", "n", "\n", "case", "nodeFailedState", ":", "if", "currState", "==", "nodeFailedState", "{", "return", "false", ",", "nil", "\n", "}", "\n", "delete", "(", "m", ",", "nodeName", ")", "\n", "nDB", ".", "failedNodes", "[", "nodeName", "]", "=", "n", "\n", "}", "\n", "logrus", ".", "Infof", "(", "\"Node %s change state %s ", ",", "nodeName", ",", "nodeStateName", "[", "currState", "]", ",", "nodeStateName", "[", "newState", "]", ")", "\n", "if", "newState", "==", "nodeLeftState", "||", "newState", "==", "nodeFailedState", "{", "if", "n", ".", "reapTime", "==", "0", "{", "n", ".", "reapTime", "=", "nodeReapInterval", "\n", "}", "\n", "nDB", ".", "deleteNodeFromNetworks", "(", "n", ".", "Name", ")", "\n", "nDB", ".", "deleteNodeTableEntries", "(", "n", ".", "Name", ")", "\n", "}", "\n", "return", "true", ",", "nil", "\n", "}" ]
// changeNodeState changes the state of the node specified, returns true if the node was moved, // false if there was no need to change the node state. Error will be returned if the node does not // exists
[ "changeNodeState", "changes", "the", "state", "of", "the", "node", "specified", "returns", "true", "if", "the", "node", "was", "moved", "false", "if", "there", "was", "no", "need", "to", "change", "the", "node", "state", ".", "Error", "will", "be", "returned", "if", "the", "node", "does", "not", "exists" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/nodemgmt.go#L44-L92
train
docker/libnetwork
networkdb/message.go
decodeCompoundMessage
func decodeCompoundMessage(buf []byte) ([][]byte, error) { var cMsg CompoundMessage if err := proto.Unmarshal(buf, &cMsg); err != nil { return nil, err } parts := make([][]byte, 0, len(cMsg.Messages)) for _, m := range cMsg.Messages { parts = append(parts, m.Payload) } return parts, nil }
go
func decodeCompoundMessage(buf []byte) ([][]byte, error) { var cMsg CompoundMessage if err := proto.Unmarshal(buf, &cMsg); err != nil { return nil, err } parts := make([][]byte, 0, len(cMsg.Messages)) for _, m := range cMsg.Messages { parts = append(parts, m.Payload) } return parts, nil }
[ "func", "decodeCompoundMessage", "(", "buf", "[", "]", "byte", ")", "(", "[", "]", "[", "]", "byte", ",", "error", ")", "{", "var", "cMsg", "CompoundMessage", "\n", "if", "err", ":=", "proto", ".", "Unmarshal", "(", "buf", ",", "&", "cMsg", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "parts", ":=", "make", "(", "[", "]", "[", "]", "byte", ",", "0", ",", "len", "(", "cMsg", ".", "Messages", ")", ")", "\n", "for", "_", ",", "m", ":=", "range", "cMsg", ".", "Messages", "{", "parts", "=", "append", "(", "parts", ",", "m", ".", "Payload", ")", "\n", "}", "\n", "return", "parts", ",", "nil", "\n", "}" ]
// decodeCompoundMessage splits a compound message and returns // the slices of individual messages. Returns any potential error.
[ "decodeCompoundMessage", "splits", "a", "compound", "message", "and", "returns", "the", "slices", "of", "individual", "messages", ".", "Returns", "any", "potential", "error", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/networkdb/message.go#L86-L98
train
docker/libnetwork
bitseq/sequence.go
NewHandle
func NewHandle(app string, ds datastore.DataStore, id string, numElements uint64) (*Handle, error) { h := &Handle{ app: app, id: id, store: ds, bits: numElements, unselected: numElements, head: &sequence{ block: 0x0, count: getNumBlocks(numElements), }, } if h.store == nil { return h, nil } // Get the initial status from the ds if present. if err := h.store.GetObject(datastore.Key(h.Key()...), h); err != nil && err != datastore.ErrKeyNotFound { return nil, err } // If the handle is not in store, write it. if !h.Exists() { if err := h.writeToStore(); err != nil { return nil, fmt.Errorf("failed to write bitsequence to store: %v", err) } } return h, nil }
go
func NewHandle(app string, ds datastore.DataStore, id string, numElements uint64) (*Handle, error) { h := &Handle{ app: app, id: id, store: ds, bits: numElements, unselected: numElements, head: &sequence{ block: 0x0, count: getNumBlocks(numElements), }, } if h.store == nil { return h, nil } // Get the initial status from the ds if present. if err := h.store.GetObject(datastore.Key(h.Key()...), h); err != nil && err != datastore.ErrKeyNotFound { return nil, err } // If the handle is not in store, write it. if !h.Exists() { if err := h.writeToStore(); err != nil { return nil, fmt.Errorf("failed to write bitsequence to store: %v", err) } } return h, nil }
[ "func", "NewHandle", "(", "app", "string", ",", "ds", "datastore", ".", "DataStore", ",", "id", "string", ",", "numElements", "uint64", ")", "(", "*", "Handle", ",", "error", ")", "{", "h", ":=", "&", "Handle", "{", "app", ":", "app", ",", "id", ":", "id", ",", "store", ":", "ds", ",", "bits", ":", "numElements", ",", "unselected", ":", "numElements", ",", "head", ":", "&", "sequence", "{", "block", ":", "0x0", ",", "count", ":", "getNumBlocks", "(", "numElements", ")", ",", "}", ",", "}", "\n", "if", "h", ".", "store", "==", "nil", "{", "return", "h", ",", "nil", "\n", "}", "\n", "if", "err", ":=", "h", ".", "store", ".", "GetObject", "(", "datastore", ".", "Key", "(", "h", ".", "Key", "(", ")", "...", ")", ",", "h", ")", ";", "err", "!=", "nil", "&&", "err", "!=", "datastore", ".", "ErrKeyNotFound", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "!", "h", ".", "Exists", "(", ")", "{", "if", "err", ":=", "h", ".", "writeToStore", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"failed to write bitsequence to store: %v\"", ",", "err", ")", "\n", "}", "\n", "}", "\n", "return", "h", ",", "nil", "\n", "}" ]
// NewHandle returns a thread-safe instance of the bitmask handler
[ "NewHandle", "returns", "a", "thread", "-", "safe", "instance", "of", "the", "bitmask", "handler" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L50-L80
train
docker/libnetwork
bitseq/sequence.go
toString
func (s *sequence) toString() string { var nextBlock string if s.next == nil { nextBlock = "end" } else { nextBlock = s.next.toString() } return fmt.Sprintf("(0x%x, %d)->%s", s.block, s.count, nextBlock) }
go
func (s *sequence) toString() string { var nextBlock string if s.next == nil { nextBlock = "end" } else { nextBlock = s.next.toString() } return fmt.Sprintf("(0x%x, %d)->%s", s.block, s.count, nextBlock) }
[ "func", "(", "s", "*", "sequence", ")", "toString", "(", ")", "string", "{", "var", "nextBlock", "string", "\n", "if", "s", ".", "next", "==", "nil", "{", "nextBlock", "=", "\"end\"", "\n", "}", "else", "{", "nextBlock", "=", "s", ".", "next", ".", "toString", "(", ")", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"(0x%x, %d)->%s\"", ",", "s", ".", "block", ",", "s", ".", "count", ",", "nextBlock", ")", "\n", "}" ]
// String returns a string representation of the block sequence starting from this block
[ "String", "returns", "a", "string", "representation", "of", "the", "block", "sequence", "starting", "from", "this", "block" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L90-L98
train
docker/libnetwork
bitseq/sequence.go
getAvailableBit
func (s *sequence) getAvailableBit(from uint64) (uint64, uint64, error) { if s.block == blockMAX || s.count == 0 { return invalidPos, invalidPos, ErrNoBitAvailable } bits := from bitSel := blockFirstBit >> from for bitSel > 0 && s.block&bitSel != 0 { bitSel >>= 1 bits++ } // Check if the loop exited because it could not // find any available bit int block starting from // "from". Return invalid pos in that case. if bitSel == 0 { return invalidPos, invalidPos, ErrNoBitAvailable } return bits / 8, bits % 8, nil }
go
func (s *sequence) getAvailableBit(from uint64) (uint64, uint64, error) { if s.block == blockMAX || s.count == 0 { return invalidPos, invalidPos, ErrNoBitAvailable } bits := from bitSel := blockFirstBit >> from for bitSel > 0 && s.block&bitSel != 0 { bitSel >>= 1 bits++ } // Check if the loop exited because it could not // find any available bit int block starting from // "from". Return invalid pos in that case. if bitSel == 0 { return invalidPos, invalidPos, ErrNoBitAvailable } return bits / 8, bits % 8, nil }
[ "func", "(", "s", "*", "sequence", ")", "getAvailableBit", "(", "from", "uint64", ")", "(", "uint64", ",", "uint64", ",", "error", ")", "{", "if", "s", ".", "block", "==", "blockMAX", "||", "s", ".", "count", "==", "0", "{", "return", "invalidPos", ",", "invalidPos", ",", "ErrNoBitAvailable", "\n", "}", "\n", "bits", ":=", "from", "\n", "bitSel", ":=", "blockFirstBit", ">>", "from", "\n", "for", "bitSel", ">", "0", "&&", "s", ".", "block", "&", "bitSel", "!=", "0", "{", "bitSel", ">>=", "1", "\n", "bits", "++", "\n", "}", "\n", "if", "bitSel", "==", "0", "{", "return", "invalidPos", ",", "invalidPos", ",", "ErrNoBitAvailable", "\n", "}", "\n", "return", "bits", "/", "8", ",", "bits", "%", "8", ",", "nil", "\n", "}" ]
// GetAvailableBit returns the position of the first unset bit in the bitmask represented by this sequence
[ "GetAvailableBit", "returns", "the", "position", "of", "the", "first", "unset", "bit", "in", "the", "bitmask", "represented", "by", "this", "sequence" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L101-L118
train
docker/libnetwork
bitseq/sequence.go
getCopy
func (s *sequence) getCopy() *sequence { n := &sequence{block: s.block, count: s.count} pn := n ps := s.next for ps != nil { pn.next = &sequence{block: ps.block, count: ps.count} pn = pn.next ps = ps.next } return n }
go
func (s *sequence) getCopy() *sequence { n := &sequence{block: s.block, count: s.count} pn := n ps := s.next for ps != nil { pn.next = &sequence{block: ps.block, count: ps.count} pn = pn.next ps = ps.next } return n }
[ "func", "(", "s", "*", "sequence", ")", "getCopy", "(", ")", "*", "sequence", "{", "n", ":=", "&", "sequence", "{", "block", ":", "s", ".", "block", ",", "count", ":", "s", ".", "count", "}", "\n", "pn", ":=", "n", "\n", "ps", ":=", "s", ".", "next", "\n", "for", "ps", "!=", "nil", "{", "pn", ".", "next", "=", "&", "sequence", "{", "block", ":", "ps", ".", "block", ",", "count", ":", "ps", ".", "count", "}", "\n", "pn", "=", "pn", ".", "next", "\n", "ps", "=", "ps", ".", "next", "\n", "}", "\n", "return", "n", "\n", "}" ]
// GetCopy returns a copy of the linked list rooted at this node
[ "GetCopy", "returns", "a", "copy", "of", "the", "linked", "list", "rooted", "at", "this", "node" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L121-L131
train
docker/libnetwork
bitseq/sequence.go
equal
func (s *sequence) equal(o *sequence) bool { this := s other := o for this != nil { if other == nil { return false } if this.block != other.block || this.count != other.count { return false } this = this.next other = other.next } // Check if other is longer than this if other != nil { return false } return true }
go
func (s *sequence) equal(o *sequence) bool { this := s other := o for this != nil { if other == nil { return false } if this.block != other.block || this.count != other.count { return false } this = this.next other = other.next } // Check if other is longer than this if other != nil { return false } return true }
[ "func", "(", "s", "*", "sequence", ")", "equal", "(", "o", "*", "sequence", ")", "bool", "{", "this", ":=", "s", "\n", "other", ":=", "o", "\n", "for", "this", "!=", "nil", "{", "if", "other", "==", "nil", "{", "return", "false", "\n", "}", "\n", "if", "this", ".", "block", "!=", "other", ".", "block", "||", "this", ".", "count", "!=", "other", ".", "count", "{", "return", "false", "\n", "}", "\n", "this", "=", "this", ".", "next", "\n", "other", "=", "other", ".", "next", "\n", "}", "\n", "if", "other", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Equal checks if this sequence is equal to the passed one
[ "Equal", "checks", "if", "this", "sequence", "is", "equal", "to", "the", "passed", "one" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L134-L152
train
docker/libnetwork
bitseq/sequence.go
toByteArray
func (s *sequence) toByteArray() ([]byte, error) { var bb []byte p := s for p != nil { b := make([]byte, 12) binary.BigEndian.PutUint32(b[0:], p.block) binary.BigEndian.PutUint64(b[4:], p.count) bb = append(bb, b...) p = p.next } return bb, nil }
go
func (s *sequence) toByteArray() ([]byte, error) { var bb []byte p := s for p != nil { b := make([]byte, 12) binary.BigEndian.PutUint32(b[0:], p.block) binary.BigEndian.PutUint64(b[4:], p.count) bb = append(bb, b...) p = p.next } return bb, nil }
[ "func", "(", "s", "*", "sequence", ")", "toByteArray", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "bb", "[", "]", "byte", "\n", "p", ":=", "s", "\n", "for", "p", "!=", "nil", "{", "b", ":=", "make", "(", "[", "]", "byte", ",", "12", ")", "\n", "binary", ".", "BigEndian", ".", "PutUint32", "(", "b", "[", "0", ":", "]", ",", "p", ".", "block", ")", "\n", "binary", ".", "BigEndian", ".", "PutUint64", "(", "b", "[", "4", ":", "]", ",", "p", ".", "count", ")", "\n", "bb", "=", "append", "(", "bb", ",", "b", "...", ")", "\n", "p", "=", "p", ".", "next", "\n", "}", "\n", "return", "bb", ",", "nil", "\n", "}" ]
// ToByteArray converts the sequence into a byte array
[ "ToByteArray", "converts", "the", "sequence", "into", "a", "byte", "array" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L155-L168
train
docker/libnetwork
bitseq/sequence.go
fromByteArray
func (s *sequence) fromByteArray(data []byte) error { l := len(data) if l%12 != 0 { return fmt.Errorf("cannot deserialize byte sequence of length %d (%v)", l, data) } p := s i := 0 for { p.block = binary.BigEndian.Uint32(data[i : i+4]) p.count = binary.BigEndian.Uint64(data[i+4 : i+12]) i += 12 if i == l { break } p.next = &sequence{} p = p.next } return nil }
go
func (s *sequence) fromByteArray(data []byte) error { l := len(data) if l%12 != 0 { return fmt.Errorf("cannot deserialize byte sequence of length %d (%v)", l, data) } p := s i := 0 for { p.block = binary.BigEndian.Uint32(data[i : i+4]) p.count = binary.BigEndian.Uint64(data[i+4 : i+12]) i += 12 if i == l { break } p.next = &sequence{} p = p.next } return nil }
[ "func", "(", "s", "*", "sequence", ")", "fromByteArray", "(", "data", "[", "]", "byte", ")", "error", "{", "l", ":=", "len", "(", "data", ")", "\n", "if", "l", "%", "12", "!=", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"cannot deserialize byte sequence of length %d (%v)\"", ",", "l", ",", "data", ")", "\n", "}", "\n", "p", ":=", "s", "\n", "i", ":=", "0", "\n", "for", "{", "p", ".", "block", "=", "binary", ".", "BigEndian", ".", "Uint32", "(", "data", "[", "i", ":", "i", "+", "4", "]", ")", "\n", "p", ".", "count", "=", "binary", ".", "BigEndian", ".", "Uint64", "(", "data", "[", "i", "+", "4", ":", "i", "+", "12", "]", ")", "\n", "i", "+=", "12", "\n", "if", "i", "==", "l", "{", "break", "\n", "}", "\n", "p", ".", "next", "=", "&", "sequence", "{", "}", "\n", "p", "=", "p", ".", "next", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// fromByteArray construct the sequence from the byte array
[ "fromByteArray", "construct", "the", "sequence", "from", "the", "byte", "array" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L171-L191
train
docker/libnetwork
bitseq/sequence.go
SetAnyInRange
func (h *Handle) SetAnyInRange(start, end uint64, serial bool) (uint64, error) { if end < start || end >= h.bits { return invalidPos, fmt.Errorf("invalid bit range [%d, %d]", start, end) } if h.Unselected() == 0 { return invalidPos, ErrNoBitAvailable } return h.set(0, start, end, true, false, serial) }
go
func (h *Handle) SetAnyInRange(start, end uint64, serial bool) (uint64, error) { if end < start || end >= h.bits { return invalidPos, fmt.Errorf("invalid bit range [%d, %d]", start, end) } if h.Unselected() == 0 { return invalidPos, ErrNoBitAvailable } return h.set(0, start, end, true, false, serial) }
[ "func", "(", "h", "*", "Handle", ")", "SetAnyInRange", "(", "start", ",", "end", "uint64", ",", "serial", "bool", ")", "(", "uint64", ",", "error", ")", "{", "if", "end", "<", "start", "||", "end", ">=", "h", ".", "bits", "{", "return", "invalidPos", ",", "fmt", ".", "Errorf", "(", "\"invalid bit range [%d, %d]\"", ",", "start", ",", "end", ")", "\n", "}", "\n", "if", "h", ".", "Unselected", "(", ")", "==", "0", "{", "return", "invalidPos", ",", "ErrNoBitAvailable", "\n", "}", "\n", "return", "h", ".", "set", "(", "0", ",", "start", ",", "end", ",", "true", ",", "false", ",", "serial", ")", "\n", "}" ]
// SetAnyInRange atomically sets the first unset bit in the specified range in the sequence and returns the corresponding ordinal
[ "SetAnyInRange", "atomically", "sets", "the", "first", "unset", "bit", "in", "the", "specified", "range", "in", "the", "sequence", "and", "returns", "the", "corresponding", "ordinal" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L208-L216
train
docker/libnetwork
bitseq/sequence.go
SetAny
func (h *Handle) SetAny(serial bool) (uint64, error) { if h.Unselected() == 0 { return invalidPos, ErrNoBitAvailable } return h.set(0, 0, h.bits-1, true, false, serial) }
go
func (h *Handle) SetAny(serial bool) (uint64, error) { if h.Unselected() == 0 { return invalidPos, ErrNoBitAvailable } return h.set(0, 0, h.bits-1, true, false, serial) }
[ "func", "(", "h", "*", "Handle", ")", "SetAny", "(", "serial", "bool", ")", "(", "uint64", ",", "error", ")", "{", "if", "h", ".", "Unselected", "(", ")", "==", "0", "{", "return", "invalidPos", ",", "ErrNoBitAvailable", "\n", "}", "\n", "return", "h", ".", "set", "(", "0", ",", "0", ",", "h", ".", "bits", "-", "1", ",", "true", ",", "false", ",", "serial", ")", "\n", "}" ]
// SetAny atomically sets the first unset bit in the sequence and returns the corresponding ordinal
[ "SetAny", "atomically", "sets", "the", "first", "unset", "bit", "in", "the", "sequence", "and", "returns", "the", "corresponding", "ordinal" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L219-L224
train
docker/libnetwork
bitseq/sequence.go
Set
func (h *Handle) Set(ordinal uint64) error { if err := h.validateOrdinal(ordinal); err != nil { return err } _, err := h.set(ordinal, 0, 0, false, false, false) return err }
go
func (h *Handle) Set(ordinal uint64) error { if err := h.validateOrdinal(ordinal); err != nil { return err } _, err := h.set(ordinal, 0, 0, false, false, false) return err }
[ "func", "(", "h", "*", "Handle", ")", "Set", "(", "ordinal", "uint64", ")", "error", "{", "if", "err", ":=", "h", ".", "validateOrdinal", "(", "ordinal", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "_", ",", "err", ":=", "h", ".", "set", "(", "ordinal", ",", "0", ",", "0", ",", "false", ",", "false", ",", "false", ")", "\n", "return", "err", "\n", "}" ]
// Set atomically sets the corresponding bit in the sequence
[ "Set", "atomically", "sets", "the", "corresponding", "bit", "in", "the", "sequence" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L227-L233
train
docker/libnetwork
bitseq/sequence.go
Unset
func (h *Handle) Unset(ordinal uint64) error { if err := h.validateOrdinal(ordinal); err != nil { return err } _, err := h.set(ordinal, 0, 0, false, true, false) return err }
go
func (h *Handle) Unset(ordinal uint64) error { if err := h.validateOrdinal(ordinal); err != nil { return err } _, err := h.set(ordinal, 0, 0, false, true, false) return err }
[ "func", "(", "h", "*", "Handle", ")", "Unset", "(", "ordinal", "uint64", ")", "error", "{", "if", "err", ":=", "h", ".", "validateOrdinal", "(", "ordinal", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "_", ",", "err", ":=", "h", ".", "set", "(", "ordinal", ",", "0", ",", "0", ",", "false", ",", "true", ",", "false", ")", "\n", "return", "err", "\n", "}" ]
// Unset atomically unsets the corresponding bit in the sequence
[ "Unset", "atomically", "unsets", "the", "corresponding", "bit", "in", "the", "sequence" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L236-L242
train
docker/libnetwork
bitseq/sequence.go
IsSet
func (h *Handle) IsSet(ordinal uint64) bool { if err := h.validateOrdinal(ordinal); err != nil { return false } h.Lock() _, _, err := checkIfAvailable(h.head, ordinal) h.Unlock() return err != nil }
go
func (h *Handle) IsSet(ordinal uint64) bool { if err := h.validateOrdinal(ordinal); err != nil { return false } h.Lock() _, _, err := checkIfAvailable(h.head, ordinal) h.Unlock() return err != nil }
[ "func", "(", "h", "*", "Handle", ")", "IsSet", "(", "ordinal", "uint64", ")", "bool", "{", "if", "err", ":=", "h", ".", "validateOrdinal", "(", "ordinal", ")", ";", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "h", ".", "Lock", "(", ")", "\n", "_", ",", "_", ",", "err", ":=", "checkIfAvailable", "(", "h", ".", "head", ",", "ordinal", ")", "\n", "h", ".", "Unlock", "(", ")", "\n", "return", "err", "!=", "nil", "\n", "}" ]
// IsSet atomically checks if the ordinal bit is set. In case ordinal // is outside of the bit sequence limits, false is returned.
[ "IsSet", "atomically", "checks", "if", "the", "ordinal", "bit", "is", "set", ".", "In", "case", "ordinal", "is", "outside", "of", "the", "bit", "sequence", "limits", "false", "is", "returned", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L246-L254
train
docker/libnetwork
bitseq/sequence.go
CheckConsistency
func (h *Handle) CheckConsistency() error { for { h.Lock() store := h.store h.Unlock() if store != nil { if err := store.GetObject(datastore.Key(h.Key()...), h); err != nil && err != datastore.ErrKeyNotFound { return err } } h.Lock() nh := h.getCopy() h.Unlock() if !nh.runConsistencyCheck() { return nil } if err := nh.writeToStore(); err != nil { if _, ok := err.(types.RetryError); !ok { return fmt.Errorf("internal failure while fixing inconsistent bitsequence: %v", err) } continue } logrus.Infof("Fixed inconsistent bit sequence in datastore:\n%s\n%s", h, nh) h.Lock() h.head = nh.head h.Unlock() return nil } }
go
func (h *Handle) CheckConsistency() error { for { h.Lock() store := h.store h.Unlock() if store != nil { if err := store.GetObject(datastore.Key(h.Key()...), h); err != nil && err != datastore.ErrKeyNotFound { return err } } h.Lock() nh := h.getCopy() h.Unlock() if !nh.runConsistencyCheck() { return nil } if err := nh.writeToStore(); err != nil { if _, ok := err.(types.RetryError); !ok { return fmt.Errorf("internal failure while fixing inconsistent bitsequence: %v", err) } continue } logrus.Infof("Fixed inconsistent bit sequence in datastore:\n%s\n%s", h, nh) h.Lock() h.head = nh.head h.Unlock() return nil } }
[ "func", "(", "h", "*", "Handle", ")", "CheckConsistency", "(", ")", "error", "{", "for", "{", "h", ".", "Lock", "(", ")", "\n", "store", ":=", "h", ".", "store", "\n", "h", ".", "Unlock", "(", ")", "\n", "if", "store", "!=", "nil", "{", "if", "err", ":=", "store", ".", "GetObject", "(", "datastore", ".", "Key", "(", "h", ".", "Key", "(", ")", "...", ")", ",", "h", ")", ";", "err", "!=", "nil", "&&", "err", "!=", "datastore", ".", "ErrKeyNotFound", "{", "return", "err", "\n", "}", "\n", "}", "\n", "h", ".", "Lock", "(", ")", "\n", "nh", ":=", "h", ".", "getCopy", "(", ")", "\n", "h", ".", "Unlock", "(", ")", "\n", "if", "!", "nh", ".", "runConsistencyCheck", "(", ")", "{", "return", "nil", "\n", "}", "\n", "if", "err", ":=", "nh", ".", "writeToStore", "(", ")", ";", "err", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "err", ".", "(", "types", ".", "RetryError", ")", ";", "!", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"internal failure while fixing inconsistent bitsequence: %v\"", ",", "err", ")", "\n", "}", "\n", "continue", "\n", "}", "\n", "logrus", ".", "Infof", "(", "\"Fixed inconsistent bit sequence in datastore:\\n%s\\n%s\"", ",", "\\n", ",", "\\n", ")", "\n", "h", "\n", "nh", "\n", "h", ".", "Lock", "(", ")", "\n", "h", ".", "head", "=", "nh", ".", "head", "\n", "}", "\n", "}" ]
// CheckConsistency checks if the bit sequence is in an inconsistent state and attempts to fix it. // It looks for a corruption signature that may happen in docker 1.9.0 and 1.9.1.
[ "CheckConsistency", "checks", "if", "the", "bit", "sequence", "is", "in", "an", "inconsistent", "state", "and", "attempts", "to", "fix", "it", ".", "It", "looks", "for", "a", "corruption", "signature", "that", "may", "happen", "in", "docker", "1", ".", "9", ".", "0", "and", "1", ".", "9", ".", "1", "." ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L271-L306
train
docker/libnetwork
bitseq/sequence.go
validateOrdinal
func (h *Handle) validateOrdinal(ordinal uint64) error { h.Lock() defer h.Unlock() if ordinal >= h.bits { return errors.New("bit does not belong to the sequence") } return nil }
go
func (h *Handle) validateOrdinal(ordinal uint64) error { h.Lock() defer h.Unlock() if ordinal >= h.bits { return errors.New("bit does not belong to the sequence") } return nil }
[ "func", "(", "h", "*", "Handle", ")", "validateOrdinal", "(", "ordinal", "uint64", ")", "error", "{", "h", ".", "Lock", "(", ")", "\n", "defer", "h", ".", "Unlock", "(", ")", "\n", "if", "ordinal", ">=", "h", ".", "bits", "{", "return", "errors", ".", "New", "(", "\"bit does not belong to the sequence\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// checks is needed because to cover the case where the number of bits is not a multiple of blockLen
[ "checks", "is", "needed", "because", "to", "cover", "the", "case", "where", "the", "number", "of", "bits", "is", "not", "a", "multiple", "of", "blockLen" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L386-L393
train
docker/libnetwork
bitseq/sequence.go
Destroy
func (h *Handle) Destroy() error { for { if err := h.deleteFromStore(); err != nil { if _, ok := err.(types.RetryError); !ok { return fmt.Errorf("internal failure while destroying the sequence: %v", err) } // Fetch latest if err := h.store.GetObject(datastore.Key(h.Key()...), h); err != nil { if err == datastore.ErrKeyNotFound { // already removed return nil } return fmt.Errorf("failed to fetch from store when destroying the sequence: %v", err) } continue } return nil } }
go
func (h *Handle) Destroy() error { for { if err := h.deleteFromStore(); err != nil { if _, ok := err.(types.RetryError); !ok { return fmt.Errorf("internal failure while destroying the sequence: %v", err) } // Fetch latest if err := h.store.GetObject(datastore.Key(h.Key()...), h); err != nil { if err == datastore.ErrKeyNotFound { // already removed return nil } return fmt.Errorf("failed to fetch from store when destroying the sequence: %v", err) } continue } return nil } }
[ "func", "(", "h", "*", "Handle", ")", "Destroy", "(", ")", "error", "{", "for", "{", "if", "err", ":=", "h", ".", "deleteFromStore", "(", ")", ";", "err", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "err", ".", "(", "types", ".", "RetryError", ")", ";", "!", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"internal failure while destroying the sequence: %v\"", ",", "err", ")", "\n", "}", "\n", "if", "err", ":=", "h", ".", "store", ".", "GetObject", "(", "datastore", ".", "Key", "(", "h", ".", "Key", "(", ")", "...", ")", ",", "h", ")", ";", "err", "!=", "nil", "{", "if", "err", "==", "datastore", ".", "ErrKeyNotFound", "{", "return", "nil", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"failed to fetch from store when destroying the sequence: %v\"", ",", "err", ")", "\n", "}", "\n", "continue", "\n", "}", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Destroy removes from the datastore the data belonging to this handle
[ "Destroy", "removes", "from", "the", "datastore", "the", "data", "belonging", "to", "this", "handle" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L396-L413
train
docker/libnetwork
bitseq/sequence.go
ToByteArray
func (h *Handle) ToByteArray() ([]byte, error) { h.Lock() defer h.Unlock() ba := make([]byte, 16) binary.BigEndian.PutUint64(ba[0:], h.bits) binary.BigEndian.PutUint64(ba[8:], h.unselected) bm, err := h.head.toByteArray() if err != nil { return nil, fmt.Errorf("failed to serialize head: %s", err.Error()) } ba = append(ba, bm...) return ba, nil }
go
func (h *Handle) ToByteArray() ([]byte, error) { h.Lock() defer h.Unlock() ba := make([]byte, 16) binary.BigEndian.PutUint64(ba[0:], h.bits) binary.BigEndian.PutUint64(ba[8:], h.unselected) bm, err := h.head.toByteArray() if err != nil { return nil, fmt.Errorf("failed to serialize head: %s", err.Error()) } ba = append(ba, bm...) return ba, nil }
[ "func", "(", "h", "*", "Handle", ")", "ToByteArray", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "h", ".", "Lock", "(", ")", "\n", "defer", "h", ".", "Unlock", "(", ")", "\n", "ba", ":=", "make", "(", "[", "]", "byte", ",", "16", ")", "\n", "binary", ".", "BigEndian", ".", "PutUint64", "(", "ba", "[", "0", ":", "]", ",", "h", ".", "bits", ")", "\n", "binary", ".", "BigEndian", ".", "PutUint64", "(", "ba", "[", "8", ":", "]", ",", "h", ".", "unselected", ")", "\n", "bm", ",", "err", ":=", "h", ".", "head", ".", "toByteArray", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"failed to serialize head: %s\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "ba", "=", "append", "(", "ba", ",", "bm", "...", ")", "\n", "return", "ba", ",", "nil", "\n", "}" ]
// ToByteArray converts this handle's data into a byte array
[ "ToByteArray", "converts", "this", "handle", "s", "data", "into", "a", "byte", "array" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L416-L430
train
docker/libnetwork
bitseq/sequence.go
FromByteArray
func (h *Handle) FromByteArray(ba []byte) error { if ba == nil { return errors.New("nil byte array") } nh := &sequence{} err := nh.fromByteArray(ba[16:]) if err != nil { return fmt.Errorf("failed to deserialize head: %s", err.Error()) } h.Lock() h.head = nh h.bits = binary.BigEndian.Uint64(ba[0:8]) h.unselected = binary.BigEndian.Uint64(ba[8:16]) h.Unlock() return nil }
go
func (h *Handle) FromByteArray(ba []byte) error { if ba == nil { return errors.New("nil byte array") } nh := &sequence{} err := nh.fromByteArray(ba[16:]) if err != nil { return fmt.Errorf("failed to deserialize head: %s", err.Error()) } h.Lock() h.head = nh h.bits = binary.BigEndian.Uint64(ba[0:8]) h.unselected = binary.BigEndian.Uint64(ba[8:16]) h.Unlock() return nil }
[ "func", "(", "h", "*", "Handle", ")", "FromByteArray", "(", "ba", "[", "]", "byte", ")", "error", "{", "if", "ba", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"nil byte array\"", ")", "\n", "}", "\n", "nh", ":=", "&", "sequence", "{", "}", "\n", "err", ":=", "nh", ".", "fromByteArray", "(", "ba", "[", "16", ":", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"failed to deserialize head: %s\"", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "h", ".", "Lock", "(", ")", "\n", "h", ".", "head", "=", "nh", "\n", "h", ".", "bits", "=", "binary", ".", "BigEndian", ".", "Uint64", "(", "ba", "[", "0", ":", "8", "]", ")", "\n", "h", ".", "unselected", "=", "binary", ".", "BigEndian", ".", "Uint64", "(", "ba", "[", "8", ":", "16", "]", ")", "\n", "h", ".", "Unlock", "(", ")", "\n", "return", "nil", "\n", "}" ]
// FromByteArray reads his handle's data from a byte array
[ "FromByteArray", "reads", "his", "handle", "s", "data", "from", "a", "byte", "array" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L433-L451
train
docker/libnetwork
bitseq/sequence.go
Unselected
func (h *Handle) Unselected() uint64 { h.Lock() defer h.Unlock() return h.unselected }
go
func (h *Handle) Unselected() uint64 { h.Lock() defer h.Unlock() return h.unselected }
[ "func", "(", "h", "*", "Handle", ")", "Unselected", "(", ")", "uint64", "{", "h", ".", "Lock", "(", ")", "\n", "defer", "h", ".", "Unlock", "(", ")", "\n", "return", "h", ".", "unselected", "\n", "}" ]
// Unselected returns the number of bits which are not selected
[ "Unselected", "returns", "the", "number", "of", "bits", "which", "are", "not", "selected" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L459-L463
train
docker/libnetwork
bitseq/sequence.go
MarshalJSON
func (h *Handle) MarshalJSON() ([]byte, error) { m := map[string]interface{}{ "id": h.id, } b, err := h.ToByteArray() if err != nil { return nil, err } m["sequence"] = b return json.Marshal(m) }
go
func (h *Handle) MarshalJSON() ([]byte, error) { m := map[string]interface{}{ "id": h.id, } b, err := h.ToByteArray() if err != nil { return nil, err } m["sequence"] = b return json.Marshal(m) }
[ "func", "(", "h", "*", "Handle", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "m", ":=", "map", "[", "string", "]", "interface", "{", "}", "{", "\"id\"", ":", "h", ".", "id", ",", "}", "\n", "b", ",", "err", ":=", "h", ".", "ToByteArray", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "m", "[", "\"sequence\"", "]", "=", "b", "\n", "return", "json", ".", "Marshal", "(", "m", ")", "\n", "}" ]
// MarshalJSON encodes Handle into json message
[ "MarshalJSON", "encodes", "Handle", "into", "json", "message" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L473-L484
train
docker/libnetwork
bitseq/sequence.go
UnmarshalJSON
func (h *Handle) UnmarshalJSON(data []byte) error { var ( m map[string]interface{} b []byte err error ) if err = json.Unmarshal(data, &m); err != nil { return err } h.id = m["id"].(string) bi, _ := json.Marshal(m["sequence"]) if err := json.Unmarshal(bi, &b); err != nil { return err } return h.FromByteArray(b) }
go
func (h *Handle) UnmarshalJSON(data []byte) error { var ( m map[string]interface{} b []byte err error ) if err = json.Unmarshal(data, &m); err != nil { return err } h.id = m["id"].(string) bi, _ := json.Marshal(m["sequence"]) if err := json.Unmarshal(bi, &b); err != nil { return err } return h.FromByteArray(b) }
[ "func", "(", "h", "*", "Handle", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "(", "m", "map", "[", "string", "]", "interface", "{", "}", "\n", "b", "[", "]", "byte", "\n", "err", "error", "\n", ")", "\n", "if", "err", "=", "json", ".", "Unmarshal", "(", "data", ",", "&", "m", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "h", ".", "id", "=", "m", "[", "\"id\"", "]", ".", "(", "string", ")", "\n", "bi", ",", "_", ":=", "json", ".", "Marshal", "(", "m", "[", "\"sequence\"", "]", ")", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "bi", ",", "&", "b", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "h", ".", "FromByteArray", "(", "b", ")", "\n", "}" ]
// UnmarshalJSON decodes json message into Handle
[ "UnmarshalJSON", "decodes", "json", "message", "into", "Handle" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L487-L502
train
docker/libnetwork
bitseq/sequence.go
getFirstAvailable
func getFirstAvailable(head *sequence, start uint64) (uint64, uint64, error) { // Find sequence which contains the start bit byteStart, bitStart := ordinalToPos(start) current, _, precBlocks, inBlockBytePos := findSequence(head, byteStart) // Derive the this sequence offsets byteOffset := byteStart - inBlockBytePos bitOffset := inBlockBytePos*8 + bitStart for current != nil { if current.block != blockMAX { // If the current block is not full, check if there is any bit // from the current bit in the current block. If not, before proceeding to the // next block node, make sure we check for available bit in the next // instance of the same block. Due to RLE same block signature will be // compressed. retry: bytePos, bitPos, err := current.getAvailableBit(bitOffset) if err != nil && precBlocks == current.count-1 { // This is the last instance in the same block node, // so move to the next block. goto next } if err != nil { // There are some more instances of the same block, so add the offset // and be optimistic that you will find the available bit in the next // instance of the same block. bitOffset = 0 byteOffset += blockBytes precBlocks++ goto retry } return byteOffset + bytePos, bitPos, err } // Moving to next block: Reset bit offset. next: bitOffset = 0 byteOffset += (current.count * blockBytes) - (precBlocks * blockBytes) precBlocks = 0 current = current.next } return invalidPos, invalidPos, ErrNoBitAvailable }
go
func getFirstAvailable(head *sequence, start uint64) (uint64, uint64, error) { // Find sequence which contains the start bit byteStart, bitStart := ordinalToPos(start) current, _, precBlocks, inBlockBytePos := findSequence(head, byteStart) // Derive the this sequence offsets byteOffset := byteStart - inBlockBytePos bitOffset := inBlockBytePos*8 + bitStart for current != nil { if current.block != blockMAX { // If the current block is not full, check if there is any bit // from the current bit in the current block. If not, before proceeding to the // next block node, make sure we check for available bit in the next // instance of the same block. Due to RLE same block signature will be // compressed. retry: bytePos, bitPos, err := current.getAvailableBit(bitOffset) if err != nil && precBlocks == current.count-1 { // This is the last instance in the same block node, // so move to the next block. goto next } if err != nil { // There are some more instances of the same block, so add the offset // and be optimistic that you will find the available bit in the next // instance of the same block. bitOffset = 0 byteOffset += blockBytes precBlocks++ goto retry } return byteOffset + bytePos, bitPos, err } // Moving to next block: Reset bit offset. next: bitOffset = 0 byteOffset += (current.count * blockBytes) - (precBlocks * blockBytes) precBlocks = 0 current = current.next } return invalidPos, invalidPos, ErrNoBitAvailable }
[ "func", "getFirstAvailable", "(", "head", "*", "sequence", ",", "start", "uint64", ")", "(", "uint64", ",", "uint64", ",", "error", ")", "{", "byteStart", ",", "bitStart", ":=", "ordinalToPos", "(", "start", ")", "\n", "current", ",", "_", ",", "precBlocks", ",", "inBlockBytePos", ":=", "findSequence", "(", "head", ",", "byteStart", ")", "\n", "byteOffset", ":=", "byteStart", "-", "inBlockBytePos", "\n", "bitOffset", ":=", "inBlockBytePos", "*", "8", "+", "bitStart", "\n", "for", "current", "!=", "nil", "{", "if", "current", ".", "block", "!=", "blockMAX", "{", "retry", ":", "bytePos", ",", "bitPos", ",", "err", ":=", "current", ".", "getAvailableBit", "(", "bitOffset", ")", "\n", "if", "err", "!=", "nil", "&&", "precBlocks", "==", "current", ".", "count", "-", "1", "{", "goto", "next", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "bitOffset", "=", "0", "\n", "byteOffset", "+=", "blockBytes", "\n", "precBlocks", "++", "\n", "goto", "retry", "\n", "}", "\n", "return", "byteOffset", "+", "bytePos", ",", "bitPos", ",", "err", "\n", "}", "\n", "next", ":", "bitOffset", "=", "0", "\n", "byteOffset", "+=", "(", "current", ".", "count", "*", "blockBytes", ")", "-", "(", "precBlocks", "*", "blockBytes", ")", "\n", "precBlocks", "=", "0", "\n", "current", "=", "current", ".", "next", "\n", "}", "\n", "return", "invalidPos", ",", "invalidPos", ",", "ErrNoBitAvailable", "\n", "}" ]
// getFirstAvailable looks for the first unset bit in passed mask starting from start
[ "getFirstAvailable", "looks", "for", "the", "first", "unset", "bit", "in", "passed", "mask", "starting", "from", "start" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L505-L545
train
docker/libnetwork
bitseq/sequence.go
getAvailableFromCurrent
func getAvailableFromCurrent(head *sequence, start, curr, end uint64) (uint64, uint64, error) { var bytePos, bitPos uint64 var err error if curr != 0 && curr > start { bytePos, bitPos, err = getFirstAvailable(head, curr) ret := posToOrdinal(bytePos, bitPos) if end < ret || err != nil { goto begin } return bytePos, bitPos, nil } begin: bytePos, bitPos, err = getFirstAvailable(head, start) ret := posToOrdinal(bytePos, bitPos) if end < ret || err != nil { return invalidPos, invalidPos, ErrNoBitAvailable } return bytePos, bitPos, nil }
go
func getAvailableFromCurrent(head *sequence, start, curr, end uint64) (uint64, uint64, error) { var bytePos, bitPos uint64 var err error if curr != 0 && curr > start { bytePos, bitPos, err = getFirstAvailable(head, curr) ret := posToOrdinal(bytePos, bitPos) if end < ret || err != nil { goto begin } return bytePos, bitPos, nil } begin: bytePos, bitPos, err = getFirstAvailable(head, start) ret := posToOrdinal(bytePos, bitPos) if end < ret || err != nil { return invalidPos, invalidPos, ErrNoBitAvailable } return bytePos, bitPos, nil }
[ "func", "getAvailableFromCurrent", "(", "head", "*", "sequence", ",", "start", ",", "curr", ",", "end", "uint64", ")", "(", "uint64", ",", "uint64", ",", "error", ")", "{", "var", "bytePos", ",", "bitPos", "uint64", "\n", "var", "err", "error", "\n", "if", "curr", "!=", "0", "&&", "curr", ">", "start", "{", "bytePos", ",", "bitPos", ",", "err", "=", "getFirstAvailable", "(", "head", ",", "curr", ")", "\n", "ret", ":=", "posToOrdinal", "(", "bytePos", ",", "bitPos", ")", "\n", "if", "end", "<", "ret", "||", "err", "!=", "nil", "{", "goto", "begin", "\n", "}", "\n", "return", "bytePos", ",", "bitPos", ",", "nil", "\n", "}", "\n", "begin", ":", "bytePos", ",", "bitPos", ",", "err", "=", "getFirstAvailable", "(", "head", ",", "start", ")", "\n", "ret", ":=", "posToOrdinal", "(", "bytePos", ",", "bitPos", ")", "\n", "if", "end", "<", "ret", "||", "err", "!=", "nil", "{", "return", "invalidPos", ",", "invalidPos", ",", "ErrNoBitAvailable", "\n", "}", "\n", "return", "bytePos", ",", "bitPos", ",", "nil", "\n", "}" ]
// getAvailableFromCurrent will look for available ordinal from the current ordinal. // If none found then it will loop back to the start to check of the available bit. // This can be further optimized to check from start till curr in case of a rollover
[ "getAvailableFromCurrent", "will", "look", "for", "available", "ordinal", "from", "the", "current", "ordinal", ".", "If", "none", "found", "then", "it", "will", "loop", "back", "to", "the", "start", "to", "check", "of", "the", "available", "bit", ".", "This", "can", "be", "further", "optimized", "to", "check", "from", "start", "till", "curr", "in", "case", "of", "a", "rollover" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L550-L569
train
docker/libnetwork
bitseq/sequence.go
checkIfAvailable
func checkIfAvailable(head *sequence, ordinal uint64) (uint64, uint64, error) { bytePos, bitPos := ordinalToPos(ordinal) // Find the sequence containing this byte current, _, _, inBlockBytePos := findSequence(head, bytePos) if current != nil { // Check whether the bit corresponding to the ordinal address is unset bitSel := blockFirstBit >> (inBlockBytePos*8 + bitPos) if current.block&bitSel == 0 { return bytePos, bitPos, nil } } return invalidPos, invalidPos, ErrBitAllocated }
go
func checkIfAvailable(head *sequence, ordinal uint64) (uint64, uint64, error) { bytePos, bitPos := ordinalToPos(ordinal) // Find the sequence containing this byte current, _, _, inBlockBytePos := findSequence(head, bytePos) if current != nil { // Check whether the bit corresponding to the ordinal address is unset bitSel := blockFirstBit >> (inBlockBytePos*8 + bitPos) if current.block&bitSel == 0 { return bytePos, bitPos, nil } } return invalidPos, invalidPos, ErrBitAllocated }
[ "func", "checkIfAvailable", "(", "head", "*", "sequence", ",", "ordinal", "uint64", ")", "(", "uint64", ",", "uint64", ",", "error", ")", "{", "bytePos", ",", "bitPos", ":=", "ordinalToPos", "(", "ordinal", ")", "\n", "current", ",", "_", ",", "_", ",", "inBlockBytePos", ":=", "findSequence", "(", "head", ",", "bytePos", ")", "\n", "if", "current", "!=", "nil", "{", "bitSel", ":=", "blockFirstBit", ">>", "(", "inBlockBytePos", "*", "8", "+", "bitPos", ")", "\n", "if", "current", ".", "block", "&", "bitSel", "==", "0", "{", "return", "bytePos", ",", "bitPos", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "invalidPos", ",", "invalidPos", ",", "ErrBitAllocated", "\n", "}" ]
// checkIfAvailable checks if the bit correspondent to the specified ordinal is unset // If the ordinal is beyond the sequence limits, a negative response is returned
[ "checkIfAvailable", "checks", "if", "the", "bit", "correspondent", "to", "the", "specified", "ordinal", "is", "unset", "If", "the", "ordinal", "is", "beyond", "the", "sequence", "limits", "a", "negative", "response", "is", "returned" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L573-L587
train
docker/libnetwork
bitseq/sequence.go
removeCurrentIfEmpty
func removeCurrentIfEmpty(head **sequence, previous, current *sequence) { if current.count == 0 { if current == *head { *head = current.next } else { previous.next = current.next current = current.next } } }
go
func removeCurrentIfEmpty(head **sequence, previous, current *sequence) { if current.count == 0 { if current == *head { *head = current.next } else { previous.next = current.next current = current.next } } }
[ "func", "removeCurrentIfEmpty", "(", "head", "*", "*", "sequence", ",", "previous", ",", "current", "*", "sequence", ")", "{", "if", "current", ".", "count", "==", "0", "{", "if", "current", "==", "*", "head", "{", "*", "head", "=", "current", ".", "next", "\n", "}", "else", "{", "previous", ".", "next", "=", "current", ".", "next", "\n", "current", "=", "current", ".", "next", "\n", "}", "\n", "}", "\n", "}" ]
// Removes the current sequence from the list if empty, adjusting the head pointer if needed
[ "Removes", "the", "current", "sequence", "from", "the", "list", "if", "empty", "adjusting", "the", "head", "pointer", "if", "needed" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/bitseq/sequence.go#L696-L705
train
docker/libnetwork
osl/interface_linux.go
Statistics
func (i *nwIface) Statistics() (*types.InterfaceStatistics, error) { i.Lock() n := i.ns i.Unlock() l, err := n.nlHandle.LinkByName(i.DstName()) if err != nil { return nil, fmt.Errorf("failed to retrieve the statistics for %s in netns %s: %v", i.DstName(), n.path, err) } stats := l.Attrs().Statistics if stats == nil { return nil, fmt.Errorf("no statistics were returned") } return &types.InterfaceStatistics{ RxBytes: uint64(stats.RxBytes), TxBytes: uint64(stats.TxBytes), RxPackets: uint64(stats.RxPackets), TxPackets: uint64(stats.TxPackets), RxDropped: uint64(stats.RxDropped), TxDropped: uint64(stats.TxDropped), }, nil }
go
func (i *nwIface) Statistics() (*types.InterfaceStatistics, error) { i.Lock() n := i.ns i.Unlock() l, err := n.nlHandle.LinkByName(i.DstName()) if err != nil { return nil, fmt.Errorf("failed to retrieve the statistics for %s in netns %s: %v", i.DstName(), n.path, err) } stats := l.Attrs().Statistics if stats == nil { return nil, fmt.Errorf("no statistics were returned") } return &types.InterfaceStatistics{ RxBytes: uint64(stats.RxBytes), TxBytes: uint64(stats.TxBytes), RxPackets: uint64(stats.RxPackets), TxPackets: uint64(stats.TxPackets), RxDropped: uint64(stats.RxDropped), TxDropped: uint64(stats.TxDropped), }, nil }
[ "func", "(", "i", "*", "nwIface", ")", "Statistics", "(", ")", "(", "*", "types", ".", "InterfaceStatistics", ",", "error", ")", "{", "i", ".", "Lock", "(", ")", "\n", "n", ":=", "i", ".", "ns", "\n", "i", ".", "Unlock", "(", ")", "\n", "l", ",", "err", ":=", "n", ".", "nlHandle", ".", "LinkByName", "(", "i", ".", "DstName", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"failed to retrieve the statistics for %s in netns %s: %v\"", ",", "i", ".", "DstName", "(", ")", ",", "n", ".", "path", ",", "err", ")", "\n", "}", "\n", "stats", ":=", "l", ".", "Attrs", "(", ")", ".", "Statistics", "\n", "if", "stats", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"no statistics were returned\"", ")", "\n", "}", "\n", "return", "&", "types", ".", "InterfaceStatistics", "{", "RxBytes", ":", "uint64", "(", "stats", ".", "RxBytes", ")", ",", "TxBytes", ":", "uint64", "(", "stats", ".", "TxBytes", ")", ",", "RxPackets", ":", "uint64", "(", "stats", ".", "RxPackets", ")", ",", "TxPackets", ":", "uint64", "(", "stats", ".", "TxPackets", ")", ",", "RxDropped", ":", "uint64", "(", "stats", ".", "RxDropped", ")", ",", "TxDropped", ":", "uint64", "(", "stats", ".", "TxDropped", ")", ",", "}", ",", "nil", "\n", "}" ]
// Returns the sandbox's side veth interface statistics
[ "Returns", "the", "sandbox", "s", "side", "veth", "interface", "statistics" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/osl/interface_linux.go#L180-L203
train
docker/libnetwork
ipamutils/utils.go
configDefaultNetworks
func configDefaultNetworks(defaultAddressPool []*NetworkToSplit, result *[]*net.IPNet) error { mutex.Lock() defer mutex.Unlock() defaultNetworks, err := splitNetworks(defaultAddressPool) if err != nil { return err } *result = defaultNetworks return nil }
go
func configDefaultNetworks(defaultAddressPool []*NetworkToSplit, result *[]*net.IPNet) error { mutex.Lock() defer mutex.Unlock() defaultNetworks, err := splitNetworks(defaultAddressPool) if err != nil { return err } *result = defaultNetworks return nil }
[ "func", "configDefaultNetworks", "(", "defaultAddressPool", "[", "]", "*", "NetworkToSplit", ",", "result", "*", "[", "]", "*", "net", ".", "IPNet", ")", "error", "{", "mutex", ".", "Lock", "(", ")", "\n", "defer", "mutex", ".", "Unlock", "(", ")", "\n", "defaultNetworks", ",", "err", ":=", "splitNetworks", "(", "defaultAddressPool", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "*", "result", "=", "defaultNetworks", "\n", "return", "nil", "\n", "}" ]
// configDefaultNetworks configures local as well global default pool based on input
[ "configDefaultNetworks", "configures", "local", "as", "well", "global", "default", "pool", "based", "on", "input" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipamutils/utils.go#L48-L57
train
docker/libnetwork
ipamutils/utils.go
ConfigGlobalScopeDefaultNetworks
func ConfigGlobalScopeDefaultNetworks(defaultAddressPool []*NetworkToSplit) error { if defaultAddressPool == nil { defaultAddressPool = globalScopeDefaultNetworks } return configDefaultNetworks(defaultAddressPool, &PredefinedGlobalScopeDefaultNetworks) }
go
func ConfigGlobalScopeDefaultNetworks(defaultAddressPool []*NetworkToSplit) error { if defaultAddressPool == nil { defaultAddressPool = globalScopeDefaultNetworks } return configDefaultNetworks(defaultAddressPool, &PredefinedGlobalScopeDefaultNetworks) }
[ "func", "ConfigGlobalScopeDefaultNetworks", "(", "defaultAddressPool", "[", "]", "*", "NetworkToSplit", ")", "error", "{", "if", "defaultAddressPool", "==", "nil", "{", "defaultAddressPool", "=", "globalScopeDefaultNetworks", "\n", "}", "\n", "return", "configDefaultNetworks", "(", "defaultAddressPool", ",", "&", "PredefinedGlobalScopeDefaultNetworks", ")", "\n", "}" ]
// ConfigGlobalScopeDefaultNetworks configures global default pool. // Ideally this will be called from SwarmKit as part of swarm init
[ "ConfigGlobalScopeDefaultNetworks", "configures", "global", "default", "pool", ".", "Ideally", "this", "will", "be", "called", "from", "SwarmKit", "as", "part", "of", "swarm", "init" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipamutils/utils.go#L75-L80
train
docker/libnetwork
ipamutils/utils.go
ConfigLocalScopeDefaultNetworks
func ConfigLocalScopeDefaultNetworks(defaultAddressPool []*NetworkToSplit) error { if defaultAddressPool == nil { return nil } return configDefaultNetworks(defaultAddressPool, &PredefinedLocalScopeDefaultNetworks) }
go
func ConfigLocalScopeDefaultNetworks(defaultAddressPool []*NetworkToSplit) error { if defaultAddressPool == nil { return nil } return configDefaultNetworks(defaultAddressPool, &PredefinedLocalScopeDefaultNetworks) }
[ "func", "ConfigLocalScopeDefaultNetworks", "(", "defaultAddressPool", "[", "]", "*", "NetworkToSplit", ")", "error", "{", "if", "defaultAddressPool", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "configDefaultNetworks", "(", "defaultAddressPool", ",", "&", "PredefinedLocalScopeDefaultNetworks", ")", "\n", "}" ]
// ConfigLocalScopeDefaultNetworks configures local default pool. // Ideally this will be called during libnetwork init
[ "ConfigLocalScopeDefaultNetworks", "configures", "local", "default", "pool", ".", "Ideally", "this", "will", "be", "called", "during", "libnetwork", "init" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipamutils/utils.go#L84-L89
train
docker/libnetwork
ipamutils/utils.go
splitNetworks
func splitNetworks(list []*NetworkToSplit) ([]*net.IPNet, error) { localPools := make([]*net.IPNet, 0, len(list)) for _, p := range list { _, b, err := net.ParseCIDR(p.Base) if err != nil { return nil, fmt.Errorf("invalid base pool %q: %v", p.Base, err) } ones, _ := b.Mask.Size() if p.Size <= 0 || p.Size < ones { return nil, fmt.Errorf("invalid pools size: %d", p.Size) } localPools = append(localPools, splitNetwork(p.Size, b)...) } return localPools, nil }
go
func splitNetworks(list []*NetworkToSplit) ([]*net.IPNet, error) { localPools := make([]*net.IPNet, 0, len(list)) for _, p := range list { _, b, err := net.ParseCIDR(p.Base) if err != nil { return nil, fmt.Errorf("invalid base pool %q: %v", p.Base, err) } ones, _ := b.Mask.Size() if p.Size <= 0 || p.Size < ones { return nil, fmt.Errorf("invalid pools size: %d", p.Size) } localPools = append(localPools, splitNetwork(p.Size, b)...) } return localPools, nil }
[ "func", "splitNetworks", "(", "list", "[", "]", "*", "NetworkToSplit", ")", "(", "[", "]", "*", "net", ".", "IPNet", ",", "error", ")", "{", "localPools", ":=", "make", "(", "[", "]", "*", "net", ".", "IPNet", ",", "0", ",", "len", "(", "list", ")", ")", "\n", "for", "_", ",", "p", ":=", "range", "list", "{", "_", ",", "b", ",", "err", ":=", "net", ".", "ParseCIDR", "(", "p", ".", "Base", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"invalid base pool %q: %v\"", ",", "p", ".", "Base", ",", "err", ")", "\n", "}", "\n", "ones", ",", "_", ":=", "b", ".", "Mask", ".", "Size", "(", ")", "\n", "if", "p", ".", "Size", "<=", "0", "||", "p", ".", "Size", "<", "ones", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"invalid pools size: %d\"", ",", "p", ".", "Size", ")", "\n", "}", "\n", "localPools", "=", "append", "(", "localPools", ",", "splitNetwork", "(", "p", ".", "Size", ",", "b", ")", "...", ")", "\n", "}", "\n", "return", "localPools", ",", "nil", "\n", "}" ]
// splitNetworks takes a slice of networks, split them accordingly and returns them
[ "splitNetworks", "takes", "a", "slice", "of", "networks", "split", "them", "accordingly", "and", "returns", "them" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/ipamutils/utils.go#L92-L107
train
docker/libnetwork
portmapper/mapper_linux.go
SetIptablesChain
func (pm *PortMapper) SetIptablesChain(c *iptables.ChainInfo, bridgeName string) { pm.chain = c pm.bridgeName = bridgeName }
go
func (pm *PortMapper) SetIptablesChain(c *iptables.ChainInfo, bridgeName string) { pm.chain = c pm.bridgeName = bridgeName }
[ "func", "(", "pm", "*", "PortMapper", ")", "SetIptablesChain", "(", "c", "*", "iptables", ".", "ChainInfo", ",", "bridgeName", "string", ")", "{", "pm", ".", "chain", "=", "c", "\n", "pm", ".", "bridgeName", "=", "bridgeName", "\n", "}" ]
// SetIptablesChain sets the specified chain into portmapper
[ "SetIptablesChain", "sets", "the", "specified", "chain", "into", "portmapper" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/portmapper/mapper_linux.go#L26-L29
train
docker/libnetwork
portmapper/mapper_linux.go
DeleteForwardingTableEntry
func (pm *PortMapper) DeleteForwardingTableEntry(proto string, sourceIP net.IP, sourcePort int, containerIP string, containerPort int) error { return pm.forward(iptables.Delete, proto, sourceIP, sourcePort, containerIP, containerPort) }
go
func (pm *PortMapper) DeleteForwardingTableEntry(proto string, sourceIP net.IP, sourcePort int, containerIP string, containerPort int) error { return pm.forward(iptables.Delete, proto, sourceIP, sourcePort, containerIP, containerPort) }
[ "func", "(", "pm", "*", "PortMapper", ")", "DeleteForwardingTableEntry", "(", "proto", "string", ",", "sourceIP", "net", ".", "IP", ",", "sourcePort", "int", ",", "containerIP", "string", ",", "containerPort", "int", ")", "error", "{", "return", "pm", ".", "forward", "(", "iptables", ".", "Delete", ",", "proto", ",", "sourceIP", ",", "sourcePort", ",", "containerIP", ",", "containerPort", ")", "\n", "}" ]
// DeleteForwardingTableEntry removes a port mapping from the forwarding table
[ "DeleteForwardingTableEntry", "removes", "a", "port", "mapping", "from", "the", "forwarding", "table" ]
9ff9b57c344df5cd47443ad9e65702ec85c5aeb0
https://github.com/docker/libnetwork/blob/9ff9b57c344df5cd47443ad9e65702ec85c5aeb0/portmapper/mapper_linux.go#L37-L39
train
satori/go.uuid
codec.go
FromBytes
func FromBytes(input []byte) (u UUID, err error) { err = u.UnmarshalBinary(input) return }
go
func FromBytes(input []byte) (u UUID, err error) { err = u.UnmarshalBinary(input) return }
[ "func", "FromBytes", "(", "input", "[", "]", "byte", ")", "(", "u", "UUID", ",", "err", "error", ")", "{", "err", "=", "u", ".", "UnmarshalBinary", "(", "input", ")", "\n", "return", "\n", "}" ]
// FromBytes returns UUID converted from raw byte slice input. // It will return error if the slice isn't 16 bytes long.
[ "FromBytes", "returns", "UUID", "converted", "from", "raw", "byte", "slice", "input", ".", "It", "will", "return", "error", "if", "the", "slice", "isn", "t", "16", "bytes", "long", "." ]
b2ce2384e17bbe0c6d34077efa39dbab3e09123b
https://github.com/satori/go.uuid/blob/b2ce2384e17bbe0c6d34077efa39dbab3e09123b/codec.go#L32-L35
train
satori/go.uuid
codec.go
FromBytesOrNil
func FromBytesOrNil(input []byte) UUID { uuid, err := FromBytes(input) if err != nil { return Nil } return uuid }
go
func FromBytesOrNil(input []byte) UUID { uuid, err := FromBytes(input) if err != nil { return Nil } return uuid }
[ "func", "FromBytesOrNil", "(", "input", "[", "]", "byte", ")", "UUID", "{", "uuid", ",", "err", ":=", "FromBytes", "(", "input", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Nil", "\n", "}", "\n", "return", "uuid", "\n", "}" ]
// FromBytesOrNil returns UUID converted from raw byte slice input. // Same behavior as FromBytes, but returns a Nil UUID on error.
[ "FromBytesOrNil", "returns", "UUID", "converted", "from", "raw", "byte", "slice", "input", ".", "Same", "behavior", "as", "FromBytes", "but", "returns", "a", "Nil", "UUID", "on", "error", "." ]
b2ce2384e17bbe0c6d34077efa39dbab3e09123b
https://github.com/satori/go.uuid/blob/b2ce2384e17bbe0c6d34077efa39dbab3e09123b/codec.go#L39-L45
train
satori/go.uuid
codec.go
FromStringOrNil
func FromStringOrNil(input string) UUID { uuid, err := FromString(input) if err != nil { return Nil } return uuid }
go
func FromStringOrNil(input string) UUID { uuid, err := FromString(input) if err != nil { return Nil } return uuid }
[ "func", "FromStringOrNil", "(", "input", "string", ")", "UUID", "{", "uuid", ",", "err", ":=", "FromString", "(", "input", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Nil", "\n", "}", "\n", "return", "uuid", "\n", "}" ]
// FromStringOrNil returns UUID parsed from string input. // Same behavior as FromString, but returns a Nil UUID on error.
[ "FromStringOrNil", "returns", "UUID", "parsed", "from", "string", "input", ".", "Same", "behavior", "as", "FromString", "but", "returns", "a", "Nil", "UUID", "on", "error", "." ]
b2ce2384e17bbe0c6d34077efa39dbab3e09123b
https://github.com/satori/go.uuid/blob/b2ce2384e17bbe0c6d34077efa39dbab3e09123b/codec.go#L56-L62
train
satori/go.uuid
codec.go
MarshalText
func (u UUID) MarshalText() (text []byte, err error) { text = []byte(u.String()) return }
go
func (u UUID) MarshalText() (text []byte, err error) { text = []byte(u.String()) return }
[ "func", "(", "u", "UUID", ")", "MarshalText", "(", ")", "(", "text", "[", "]", "byte", ",", "err", "error", ")", "{", "text", "=", "[", "]", "byte", "(", "u", ".", "String", "(", ")", ")", "\n", "return", "\n", "}" ]
// MarshalText implements the encoding.TextMarshaler interface. // The encoding is the same as returned by String.
[ "MarshalText", "implements", "the", "encoding", ".", "TextMarshaler", "interface", ".", "The", "encoding", "is", "the", "same", "as", "returned", "by", "String", "." ]
b2ce2384e17bbe0c6d34077efa39dbab3e09123b
https://github.com/satori/go.uuid/blob/b2ce2384e17bbe0c6d34077efa39dbab3e09123b/codec.go#L66-L69
train
satori/go.uuid
codec.go
decodeCanonical
func (u *UUID) decodeCanonical(t []byte) (err error) { if t[8] != '-' || t[13] != '-' || t[18] != '-' || t[23] != '-' { return fmt.Errorf("uuid: incorrect UUID format %s", t) } src := t[:] dst := u[:] for i, byteGroup := range byteGroups { if i > 0 { src = src[1:] // skip dash } _, err = hex.Decode(dst[:byteGroup/2], src[:byteGroup]) if err != nil { return } src = src[byteGroup:] dst = dst[byteGroup/2:] } return }
go
func (u *UUID) decodeCanonical(t []byte) (err error) { if t[8] != '-' || t[13] != '-' || t[18] != '-' || t[23] != '-' { return fmt.Errorf("uuid: incorrect UUID format %s", t) } src := t[:] dst := u[:] for i, byteGroup := range byteGroups { if i > 0 { src = src[1:] // skip dash } _, err = hex.Decode(dst[:byteGroup/2], src[:byteGroup]) if err != nil { return } src = src[byteGroup:] dst = dst[byteGroup/2:] } return }
[ "func", "(", "u", "*", "UUID", ")", "decodeCanonical", "(", "t", "[", "]", "byte", ")", "(", "err", "error", ")", "{", "if", "t", "[", "8", "]", "!=", "'-'", "||", "t", "[", "13", "]", "!=", "'-'", "||", "t", "[", "18", "]", "!=", "'-'", "||", "t", "[", "23", "]", "!=", "'-'", "{", "return", "fmt", ".", "Errorf", "(", "\"uuid: incorrect UUID format %s\"", ",", "t", ")", "\n", "}", "\n", "src", ":=", "t", "[", ":", "]", "\n", "dst", ":=", "u", "[", ":", "]", "\n", "for", "i", ",", "byteGroup", ":=", "range", "byteGroups", "{", "if", "i", ">", "0", "{", "src", "=", "src", "[", "1", ":", "]", "\n", "}", "\n", "_", ",", "err", "=", "hex", ".", "Decode", "(", "dst", "[", ":", "byteGroup", "/", "2", "]", ",", "src", "[", ":", "byteGroup", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "src", "=", "src", "[", "byteGroup", ":", "]", "\n", "dst", "=", "dst", "[", "byteGroup", "/", "2", ":", "]", "\n", "}", "\n", "return", "\n", "}" ]
// decodeCanonical decodes UUID string in format // "6ba7b810-9dad-11d1-80b4-00c04fd430c8".
[ "decodeCanonical", "decodes", "UUID", "string", "in", "format", "6ba7b810", "-", "9dad", "-", "11d1", "-", "80b4", "-", "00c04fd430c8", "." ]
b2ce2384e17bbe0c6d34077efa39dbab3e09123b
https://github.com/satori/go.uuid/blob/b2ce2384e17bbe0c6d34077efa39dbab3e09123b/codec.go#L113-L134
train
satori/go.uuid
codec.go
decodeHashLike
func (u *UUID) decodeHashLike(t []byte) (err error) { src := t[:] dst := u[:] if _, err = hex.Decode(dst, src); err != nil { return err } return }
go
func (u *UUID) decodeHashLike(t []byte) (err error) { src := t[:] dst := u[:] if _, err = hex.Decode(dst, src); err != nil { return err } return }
[ "func", "(", "u", "*", "UUID", ")", "decodeHashLike", "(", "t", "[", "]", "byte", ")", "(", "err", "error", ")", "{", "src", ":=", "t", "[", ":", "]", "\n", "dst", ":=", "u", "[", ":", "]", "\n", "if", "_", ",", "err", "=", "hex", ".", "Decode", "(", "dst", ",", "src", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "\n", "}" ]
// decodeHashLike decodes UUID string in format // "6ba7b8109dad11d180b400c04fd430c8".
[ "decodeHashLike", "decodes", "UUID", "string", "in", "format", "6ba7b8109dad11d180b400c04fd430c8", "." ]
b2ce2384e17bbe0c6d34077efa39dbab3e09123b
https://github.com/satori/go.uuid/blob/b2ce2384e17bbe0c6d34077efa39dbab3e09123b/codec.go#L138-L146
train
satori/go.uuid
codec.go
decodePlain
func (u *UUID) decodePlain(t []byte) (err error) { switch len(t) { case 32: return u.decodeHashLike(t) case 36: return u.decodeCanonical(t) default: return fmt.Errorf("uuid: incorrrect UUID length: %s", t) } }
go
func (u *UUID) decodePlain(t []byte) (err error) { switch len(t) { case 32: return u.decodeHashLike(t) case 36: return u.decodeCanonical(t) default: return fmt.Errorf("uuid: incorrrect UUID length: %s", t) } }
[ "func", "(", "u", "*", "UUID", ")", "decodePlain", "(", "t", "[", "]", "byte", ")", "(", "err", "error", ")", "{", "switch", "len", "(", "t", ")", "{", "case", "32", ":", "return", "u", ".", "decodeHashLike", "(", "t", ")", "\n", "case", "36", ":", "return", "u", ".", "decodeCanonical", "(", "t", ")", "\n", "default", ":", "return", "fmt", ".", "Errorf", "(", "\"uuid: incorrrect UUID length: %s\"", ",", "t", ")", "\n", "}", "\n", "}" ]
// decodePlain decodes UUID string in canonical format // "6ba7b810-9dad-11d1-80b4-00c04fd430c8" or in hash-like format // "6ba7b8109dad11d180b400c04fd430c8".
[ "decodePlain", "decodes", "UUID", "string", "in", "canonical", "format", "6ba7b810", "-", "9dad", "-", "11d1", "-", "80b4", "-", "00c04fd430c8", "or", "in", "hash", "-", "like", "format", "6ba7b8109dad11d180b400c04fd430c8", "." ]
b2ce2384e17bbe0c6d34077efa39dbab3e09123b
https://github.com/satori/go.uuid/blob/b2ce2384e17bbe0c6d34077efa39dbab3e09123b/codec.go#L179-L188
train
satori/go.uuid
codec.go
UnmarshalBinary
func (u *UUID) UnmarshalBinary(data []byte) (err error) { if len(data) != Size { err = fmt.Errorf("uuid: UUID must be exactly 16 bytes long, got %d bytes", len(data)) return } copy(u[:], data) return }
go
func (u *UUID) UnmarshalBinary(data []byte) (err error) { if len(data) != Size { err = fmt.Errorf("uuid: UUID must be exactly 16 bytes long, got %d bytes", len(data)) return } copy(u[:], data) return }
[ "func", "(", "u", "*", "UUID", ")", "UnmarshalBinary", "(", "data", "[", "]", "byte", ")", "(", "err", "error", ")", "{", "if", "len", "(", "data", ")", "!=", "Size", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"uuid: UUID must be exactly 16 bytes long, got %d bytes\"", ",", "len", "(", "data", ")", ")", "\n", "return", "\n", "}", "\n", "copy", "(", "u", "[", ":", "]", ",", "data", ")", "\n", "return", "\n", "}" ]
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. // It will return error if the slice isn't 16 bytes long.
[ "UnmarshalBinary", "implements", "the", "encoding", ".", "BinaryUnmarshaler", "interface", ".", "It", "will", "return", "error", "if", "the", "slice", "isn", "t", "16", "bytes", "long", "." ]
b2ce2384e17bbe0c6d34077efa39dbab3e09123b
https://github.com/satori/go.uuid/blob/b2ce2384e17bbe0c6d34077efa39dbab3e09123b/codec.go#L198-L206
train
satori/go.uuid
generator.go
getClockSequence
func (g *rfc4122Generator) getClockSequence() (uint64, uint16, error) { var err error g.clockSequenceOnce.Do(func() { buf := make([]byte, 2) if _, err = io.ReadFull(g.rand, buf); err != nil { return } g.clockSequence = binary.BigEndian.Uint16(buf) }) if err != nil { return 0, 0, err } g.storageMutex.Lock() defer g.storageMutex.Unlock() timeNow := g.getEpoch() // Clock didn't change since last UUID generation. // Should increase clock sequence. if timeNow <= g.lastTime { g.clockSequence++ } g.lastTime = timeNow return timeNow, g.clockSequence, nil }
go
func (g *rfc4122Generator) getClockSequence() (uint64, uint16, error) { var err error g.clockSequenceOnce.Do(func() { buf := make([]byte, 2) if _, err = io.ReadFull(g.rand, buf); err != nil { return } g.clockSequence = binary.BigEndian.Uint16(buf) }) if err != nil { return 0, 0, err } g.storageMutex.Lock() defer g.storageMutex.Unlock() timeNow := g.getEpoch() // Clock didn't change since last UUID generation. // Should increase clock sequence. if timeNow <= g.lastTime { g.clockSequence++ } g.lastTime = timeNow return timeNow, g.clockSequence, nil }
[ "func", "(", "g", "*", "rfc4122Generator", ")", "getClockSequence", "(", ")", "(", "uint64", ",", "uint16", ",", "error", ")", "{", "var", "err", "error", "\n", "g", ".", "clockSequenceOnce", ".", "Do", "(", "func", "(", ")", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "2", ")", "\n", "if", "_", ",", "err", "=", "io", ".", "ReadFull", "(", "g", ".", "rand", ",", "buf", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "g", ".", "clockSequence", "=", "binary", ".", "BigEndian", ".", "Uint16", "(", "buf", ")", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "0", ",", "err", "\n", "}", "\n", "g", ".", "storageMutex", ".", "Lock", "(", ")", "\n", "defer", "g", ".", "storageMutex", ".", "Unlock", "(", ")", "\n", "timeNow", ":=", "g", ".", "getEpoch", "(", ")", "\n", "if", "timeNow", "<=", "g", ".", "lastTime", "{", "g", ".", "clockSequence", "++", "\n", "}", "\n", "g", ".", "lastTime", "=", "timeNow", "\n", "return", "timeNow", ",", "g", ".", "clockSequence", ",", "nil", "\n", "}" ]
// Returns epoch and clock sequence.
[ "Returns", "epoch", "and", "clock", "sequence", "." ]
b2ce2384e17bbe0c6d34077efa39dbab3e09123b
https://github.com/satori/go.uuid/blob/b2ce2384e17bbe0c6d34077efa39dbab3e09123b/generator.go#L187-L212
train
satori/go.uuid
uuid.go
Equal
func Equal(u1 UUID, u2 UUID) bool { return bytes.Equal(u1[:], u2[:]) }
go
func Equal(u1 UUID, u2 UUID) bool { return bytes.Equal(u1[:], u2[:]) }
[ "func", "Equal", "(", "u1", "UUID", ",", "u2", "UUID", ")", "bool", "{", "return", "bytes", ".", "Equal", "(", "u1", "[", ":", "]", ",", "u2", "[", ":", "]", ")", "\n", "}" ]
// Equal returns true if u1 and u2 equals, otherwise returns false.
[ "Equal", "returns", "true", "if", "u1", "and", "u2", "equals", "otherwise", "returns", "false", "." ]
b2ce2384e17bbe0c6d34077efa39dbab3e09123b
https://github.com/satori/go.uuid/blob/b2ce2384e17bbe0c6d34077efa39dbab3e09123b/uuid.go#L83-L85
train
satori/go.uuid
uuid.go
SetVariant
func (u *UUID) SetVariant(v byte) { switch v { case VariantNCS: u[8] = (u[8]&(0xff>>1) | (0x00 << 7)) case VariantRFC4122: u[8] = (u[8]&(0xff>>2) | (0x02 << 6)) case VariantMicrosoft: u[8] = (u[8]&(0xff>>3) | (0x06 << 5)) case VariantFuture: fallthrough default: u[8] = (u[8]&(0xff>>3) | (0x07 << 5)) } }
go
func (u *UUID) SetVariant(v byte) { switch v { case VariantNCS: u[8] = (u[8]&(0xff>>1) | (0x00 << 7)) case VariantRFC4122: u[8] = (u[8]&(0xff>>2) | (0x02 << 6)) case VariantMicrosoft: u[8] = (u[8]&(0xff>>3) | (0x06 << 5)) case VariantFuture: fallthrough default: u[8] = (u[8]&(0xff>>3) | (0x07 << 5)) } }
[ "func", "(", "u", "*", "UUID", ")", "SetVariant", "(", "v", "byte", ")", "{", "switch", "v", "{", "case", "VariantNCS", ":", "u", "[", "8", "]", "=", "(", "u", "[", "8", "]", "&", "(", "0xff", ">>", "1", ")", "|", "(", "0x00", "<<", "7", ")", ")", "\n", "case", "VariantRFC4122", ":", "u", "[", "8", "]", "=", "(", "u", "[", "8", "]", "&", "(", "0xff", ">>", "2", ")", "|", "(", "0x02", "<<", "6", ")", ")", "\n", "case", "VariantMicrosoft", ":", "u", "[", "8", "]", "=", "(", "u", "[", "8", "]", "&", "(", "0xff", ">>", "3", ")", "|", "(", "0x06", "<<", "5", ")", ")", "\n", "case", "VariantFuture", ":", "fallthrough", "\n", "default", ":", "u", "[", "8", "]", "=", "(", "u", "[", "8", "]", "&", "(", "0xff", ">>", "3", ")", "|", "(", "0x07", "<<", "5", ")", ")", "\n", "}", "\n", "}" ]
// SetVariant sets variant bits.
[ "SetVariant", "sets", "variant", "bits", "." ]
b2ce2384e17bbe0c6d34077efa39dbab3e09123b
https://github.com/satori/go.uuid/blob/b2ce2384e17bbe0c6d34077efa39dbab3e09123b/uuid.go#L137-L150
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgAggregateByAggfnoid
func PgAggregateByAggfnoid(db XODB, aggfnoid pgtypes.Regproc) (*PgAggregate, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, ctid, aggfnoid, aggkind, aggnumdirectargs, aggtransfn, aggfinalfn, aggmtransfn, aggminvtransfn, aggmfinalfn, aggfinalextra, aggmfinalextra, aggsortop, aggtranstype, aggtransspace, aggmtranstype, aggmtransspace, agginitval, aggminitval ` + `FROM pg_catalog.pg_aggregate ` + `WHERE aggfnoid = $1` // run query XOLog(sqlstr, aggfnoid) pa := PgAggregate{} err = db.QueryRow(sqlstr, aggfnoid).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Ctid, &pa.Aggfnoid, &pa.Aggkind, &pa.Aggnumdirectargs, &pa.Aggtransfn, &pa.Aggfinalfn, &pa.Aggmtransfn, &pa.Aggminvtransfn, &pa.Aggmfinalfn, &pa.Aggfinalextra, &pa.Aggmfinalextra, &pa.Aggsortop, &pa.Aggtranstype, &pa.Aggtransspace, &pa.Aggmtranstype, &pa.Aggmtransspace, &pa.Agginitval, &pa.Aggminitval) if err != nil { return nil, err } return &pa, nil }
go
func PgAggregateByAggfnoid(db XODB, aggfnoid pgtypes.Regproc) (*PgAggregate, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, ctid, aggfnoid, aggkind, aggnumdirectargs, aggtransfn, aggfinalfn, aggmtransfn, aggminvtransfn, aggmfinalfn, aggfinalextra, aggmfinalextra, aggsortop, aggtranstype, aggtransspace, aggmtranstype, aggmtransspace, agginitval, aggminitval ` + `FROM pg_catalog.pg_aggregate ` + `WHERE aggfnoid = $1` // run query XOLog(sqlstr, aggfnoid) pa := PgAggregate{} err = db.QueryRow(sqlstr, aggfnoid).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Ctid, &pa.Aggfnoid, &pa.Aggkind, &pa.Aggnumdirectargs, &pa.Aggtransfn, &pa.Aggfinalfn, &pa.Aggmtransfn, &pa.Aggminvtransfn, &pa.Aggmfinalfn, &pa.Aggfinalextra, &pa.Aggmfinalextra, &pa.Aggsortop, &pa.Aggtranstype, &pa.Aggtransspace, &pa.Aggmtranstype, &pa.Aggmtransspace, &pa.Agginitval, &pa.Aggminitval) if err != nil { return nil, err } return &pa, nil }
[ "func", "PgAggregateByAggfnoid", "(", "db", "XODB", ",", "aggfnoid", "pgtypes", ".", "Regproc", ")", "(", "*", "PgAggregate", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, ctid, aggfnoid, aggkind, aggnumdirectargs, aggtransfn, aggfinalfn, aggmtransfn, aggminvtransfn, aggmfinalfn, aggfinalextra, aggmfinalextra, aggsortop, aggtranstype, aggtransspace, aggmtranstype, aggmtransspace, agginitval, aggminitval `", "+", "`FROM pg_catalog.pg_aggregate `", "+", "`WHERE aggfnoid = $1`", "\n", "XOLog", "(", "sqlstr", ",", "aggfnoid", ")", "\n", "pa", ":=", "PgAggregate", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "aggfnoid", ")", ".", "Scan", "(", "&", "pa", ".", "Tableoid", ",", "&", "pa", ".", "Cmax", ",", "&", "pa", ".", "Xmax", ",", "&", "pa", ".", "Cmin", ",", "&", "pa", ".", "Xmin", ",", "&", "pa", ".", "Ctid", ",", "&", "pa", ".", "Aggfnoid", ",", "&", "pa", ".", "Aggkind", ",", "&", "pa", ".", "Aggnumdirectargs", ",", "&", "pa", ".", "Aggtransfn", ",", "&", "pa", ".", "Aggfinalfn", ",", "&", "pa", ".", "Aggmtransfn", ",", "&", "pa", ".", "Aggminvtransfn", ",", "&", "pa", ".", "Aggmfinalfn", ",", "&", "pa", ".", "Aggfinalextra", ",", "&", "pa", ".", "Aggmfinalextra", ",", "&", "pa", ".", "Aggsortop", ",", "&", "pa", ".", "Aggtranstype", ",", "&", "pa", ".", "Aggtransspace", ",", "&", "pa", ".", "Aggmtranstype", ",", "&", "pa", ".", "Aggmtransspace", ",", "&", "pa", ".", "Agginitval", ",", "&", "pa", ".", "Aggminitval", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pa", ",", "nil", "\n", "}" ]
// PgAggregateByAggfnoid retrieves a row from 'pg_catalog.pg_aggregate' as a PgAggregate. // // Generated from index 'pg_aggregate_fnoid_index'.
[ "PgAggregateByAggfnoid", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_aggregate", "as", "a", "PgAggregate", ".", "Generated", "from", "index", "pg_aggregate_fnoid_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L41744-L41763
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgAmByAmname
func PgAmByAmname(db XODB, amname pgtypes.Name) (*PgAm, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, amname, amstrategies, amsupport, amcanorder, amcanorderbyop, amcanbackward, amcanunique, amcanmulticol, amoptionalkey, amsearcharray, amsearchnulls, amstorage, amclusterable, ampredlocks, amkeytype, aminsert, ambeginscan, amgettuple, amgetbitmap, amrescan, amendscan, ammarkpos, amrestrpos, ambuild, ambuildempty, ambulkdelete, amvacuumcleanup, amcanreturn, amcostestimate, amoptions ` + `FROM pg_catalog.pg_am ` + `WHERE amname = $1` // run query XOLog(sqlstr, amname) pa := PgAm{} err = db.QueryRow(sqlstr, amname).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Amname, &pa.Amstrategies, &pa.Amsupport, &pa.Amcanorder, &pa.Amcanorderbyop, &pa.Amcanbackward, &pa.Amcanunique, &pa.Amcanmulticol, &pa.Amoptionalkey, &pa.Amsearcharray, &pa.Amsearchnulls, &pa.Amstorage, &pa.Amclusterable, &pa.Ampredlocks, &pa.Amkeytype, &pa.Aminsert, &pa.Ambeginscan, &pa.Amgettuple, &pa.Amgetbitmap, &pa.Amrescan, &pa.Amendscan, &pa.Ammarkpos, &pa.Amrestrpos, &pa.Ambuild, &pa.Ambuildempty, &pa.Ambulkdelete, &pa.Amvacuumcleanup, &pa.Amcanreturn, &pa.Amcostestimate, &pa.Amoptions) if err != nil { return nil, err } return &pa, nil }
go
func PgAmByAmname(db XODB, amname pgtypes.Name) (*PgAm, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, amname, amstrategies, amsupport, amcanorder, amcanorderbyop, amcanbackward, amcanunique, amcanmulticol, amoptionalkey, amsearcharray, amsearchnulls, amstorage, amclusterable, ampredlocks, amkeytype, aminsert, ambeginscan, amgettuple, amgetbitmap, amrescan, amendscan, ammarkpos, amrestrpos, ambuild, ambuildempty, ambulkdelete, amvacuumcleanup, amcanreturn, amcostestimate, amoptions ` + `FROM pg_catalog.pg_am ` + `WHERE amname = $1` // run query XOLog(sqlstr, amname) pa := PgAm{} err = db.QueryRow(sqlstr, amname).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Amname, &pa.Amstrategies, &pa.Amsupport, &pa.Amcanorder, &pa.Amcanorderbyop, &pa.Amcanbackward, &pa.Amcanunique, &pa.Amcanmulticol, &pa.Amoptionalkey, &pa.Amsearcharray, &pa.Amsearchnulls, &pa.Amstorage, &pa.Amclusterable, &pa.Ampredlocks, &pa.Amkeytype, &pa.Aminsert, &pa.Ambeginscan, &pa.Amgettuple, &pa.Amgetbitmap, &pa.Amrescan, &pa.Amendscan, &pa.Ammarkpos, &pa.Amrestrpos, &pa.Ambuild, &pa.Ambuildempty, &pa.Ambulkdelete, &pa.Amvacuumcleanup, &pa.Amcanreturn, &pa.Amcostestimate, &pa.Amoptions) if err != nil { return nil, err } return &pa, nil }
[ "func", "PgAmByAmname", "(", "db", "XODB", ",", "amname", "pgtypes", ".", "Name", ")", "(", "*", "PgAm", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, amname, amstrategies, amsupport, amcanorder, amcanorderbyop, amcanbackward, amcanunique, amcanmulticol, amoptionalkey, amsearcharray, amsearchnulls, amstorage, amclusterable, ampredlocks, amkeytype, aminsert, ambeginscan, amgettuple, amgetbitmap, amrescan, amendscan, ammarkpos, amrestrpos, ambuild, ambuildempty, ambulkdelete, amvacuumcleanup, amcanreturn, amcostestimate, amoptions `", "+", "`FROM pg_catalog.pg_am `", "+", "`WHERE amname = $1`", "\n", "XOLog", "(", "sqlstr", ",", "amname", ")", "\n", "pa", ":=", "PgAm", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "amname", ")", ".", "Scan", "(", "&", "pa", ".", "Tableoid", ",", "&", "pa", ".", "Cmax", ",", "&", "pa", ".", "Xmax", ",", "&", "pa", ".", "Cmin", ",", "&", "pa", ".", "Xmin", ",", "&", "pa", ".", "Oid", ",", "&", "pa", ".", "Ctid", ",", "&", "pa", ".", "Amname", ",", "&", "pa", ".", "Amstrategies", ",", "&", "pa", ".", "Amsupport", ",", "&", "pa", ".", "Amcanorder", ",", "&", "pa", ".", "Amcanorderbyop", ",", "&", "pa", ".", "Amcanbackward", ",", "&", "pa", ".", "Amcanunique", ",", "&", "pa", ".", "Amcanmulticol", ",", "&", "pa", ".", "Amoptionalkey", ",", "&", "pa", ".", "Amsearcharray", ",", "&", "pa", ".", "Amsearchnulls", ",", "&", "pa", ".", "Amstorage", ",", "&", "pa", ".", "Amclusterable", ",", "&", "pa", ".", "Ampredlocks", ",", "&", "pa", ".", "Amkeytype", ",", "&", "pa", ".", "Aminsert", ",", "&", "pa", ".", "Ambeginscan", ",", "&", "pa", ".", "Amgettuple", ",", "&", "pa", ".", "Amgetbitmap", ",", "&", "pa", ".", "Amrescan", ",", "&", "pa", ".", "Amendscan", ",", "&", "pa", ".", "Ammarkpos", ",", "&", "pa", ".", "Amrestrpos", ",", "&", "pa", ".", "Ambuild", ",", "&", "pa", ".", "Ambuildempty", ",", "&", "pa", ".", "Ambulkdelete", ",", "&", "pa", ".", "Amvacuumcleanup", ",", "&", "pa", ".", "Amcanreturn", ",", "&", "pa", ".", "Amcostestimate", ",", "&", "pa", ".", "Amoptions", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pa", ",", "nil", "\n", "}" ]
// PgAmByAmname retrieves a row from 'pg_catalog.pg_am' as a PgAm. // // Generated from index 'pg_am_name_index'.
[ "PgAmByAmname", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_am", "as", "a", "PgAm", ".", "Generated", "from", "index", "pg_am_name_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L41768-L41787
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgAmopByAmopfamilyAmoplefttypeAmoprighttypeAmopstrategy
func PgAmopByAmopfamilyAmoplefttypeAmoprighttypeAmopstrategy(db XODB, amopfamily pgtypes.Oid, amoplefttype pgtypes.Oid, amoprighttype pgtypes.Oid, amopstrategy int16) (*PgAmop, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, amopfamily, amoplefttype, amoprighttype, amopstrategy, amoppurpose, amopopr, amopmethod, amopsortfamily ` + `FROM pg_catalog.pg_amop ` + `WHERE amopfamily = $1 AND amoplefttype = $2 AND amoprighttype = $3 AND amopstrategy = $4` // run query XOLog(sqlstr, amopfamily, amoplefttype, amoprighttype, amopstrategy) pa := PgAmop{} err = db.QueryRow(sqlstr, amopfamily, amoplefttype, amoprighttype, amopstrategy).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Amopfamily, &pa.Amoplefttype, &pa.Amoprighttype, &pa.Amopstrategy, &pa.Amoppurpose, &pa.Amopopr, &pa.Amopmethod, &pa.Amopsortfamily) if err != nil { return nil, err } return &pa, nil }
go
func PgAmopByAmopfamilyAmoplefttypeAmoprighttypeAmopstrategy(db XODB, amopfamily pgtypes.Oid, amoplefttype pgtypes.Oid, amoprighttype pgtypes.Oid, amopstrategy int16) (*PgAmop, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, amopfamily, amoplefttype, amoprighttype, amopstrategy, amoppurpose, amopopr, amopmethod, amopsortfamily ` + `FROM pg_catalog.pg_amop ` + `WHERE amopfamily = $1 AND amoplefttype = $2 AND amoprighttype = $3 AND amopstrategy = $4` // run query XOLog(sqlstr, amopfamily, amoplefttype, amoprighttype, amopstrategy) pa := PgAmop{} err = db.QueryRow(sqlstr, amopfamily, amoplefttype, amoprighttype, amopstrategy).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Amopfamily, &pa.Amoplefttype, &pa.Amoprighttype, &pa.Amopstrategy, &pa.Amoppurpose, &pa.Amopopr, &pa.Amopmethod, &pa.Amopsortfamily) if err != nil { return nil, err } return &pa, nil }
[ "func", "PgAmopByAmopfamilyAmoplefttypeAmoprighttypeAmopstrategy", "(", "db", "XODB", ",", "amopfamily", "pgtypes", ".", "Oid", ",", "amoplefttype", "pgtypes", ".", "Oid", ",", "amoprighttype", "pgtypes", ".", "Oid", ",", "amopstrategy", "int16", ")", "(", "*", "PgAmop", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, amopfamily, amoplefttype, amoprighttype, amopstrategy, amoppurpose, amopopr, amopmethod, amopsortfamily `", "+", "`FROM pg_catalog.pg_amop `", "+", "`WHERE amopfamily = $1 AND amoplefttype = $2 AND amoprighttype = $3 AND amopstrategy = $4`", "\n", "XOLog", "(", "sqlstr", ",", "amopfamily", ",", "amoplefttype", ",", "amoprighttype", ",", "amopstrategy", ")", "\n", "pa", ":=", "PgAmop", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "amopfamily", ",", "amoplefttype", ",", "amoprighttype", ",", "amopstrategy", ")", ".", "Scan", "(", "&", "pa", ".", "Tableoid", ",", "&", "pa", ".", "Cmax", ",", "&", "pa", ".", "Xmax", ",", "&", "pa", ".", "Cmin", ",", "&", "pa", ".", "Xmin", ",", "&", "pa", ".", "Oid", ",", "&", "pa", ".", "Ctid", ",", "&", "pa", ".", "Amopfamily", ",", "&", "pa", ".", "Amoplefttype", ",", "&", "pa", ".", "Amoprighttype", ",", "&", "pa", ".", "Amopstrategy", ",", "&", "pa", ".", "Amoppurpose", ",", "&", "pa", ".", "Amopopr", ",", "&", "pa", ".", "Amopmethod", ",", "&", "pa", ".", "Amopsortfamily", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pa", ",", "nil", "\n", "}" ]
// PgAmopByAmopfamilyAmoplefttypeAmoprighttypeAmopstrategy retrieves a row from 'pg_catalog.pg_amop' as a PgAmop. // // Generated from index 'pg_amop_fam_strat_index'.
[ "PgAmopByAmopfamilyAmoplefttypeAmoprighttypeAmopstrategy", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_amop", "as", "a", "PgAmop", ".", "Generated", "from", "index", "pg_amop_fam_strat_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L41816-L41835
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgAmopByOid
func PgAmopByOid(db XODB, oid pgtypes.Oid) (*PgAmop, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, amopfamily, amoplefttype, amoprighttype, amopstrategy, amoppurpose, amopopr, amopmethod, amopsortfamily ` + `FROM pg_catalog.pg_amop ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pa := PgAmop{} err = db.QueryRow(sqlstr, oid).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Amopfamily, &pa.Amoplefttype, &pa.Amoprighttype, &pa.Amopstrategy, &pa.Amoppurpose, &pa.Amopopr, &pa.Amopmethod, &pa.Amopsortfamily) if err != nil { return nil, err } return &pa, nil }
go
func PgAmopByOid(db XODB, oid pgtypes.Oid) (*PgAmop, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, amopfamily, amoplefttype, amoprighttype, amopstrategy, amoppurpose, amopopr, amopmethod, amopsortfamily ` + `FROM pg_catalog.pg_amop ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pa := PgAmop{} err = db.QueryRow(sqlstr, oid).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Amopfamily, &pa.Amoplefttype, &pa.Amoprighttype, &pa.Amopstrategy, &pa.Amoppurpose, &pa.Amopopr, &pa.Amopmethod, &pa.Amopsortfamily) if err != nil { return nil, err } return &pa, nil }
[ "func", "PgAmopByOid", "(", "db", "XODB", ",", "oid", "pgtypes", ".", "Oid", ")", "(", "*", "PgAmop", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, amopfamily, amoplefttype, amoprighttype, amopstrategy, amoppurpose, amopopr, amopmethod, amopsortfamily `", "+", "`FROM pg_catalog.pg_amop `", "+", "`WHERE oid = $1`", "\n", "XOLog", "(", "sqlstr", ",", "oid", ")", "\n", "pa", ":=", "PgAmop", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "oid", ")", ".", "Scan", "(", "&", "pa", ".", "Tableoid", ",", "&", "pa", ".", "Cmax", ",", "&", "pa", ".", "Xmax", ",", "&", "pa", ".", "Cmin", ",", "&", "pa", ".", "Xmin", ",", "&", "pa", ".", "Oid", ",", "&", "pa", ".", "Ctid", ",", "&", "pa", ".", "Amopfamily", ",", "&", "pa", ".", "Amoplefttype", ",", "&", "pa", ".", "Amoprighttype", ",", "&", "pa", ".", "Amopstrategy", ",", "&", "pa", ".", "Amoppurpose", ",", "&", "pa", ".", "Amopopr", ",", "&", "pa", ".", "Amopmethod", ",", "&", "pa", ".", "Amopsortfamily", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pa", ",", "nil", "\n", "}" ]
// PgAmopByOid retrieves a row from 'pg_catalog.pg_amop' as a PgAmop. // // Generated from index 'pg_amop_oid_index'.
[ "PgAmopByOid", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_amop", "as", "a", "PgAmop", ".", "Generated", "from", "index", "pg_amop_oid_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L41840-L41859
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgAmopByAmopoprAmoppurposeAmopfamily
func PgAmopByAmopoprAmoppurposeAmopfamily(db XODB, amopopr pgtypes.Oid, amoppurpose uint8, amopfamily pgtypes.Oid) (*PgAmop, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, amopfamily, amoplefttype, amoprighttype, amopstrategy, amoppurpose, amopopr, amopmethod, amopsortfamily ` + `FROM pg_catalog.pg_amop ` + `WHERE amopopr = $1 AND amoppurpose = $2 AND amopfamily = $3` // run query XOLog(sqlstr, amopopr, amoppurpose, amopfamily) pa := PgAmop{} err = db.QueryRow(sqlstr, amopopr, amoppurpose, amopfamily).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Amopfamily, &pa.Amoplefttype, &pa.Amoprighttype, &pa.Amopstrategy, &pa.Amoppurpose, &pa.Amopopr, &pa.Amopmethod, &pa.Amopsortfamily) if err != nil { return nil, err } return &pa, nil }
go
func PgAmopByAmopoprAmoppurposeAmopfamily(db XODB, amopopr pgtypes.Oid, amoppurpose uint8, amopfamily pgtypes.Oid) (*PgAmop, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, amopfamily, amoplefttype, amoprighttype, amopstrategy, amoppurpose, amopopr, amopmethod, amopsortfamily ` + `FROM pg_catalog.pg_amop ` + `WHERE amopopr = $1 AND amoppurpose = $2 AND amopfamily = $3` // run query XOLog(sqlstr, amopopr, amoppurpose, amopfamily) pa := PgAmop{} err = db.QueryRow(sqlstr, amopopr, amoppurpose, amopfamily).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Amopfamily, &pa.Amoplefttype, &pa.Amoprighttype, &pa.Amopstrategy, &pa.Amoppurpose, &pa.Amopopr, &pa.Amopmethod, &pa.Amopsortfamily) if err != nil { return nil, err } return &pa, nil }
[ "func", "PgAmopByAmopoprAmoppurposeAmopfamily", "(", "db", "XODB", ",", "amopopr", "pgtypes", ".", "Oid", ",", "amoppurpose", "uint8", ",", "amopfamily", "pgtypes", ".", "Oid", ")", "(", "*", "PgAmop", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, amopfamily, amoplefttype, amoprighttype, amopstrategy, amoppurpose, amopopr, amopmethod, amopsortfamily `", "+", "`FROM pg_catalog.pg_amop `", "+", "`WHERE amopopr = $1 AND amoppurpose = $2 AND amopfamily = $3`", "\n", "XOLog", "(", "sqlstr", ",", "amopopr", ",", "amoppurpose", ",", "amopfamily", ")", "\n", "pa", ":=", "PgAmop", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "amopopr", ",", "amoppurpose", ",", "amopfamily", ")", ".", "Scan", "(", "&", "pa", ".", "Tableoid", ",", "&", "pa", ".", "Cmax", ",", "&", "pa", ".", "Xmax", ",", "&", "pa", ".", "Cmin", ",", "&", "pa", ".", "Xmin", ",", "&", "pa", ".", "Oid", ",", "&", "pa", ".", "Ctid", ",", "&", "pa", ".", "Amopfamily", ",", "&", "pa", ".", "Amoplefttype", ",", "&", "pa", ".", "Amoprighttype", ",", "&", "pa", ".", "Amopstrategy", ",", "&", "pa", ".", "Amoppurpose", ",", "&", "pa", ".", "Amopopr", ",", "&", "pa", ".", "Amopmethod", ",", "&", "pa", ".", "Amopsortfamily", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pa", ",", "nil", "\n", "}" ]
// PgAmopByAmopoprAmoppurposeAmopfamily retrieves a row from 'pg_catalog.pg_amop' as a PgAmop. // // Generated from index 'pg_amop_opr_fam_index'.
[ "PgAmopByAmopoprAmoppurposeAmopfamily", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_amop", "as", "a", "PgAmop", ".", "Generated", "from", "index", "pg_amop_opr_fam_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L41864-L41883
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgAmprocByAmprocfamilyAmproclefttypeAmprocrighttypeAmprocnum
func PgAmprocByAmprocfamilyAmproclefttypeAmprocrighttypeAmprocnum(db XODB, amprocfamily pgtypes.Oid, amproclefttype pgtypes.Oid, amprocrighttype pgtypes.Oid, amprocnum int16) (*PgAmproc, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, amprocfamily, amproclefttype, amprocrighttype, amprocnum, amproc ` + `FROM pg_catalog.pg_amproc ` + `WHERE amprocfamily = $1 AND amproclefttype = $2 AND amprocrighttype = $3 AND amprocnum = $4` // run query XOLog(sqlstr, amprocfamily, amproclefttype, amprocrighttype, amprocnum) pa := PgAmproc{} err = db.QueryRow(sqlstr, amprocfamily, amproclefttype, amprocrighttype, amprocnum).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Amprocfamily, &pa.Amproclefttype, &pa.Amprocrighttype, &pa.Amprocnum, &pa.Amproc) if err != nil { return nil, err } return &pa, nil }
go
func PgAmprocByAmprocfamilyAmproclefttypeAmprocrighttypeAmprocnum(db XODB, amprocfamily pgtypes.Oid, amproclefttype pgtypes.Oid, amprocrighttype pgtypes.Oid, amprocnum int16) (*PgAmproc, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, amprocfamily, amproclefttype, amprocrighttype, amprocnum, amproc ` + `FROM pg_catalog.pg_amproc ` + `WHERE amprocfamily = $1 AND amproclefttype = $2 AND amprocrighttype = $3 AND amprocnum = $4` // run query XOLog(sqlstr, amprocfamily, amproclefttype, amprocrighttype, amprocnum) pa := PgAmproc{} err = db.QueryRow(sqlstr, amprocfamily, amproclefttype, amprocrighttype, amprocnum).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Amprocfamily, &pa.Amproclefttype, &pa.Amprocrighttype, &pa.Amprocnum, &pa.Amproc) if err != nil { return nil, err } return &pa, nil }
[ "func", "PgAmprocByAmprocfamilyAmproclefttypeAmprocrighttypeAmprocnum", "(", "db", "XODB", ",", "amprocfamily", "pgtypes", ".", "Oid", ",", "amproclefttype", "pgtypes", ".", "Oid", ",", "amprocrighttype", "pgtypes", ".", "Oid", ",", "amprocnum", "int16", ")", "(", "*", "PgAmproc", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, amprocfamily, amproclefttype, amprocrighttype, amprocnum, amproc `", "+", "`FROM pg_catalog.pg_amproc `", "+", "`WHERE amprocfamily = $1 AND amproclefttype = $2 AND amprocrighttype = $3 AND amprocnum = $4`", "\n", "XOLog", "(", "sqlstr", ",", "amprocfamily", ",", "amproclefttype", ",", "amprocrighttype", ",", "amprocnum", ")", "\n", "pa", ":=", "PgAmproc", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "amprocfamily", ",", "amproclefttype", ",", "amprocrighttype", ",", "amprocnum", ")", ".", "Scan", "(", "&", "pa", ".", "Tableoid", ",", "&", "pa", ".", "Cmax", ",", "&", "pa", ".", "Xmax", ",", "&", "pa", ".", "Cmin", ",", "&", "pa", ".", "Xmin", ",", "&", "pa", ".", "Oid", ",", "&", "pa", ".", "Ctid", ",", "&", "pa", ".", "Amprocfamily", ",", "&", "pa", ".", "Amproclefttype", ",", "&", "pa", ".", "Amprocrighttype", ",", "&", "pa", ".", "Amprocnum", ",", "&", "pa", ".", "Amproc", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pa", ",", "nil", "\n", "}" ]
// PgAmprocByAmprocfamilyAmproclefttypeAmprocrighttypeAmprocnum retrieves a row from 'pg_catalog.pg_amproc' as a PgAmproc. // // Generated from index 'pg_amproc_fam_proc_index'.
[ "PgAmprocByAmprocfamilyAmproclefttypeAmprocrighttypeAmprocnum", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_amproc", "as", "a", "PgAmproc", ".", "Generated", "from", "index", "pg_amproc_fam_proc_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L41888-L41907
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgAmprocByOid
func PgAmprocByOid(db XODB, oid pgtypes.Oid) (*PgAmproc, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, amprocfamily, amproclefttype, amprocrighttype, amprocnum, amproc ` + `FROM pg_catalog.pg_amproc ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pa := PgAmproc{} err = db.QueryRow(sqlstr, oid).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Amprocfamily, &pa.Amproclefttype, &pa.Amprocrighttype, &pa.Amprocnum, &pa.Amproc) if err != nil { return nil, err } return &pa, nil }
go
func PgAmprocByOid(db XODB, oid pgtypes.Oid) (*PgAmproc, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, amprocfamily, amproclefttype, amprocrighttype, amprocnum, amproc ` + `FROM pg_catalog.pg_amproc ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pa := PgAmproc{} err = db.QueryRow(sqlstr, oid).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Amprocfamily, &pa.Amproclefttype, &pa.Amprocrighttype, &pa.Amprocnum, &pa.Amproc) if err != nil { return nil, err } return &pa, nil }
[ "func", "PgAmprocByOid", "(", "db", "XODB", ",", "oid", "pgtypes", ".", "Oid", ")", "(", "*", "PgAmproc", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, amprocfamily, amproclefttype, amprocrighttype, amprocnum, amproc `", "+", "`FROM pg_catalog.pg_amproc `", "+", "`WHERE oid = $1`", "\n", "XOLog", "(", "sqlstr", ",", "oid", ")", "\n", "pa", ":=", "PgAmproc", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "oid", ")", ".", "Scan", "(", "&", "pa", ".", "Tableoid", ",", "&", "pa", ".", "Cmax", ",", "&", "pa", ".", "Xmax", ",", "&", "pa", ".", "Cmin", ",", "&", "pa", ".", "Xmin", ",", "&", "pa", ".", "Oid", ",", "&", "pa", ".", "Ctid", ",", "&", "pa", ".", "Amprocfamily", ",", "&", "pa", ".", "Amproclefttype", ",", "&", "pa", ".", "Amprocrighttype", ",", "&", "pa", ".", "Amprocnum", ",", "&", "pa", ".", "Amproc", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pa", ",", "nil", "\n", "}" ]
// PgAmprocByOid retrieves a row from 'pg_catalog.pg_amproc' as a PgAmproc. // // Generated from index 'pg_amproc_oid_index'.
[ "PgAmprocByOid", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_amproc", "as", "a", "PgAmproc", ".", "Generated", "from", "index", "pg_amproc_oid_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L41912-L41931
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgAttrdefByAdrelidAdnum
func PgAttrdefByAdrelidAdnum(db XODB, adrelid pgtypes.Oid, adnum int16) (*PgAttrdef, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, adrelid, adnum, adbin, adsrc ` + `FROM pg_catalog.pg_attrdef ` + `WHERE adrelid = $1 AND adnum = $2` // run query XOLog(sqlstr, adrelid, adnum) pa := PgAttrdef{} err = db.QueryRow(sqlstr, adrelid, adnum).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Adrelid, &pa.Adnum, &pa.Adbin, &pa.Adsrc) if err != nil { return nil, err } return &pa, nil }
go
func PgAttrdefByAdrelidAdnum(db XODB, adrelid pgtypes.Oid, adnum int16) (*PgAttrdef, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, adrelid, adnum, adbin, adsrc ` + `FROM pg_catalog.pg_attrdef ` + `WHERE adrelid = $1 AND adnum = $2` // run query XOLog(sqlstr, adrelid, adnum) pa := PgAttrdef{} err = db.QueryRow(sqlstr, adrelid, adnum).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Adrelid, &pa.Adnum, &pa.Adbin, &pa.Adsrc) if err != nil { return nil, err } return &pa, nil }
[ "func", "PgAttrdefByAdrelidAdnum", "(", "db", "XODB", ",", "adrelid", "pgtypes", ".", "Oid", ",", "adnum", "int16", ")", "(", "*", "PgAttrdef", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, adrelid, adnum, adbin, adsrc `", "+", "`FROM pg_catalog.pg_attrdef `", "+", "`WHERE adrelid = $1 AND adnum = $2`", "\n", "XOLog", "(", "sqlstr", ",", "adrelid", ",", "adnum", ")", "\n", "pa", ":=", "PgAttrdef", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "adrelid", ",", "adnum", ")", ".", "Scan", "(", "&", "pa", ".", "Tableoid", ",", "&", "pa", ".", "Cmax", ",", "&", "pa", ".", "Xmax", ",", "&", "pa", ".", "Cmin", ",", "&", "pa", ".", "Xmin", ",", "&", "pa", ".", "Oid", ",", "&", "pa", ".", "Ctid", ",", "&", "pa", ".", "Adrelid", ",", "&", "pa", ".", "Adnum", ",", "&", "pa", ".", "Adbin", ",", "&", "pa", ".", "Adsrc", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pa", ",", "nil", "\n", "}" ]
// PgAttrdefByAdrelidAdnum retrieves a row from 'pg_catalog.pg_attrdef' as a PgAttrdef. // // Generated from index 'pg_attrdef_adrelid_adnum_index'.
[ "PgAttrdefByAdrelidAdnum", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_attrdef", "as", "a", "PgAttrdef", ".", "Generated", "from", "index", "pg_attrdef_adrelid_adnum_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L41936-L41955
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgAttrdefByOid
func PgAttrdefByOid(db XODB, oid pgtypes.Oid) (*PgAttrdef, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, adrelid, adnum, adbin, adsrc ` + `FROM pg_catalog.pg_attrdef ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pa := PgAttrdef{} err = db.QueryRow(sqlstr, oid).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Adrelid, &pa.Adnum, &pa.Adbin, &pa.Adsrc) if err != nil { return nil, err } return &pa, nil }
go
func PgAttrdefByOid(db XODB, oid pgtypes.Oid) (*PgAttrdef, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, adrelid, adnum, adbin, adsrc ` + `FROM pg_catalog.pg_attrdef ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pa := PgAttrdef{} err = db.QueryRow(sqlstr, oid).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Adrelid, &pa.Adnum, &pa.Adbin, &pa.Adsrc) if err != nil { return nil, err } return &pa, nil }
[ "func", "PgAttrdefByOid", "(", "db", "XODB", ",", "oid", "pgtypes", ".", "Oid", ")", "(", "*", "PgAttrdef", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, adrelid, adnum, adbin, adsrc `", "+", "`FROM pg_catalog.pg_attrdef `", "+", "`WHERE oid = $1`", "\n", "XOLog", "(", "sqlstr", ",", "oid", ")", "\n", "pa", ":=", "PgAttrdef", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "oid", ")", ".", "Scan", "(", "&", "pa", ".", "Tableoid", ",", "&", "pa", ".", "Cmax", ",", "&", "pa", ".", "Xmax", ",", "&", "pa", ".", "Cmin", ",", "&", "pa", ".", "Xmin", ",", "&", "pa", ".", "Oid", ",", "&", "pa", ".", "Ctid", ",", "&", "pa", ".", "Adrelid", ",", "&", "pa", ".", "Adnum", ",", "&", "pa", ".", "Adbin", ",", "&", "pa", ".", "Adsrc", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pa", ",", "nil", "\n", "}" ]
// PgAttrdefByOid retrieves a row from 'pg_catalog.pg_attrdef' as a PgAttrdef. // // Generated from index 'pg_attrdef_oid_index'.
[ "PgAttrdefByOid", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_attrdef", "as", "a", "PgAttrdef", ".", "Generated", "from", "index", "pg_attrdef_oid_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L41960-L41979
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgAttributeByAttrelidAttname
func PgAttributeByAttrelidAttname(db XODB, attrelid pgtypes.Oid, attname pgtypes.Name) (*PgAttribute, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, ctid, attrelid, attname, atttypid, attstattarget, attlen, attnum, attndims, attcacheoff, atttypmod, attbyval, attstorage, attalign, attnotnull, atthasdef, attisdropped, attislocal, attinhcount, attcollation, attacl, attoptions, attfdwoptions ` + `FROM pg_catalog.pg_attribute ` + `WHERE attrelid = $1 AND attname = $2` // run query XOLog(sqlstr, attrelid, attname) pa := PgAttribute{} err = db.QueryRow(sqlstr, attrelid, attname).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Ctid, &pa.Attrelid, &pa.Attname, &pa.Atttypid, &pa.Attstattarget, &pa.Attlen, &pa.Attnum, &pa.Attndims, &pa.Attcacheoff, &pa.Atttypmod, &pa.Attbyval, &pa.Attstorage, &pa.Attalign, &pa.Attnotnull, &pa.Atthasdef, &pa.Attisdropped, &pa.Attislocal, &pa.Attinhcount, &pa.Attcollation, &pa.Attacl, &pa.Attoptions, &pa.Attfdwoptions) if err != nil { return nil, err } return &pa, nil }
go
func PgAttributeByAttrelidAttname(db XODB, attrelid pgtypes.Oid, attname pgtypes.Name) (*PgAttribute, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, ctid, attrelid, attname, atttypid, attstattarget, attlen, attnum, attndims, attcacheoff, atttypmod, attbyval, attstorage, attalign, attnotnull, atthasdef, attisdropped, attislocal, attinhcount, attcollation, attacl, attoptions, attfdwoptions ` + `FROM pg_catalog.pg_attribute ` + `WHERE attrelid = $1 AND attname = $2` // run query XOLog(sqlstr, attrelid, attname) pa := PgAttribute{} err = db.QueryRow(sqlstr, attrelid, attname).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Ctid, &pa.Attrelid, &pa.Attname, &pa.Atttypid, &pa.Attstattarget, &pa.Attlen, &pa.Attnum, &pa.Attndims, &pa.Attcacheoff, &pa.Atttypmod, &pa.Attbyval, &pa.Attstorage, &pa.Attalign, &pa.Attnotnull, &pa.Atthasdef, &pa.Attisdropped, &pa.Attislocal, &pa.Attinhcount, &pa.Attcollation, &pa.Attacl, &pa.Attoptions, &pa.Attfdwoptions) if err != nil { return nil, err } return &pa, nil }
[ "func", "PgAttributeByAttrelidAttname", "(", "db", "XODB", ",", "attrelid", "pgtypes", ".", "Oid", ",", "attname", "pgtypes", ".", "Name", ")", "(", "*", "PgAttribute", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, ctid, attrelid, attname, atttypid, attstattarget, attlen, attnum, attndims, attcacheoff, atttypmod, attbyval, attstorage, attalign, attnotnull, atthasdef, attisdropped, attislocal, attinhcount, attcollation, attacl, attoptions, attfdwoptions `", "+", "`FROM pg_catalog.pg_attribute `", "+", "`WHERE attrelid = $1 AND attname = $2`", "\n", "XOLog", "(", "sqlstr", ",", "attrelid", ",", "attname", ")", "\n", "pa", ":=", "PgAttribute", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "attrelid", ",", "attname", ")", ".", "Scan", "(", "&", "pa", ".", "Tableoid", ",", "&", "pa", ".", "Cmax", ",", "&", "pa", ".", "Xmax", ",", "&", "pa", ".", "Cmin", ",", "&", "pa", ".", "Xmin", ",", "&", "pa", ".", "Ctid", ",", "&", "pa", ".", "Attrelid", ",", "&", "pa", ".", "Attname", ",", "&", "pa", ".", "Atttypid", ",", "&", "pa", ".", "Attstattarget", ",", "&", "pa", ".", "Attlen", ",", "&", "pa", ".", "Attnum", ",", "&", "pa", ".", "Attndims", ",", "&", "pa", ".", "Attcacheoff", ",", "&", "pa", ".", "Atttypmod", ",", "&", "pa", ".", "Attbyval", ",", "&", "pa", ".", "Attstorage", ",", "&", "pa", ".", "Attalign", ",", "&", "pa", ".", "Attnotnull", ",", "&", "pa", ".", "Atthasdef", ",", "&", "pa", ".", "Attisdropped", ",", "&", "pa", ".", "Attislocal", ",", "&", "pa", ".", "Attinhcount", ",", "&", "pa", ".", "Attcollation", ",", "&", "pa", ".", "Attacl", ",", "&", "pa", ".", "Attoptions", ",", "&", "pa", ".", "Attfdwoptions", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pa", ",", "nil", "\n", "}" ]
// PgAttributeByAttrelidAttname retrieves a row from 'pg_catalog.pg_attribute' as a PgAttribute. // // Generated from index 'pg_attribute_relid_attnam_index'.
[ "PgAttributeByAttrelidAttname", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_attribute", "as", "a", "PgAttribute", ".", "Generated", "from", "index", "pg_attribute_relid_attnam_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L41984-L42003
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgAuthMemberByMemberRoleid
func PgAuthMemberByMemberRoleid(db XODB, member pgtypes.Oid, roleid pgtypes.Oid) (*PgAuthMember, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, ctid, roleid, member, grantor, admin_option ` + `FROM pg_catalog.pg_auth_members ` + `WHERE member = $1 AND roleid = $2` // run query XOLog(sqlstr, member, roleid) pam := PgAuthMember{} err = db.QueryRow(sqlstr, member, roleid).Scan(&pam.Tableoid, &pam.Cmax, &pam.Xmax, &pam.Cmin, &pam.Xmin, &pam.Ctid, &pam.Roleid, &pam.Member, &pam.Grantor, &pam.AdminOption) if err != nil { return nil, err } return &pam, nil }
go
func PgAuthMemberByMemberRoleid(db XODB, member pgtypes.Oid, roleid pgtypes.Oid) (*PgAuthMember, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, ctid, roleid, member, grantor, admin_option ` + `FROM pg_catalog.pg_auth_members ` + `WHERE member = $1 AND roleid = $2` // run query XOLog(sqlstr, member, roleid) pam := PgAuthMember{} err = db.QueryRow(sqlstr, member, roleid).Scan(&pam.Tableoid, &pam.Cmax, &pam.Xmax, &pam.Cmin, &pam.Xmin, &pam.Ctid, &pam.Roleid, &pam.Member, &pam.Grantor, &pam.AdminOption) if err != nil { return nil, err } return &pam, nil }
[ "func", "PgAuthMemberByMemberRoleid", "(", "db", "XODB", ",", "member", "pgtypes", ".", "Oid", ",", "roleid", "pgtypes", ".", "Oid", ")", "(", "*", "PgAuthMember", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, ctid, roleid, member, grantor, admin_option `", "+", "`FROM pg_catalog.pg_auth_members `", "+", "`WHERE member = $1 AND roleid = $2`", "\n", "XOLog", "(", "sqlstr", ",", "member", ",", "roleid", ")", "\n", "pam", ":=", "PgAuthMember", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "member", ",", "roleid", ")", ".", "Scan", "(", "&", "pam", ".", "Tableoid", ",", "&", "pam", ".", "Cmax", ",", "&", "pam", ".", "Xmax", ",", "&", "pam", ".", "Cmin", ",", "&", "pam", ".", "Xmin", ",", "&", "pam", ".", "Ctid", ",", "&", "pam", ".", "Roleid", ",", "&", "pam", ".", "Member", ",", "&", "pam", ".", "Grantor", ",", "&", "pam", ".", "AdminOption", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pam", ",", "nil", "\n", "}" ]
// PgAuthMemberByMemberRoleid retrieves a row from 'pg_catalog.pg_auth_members' as a PgAuthMember. // // Generated from index 'pg_auth_members_member_role_index'.
[ "PgAuthMemberByMemberRoleid", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_auth_members", "as", "a", "PgAuthMember", ".", "Generated", "from", "index", "pg_auth_members_member_role_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L42032-L42051
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgAuthidByOid
func PgAuthidByOid(db XODB, oid pgtypes.Oid) (*PgAuthid, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil ` + `FROM pg_catalog.pg_authid ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pa := PgAuthid{} err = db.QueryRow(sqlstr, oid).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Rolname, &pa.Rolsuper, &pa.Rolinherit, &pa.Rolcreaterole, &pa.Rolcreatedb, &pa.Rolcanlogin, &pa.Rolreplication, &pa.Rolbypassrls, &pa.Rolconnlimit, &pa.Rolpassword, &pa.Rolvaliduntil) if err != nil { return nil, err } return &pa, nil }
go
func PgAuthidByOid(db XODB, oid pgtypes.Oid) (*PgAuthid, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil ` + `FROM pg_catalog.pg_authid ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pa := PgAuthid{} err = db.QueryRow(sqlstr, oid).Scan(&pa.Tableoid, &pa.Cmax, &pa.Xmax, &pa.Cmin, &pa.Xmin, &pa.Oid, &pa.Ctid, &pa.Rolname, &pa.Rolsuper, &pa.Rolinherit, &pa.Rolcreaterole, &pa.Rolcreatedb, &pa.Rolcanlogin, &pa.Rolreplication, &pa.Rolbypassrls, &pa.Rolconnlimit, &pa.Rolpassword, &pa.Rolvaliduntil) if err != nil { return nil, err } return &pa, nil }
[ "func", "PgAuthidByOid", "(", "db", "XODB", ",", "oid", "pgtypes", ".", "Oid", ")", "(", "*", "PgAuthid", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil `", "+", "`FROM pg_catalog.pg_authid `", "+", "`WHERE oid = $1`", "\n", "XOLog", "(", "sqlstr", ",", "oid", ")", "\n", "pa", ":=", "PgAuthid", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "oid", ")", ".", "Scan", "(", "&", "pa", ".", "Tableoid", ",", "&", "pa", ".", "Cmax", ",", "&", "pa", ".", "Xmax", ",", "&", "pa", ".", "Cmin", ",", "&", "pa", ".", "Xmin", ",", "&", "pa", ".", "Oid", ",", "&", "pa", ".", "Ctid", ",", "&", "pa", ".", "Rolname", ",", "&", "pa", ".", "Rolsuper", ",", "&", "pa", ".", "Rolinherit", ",", "&", "pa", ".", "Rolcreaterole", ",", "&", "pa", ".", "Rolcreatedb", ",", "&", "pa", ".", "Rolcanlogin", ",", "&", "pa", ".", "Rolreplication", ",", "&", "pa", ".", "Rolbypassrls", ",", "&", "pa", ".", "Rolconnlimit", ",", "&", "pa", ".", "Rolpassword", ",", "&", "pa", ".", "Rolvaliduntil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pa", ",", "nil", "\n", "}" ]
// PgAuthidByOid retrieves a row from 'pg_catalog.pg_authid' as a PgAuthid. // // Generated from index 'pg_authid_oid_index'.
[ "PgAuthidByOid", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_authid", "as", "a", "PgAuthid", ".", "Generated", "from", "index", "pg_authid_oid_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L42080-L42099
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgCastByOid
func PgCastByOid(db XODB, oid pgtypes.Oid) (*PgCast, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, castsource, casttarget, castfunc, castcontext, castmethod ` + `FROM pg_catalog.pg_cast ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pc := PgCast{} err = db.QueryRow(sqlstr, oid).Scan(&pc.Tableoid, &pc.Cmax, &pc.Xmax, &pc.Cmin, &pc.Xmin, &pc.Oid, &pc.Ctid, &pc.Castsource, &pc.Casttarget, &pc.Castfunc, &pc.Castcontext, &pc.Castmethod) if err != nil { return nil, err } return &pc, nil }
go
func PgCastByOid(db XODB, oid pgtypes.Oid) (*PgCast, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, castsource, casttarget, castfunc, castcontext, castmethod ` + `FROM pg_catalog.pg_cast ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pc := PgCast{} err = db.QueryRow(sqlstr, oid).Scan(&pc.Tableoid, &pc.Cmax, &pc.Xmax, &pc.Cmin, &pc.Xmin, &pc.Oid, &pc.Ctid, &pc.Castsource, &pc.Casttarget, &pc.Castfunc, &pc.Castcontext, &pc.Castmethod) if err != nil { return nil, err } return &pc, nil }
[ "func", "PgCastByOid", "(", "db", "XODB", ",", "oid", "pgtypes", ".", "Oid", ")", "(", "*", "PgCast", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, castsource, casttarget, castfunc, castcontext, castmethod `", "+", "`FROM pg_catalog.pg_cast `", "+", "`WHERE oid = $1`", "\n", "XOLog", "(", "sqlstr", ",", "oid", ")", "\n", "pc", ":=", "PgCast", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "oid", ")", ".", "Scan", "(", "&", "pc", ".", "Tableoid", ",", "&", "pc", ".", "Cmax", ",", "&", "pc", ".", "Xmax", ",", "&", "pc", ".", "Cmin", ",", "&", "pc", ".", "Xmin", ",", "&", "pc", ".", "Oid", ",", "&", "pc", ".", "Ctid", ",", "&", "pc", ".", "Castsource", ",", "&", "pc", ".", "Casttarget", ",", "&", "pc", ".", "Castfunc", ",", "&", "pc", ".", "Castcontext", ",", "&", "pc", ".", "Castmethod", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pc", ",", "nil", "\n", "}" ]
// PgCastByOid retrieves a row from 'pg_catalog.pg_cast' as a PgCast. // // Generated from index 'pg_cast_oid_index'.
[ "PgCastByOid", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_cast", "as", "a", "PgCast", ".", "Generated", "from", "index", "pg_cast_oid_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L42128-L42147
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgClassByOid
func PgClassByOid(db XODB, oid pgtypes.Oid) (*PgClass, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, relname, relnamespace, reltype, reloftype, relowner, relam, relfilenode, reltablespace, relpages, reltuples, relallvisible, reltoastrelid, relhasindex, relisshared, relpersistence, relkind, relnatts, relchecks, relhasoids, relhaspkey, relhasrules, relhastriggers, relhassubclass, relrowsecurity, relforcerowsecurity, relispopulated, relreplident, relfrozenxid, relminmxid, relacl, reloptions ` + `FROM pg_catalog.pg_class ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pc := PgClass{} err = db.QueryRow(sqlstr, oid).Scan(&pc.Tableoid, &pc.Cmax, &pc.Xmax, &pc.Cmin, &pc.Xmin, &pc.Oid, &pc.Ctid, &pc.Relname, &pc.Relnamespace, &pc.Reltype, &pc.Reloftype, &pc.Relowner, &pc.Relam, &pc.Relfilenode, &pc.Reltablespace, &pc.Relpages, &pc.Reltuples, &pc.Relallvisible, &pc.Reltoastrelid, &pc.Relhasindex, &pc.Relisshared, &pc.Relpersistence, &pc.Relkind, &pc.Relnatts, &pc.Relchecks, &pc.Relhasoids, &pc.Relhaspkey, &pc.Relhasrules, &pc.Relhastriggers, &pc.Relhassubclass, &pc.Relrowsecurity, &pc.Relforcerowsecurity, &pc.Relispopulated, &pc.Relreplident, &pc.Relfrozenxid, &pc.Relminmxid, &pc.Relacl, &pc.Reloptions) if err != nil { return nil, err } return &pc, nil }
go
func PgClassByOid(db XODB, oid pgtypes.Oid) (*PgClass, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, relname, relnamespace, reltype, reloftype, relowner, relam, relfilenode, reltablespace, relpages, reltuples, relallvisible, reltoastrelid, relhasindex, relisshared, relpersistence, relkind, relnatts, relchecks, relhasoids, relhaspkey, relhasrules, relhastriggers, relhassubclass, relrowsecurity, relforcerowsecurity, relispopulated, relreplident, relfrozenxid, relminmxid, relacl, reloptions ` + `FROM pg_catalog.pg_class ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pc := PgClass{} err = db.QueryRow(sqlstr, oid).Scan(&pc.Tableoid, &pc.Cmax, &pc.Xmax, &pc.Cmin, &pc.Xmin, &pc.Oid, &pc.Ctid, &pc.Relname, &pc.Relnamespace, &pc.Reltype, &pc.Reloftype, &pc.Relowner, &pc.Relam, &pc.Relfilenode, &pc.Reltablespace, &pc.Relpages, &pc.Reltuples, &pc.Relallvisible, &pc.Reltoastrelid, &pc.Relhasindex, &pc.Relisshared, &pc.Relpersistence, &pc.Relkind, &pc.Relnatts, &pc.Relchecks, &pc.Relhasoids, &pc.Relhaspkey, &pc.Relhasrules, &pc.Relhastriggers, &pc.Relhassubclass, &pc.Relrowsecurity, &pc.Relforcerowsecurity, &pc.Relispopulated, &pc.Relreplident, &pc.Relfrozenxid, &pc.Relminmxid, &pc.Relacl, &pc.Reloptions) if err != nil { return nil, err } return &pc, nil }
[ "func", "PgClassByOid", "(", "db", "XODB", ",", "oid", "pgtypes", ".", "Oid", ")", "(", "*", "PgClass", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, relname, relnamespace, reltype, reloftype, relowner, relam, relfilenode, reltablespace, relpages, reltuples, relallvisible, reltoastrelid, relhasindex, relisshared, relpersistence, relkind, relnatts, relchecks, relhasoids, relhaspkey, relhasrules, relhastriggers, relhassubclass, relrowsecurity, relforcerowsecurity, relispopulated, relreplident, relfrozenxid, relminmxid, relacl, reloptions `", "+", "`FROM pg_catalog.pg_class `", "+", "`WHERE oid = $1`", "\n", "XOLog", "(", "sqlstr", ",", "oid", ")", "\n", "pc", ":=", "PgClass", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "oid", ")", ".", "Scan", "(", "&", "pc", ".", "Tableoid", ",", "&", "pc", ".", "Cmax", ",", "&", "pc", ".", "Xmax", ",", "&", "pc", ".", "Cmin", ",", "&", "pc", ".", "Xmin", ",", "&", "pc", ".", "Oid", ",", "&", "pc", ".", "Ctid", ",", "&", "pc", ".", "Relname", ",", "&", "pc", ".", "Relnamespace", ",", "&", "pc", ".", "Reltype", ",", "&", "pc", ".", "Reloftype", ",", "&", "pc", ".", "Relowner", ",", "&", "pc", ".", "Relam", ",", "&", "pc", ".", "Relfilenode", ",", "&", "pc", ".", "Reltablespace", ",", "&", "pc", ".", "Relpages", ",", "&", "pc", ".", "Reltuples", ",", "&", "pc", ".", "Relallvisible", ",", "&", "pc", ".", "Reltoastrelid", ",", "&", "pc", ".", "Relhasindex", ",", "&", "pc", ".", "Relisshared", ",", "&", "pc", ".", "Relpersistence", ",", "&", "pc", ".", "Relkind", ",", "&", "pc", ".", "Relnatts", ",", "&", "pc", ".", "Relchecks", ",", "&", "pc", ".", "Relhasoids", ",", "&", "pc", ".", "Relhaspkey", ",", "&", "pc", ".", "Relhasrules", ",", "&", "pc", ".", "Relhastriggers", ",", "&", "pc", ".", "Relhassubclass", ",", "&", "pc", ".", "Relrowsecurity", ",", "&", "pc", ".", "Relforcerowsecurity", ",", "&", "pc", ".", "Relispopulated", ",", "&", "pc", ".", "Relreplident", ",", "&", "pc", ".", "Relfrozenxid", ",", "&", "pc", ".", "Relminmxid", ",", "&", "pc", ".", "Relacl", ",", "&", "pc", ".", "Reloptions", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pc", ",", "nil", "\n", "}" ]
// PgClassByOid retrieves a row from 'pg_catalog.pg_class' as a PgClass. // // Generated from index 'pg_class_oid_index'.
[ "PgClassByOid", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_class", "as", "a", "PgClass", ".", "Generated", "from", "index", "pg_class_oid_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L42176-L42195
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgCollationByCollnameCollencodingCollnamespace
func PgCollationByCollnameCollencodingCollnamespace(db XODB, collname pgtypes.Name, collencoding int, collnamespace pgtypes.Oid) (*PgCollation, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, collname, collnamespace, collowner, collencoding, collcollate, collctype ` + `FROM pg_catalog.pg_collation ` + `WHERE collname = $1 AND collencoding = $2 AND collnamespace = $3` // run query XOLog(sqlstr, collname, collencoding, collnamespace) pc := PgCollation{} err = db.QueryRow(sqlstr, collname, collencoding, collnamespace).Scan(&pc.Tableoid, &pc.Cmax, &pc.Xmax, &pc.Cmin, &pc.Xmin, &pc.Oid, &pc.Ctid, &pc.Collname, &pc.Collnamespace, &pc.Collowner, &pc.Collencoding, &pc.Collcollate, &pc.Collctype) if err != nil { return nil, err } return &pc, nil }
go
func PgCollationByCollnameCollencodingCollnamespace(db XODB, collname pgtypes.Name, collencoding int, collnamespace pgtypes.Oid) (*PgCollation, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, collname, collnamespace, collowner, collencoding, collcollate, collctype ` + `FROM pg_catalog.pg_collation ` + `WHERE collname = $1 AND collencoding = $2 AND collnamespace = $3` // run query XOLog(sqlstr, collname, collencoding, collnamespace) pc := PgCollation{} err = db.QueryRow(sqlstr, collname, collencoding, collnamespace).Scan(&pc.Tableoid, &pc.Cmax, &pc.Xmax, &pc.Cmin, &pc.Xmin, &pc.Oid, &pc.Ctid, &pc.Collname, &pc.Collnamespace, &pc.Collowner, &pc.Collencoding, &pc.Collcollate, &pc.Collctype) if err != nil { return nil, err } return &pc, nil }
[ "func", "PgCollationByCollnameCollencodingCollnamespace", "(", "db", "XODB", ",", "collname", "pgtypes", ".", "Name", ",", "collencoding", "int", ",", "collnamespace", "pgtypes", ".", "Oid", ")", "(", "*", "PgCollation", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, collname, collnamespace, collowner, collencoding, collcollate, collctype `", "+", "`FROM pg_catalog.pg_collation `", "+", "`WHERE collname = $1 AND collencoding = $2 AND collnamespace = $3`", "\n", "XOLog", "(", "sqlstr", ",", "collname", ",", "collencoding", ",", "collnamespace", ")", "\n", "pc", ":=", "PgCollation", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "collname", ",", "collencoding", ",", "collnamespace", ")", ".", "Scan", "(", "&", "pc", ".", "Tableoid", ",", "&", "pc", ".", "Cmax", ",", "&", "pc", ".", "Xmax", ",", "&", "pc", ".", "Cmin", ",", "&", "pc", ".", "Xmin", ",", "&", "pc", ".", "Oid", ",", "&", "pc", ".", "Ctid", ",", "&", "pc", ".", "Collname", ",", "&", "pc", ".", "Collnamespace", ",", "&", "pc", ".", "Collowner", ",", "&", "pc", ".", "Collencoding", ",", "&", "pc", ".", "Collcollate", ",", "&", "pc", ".", "Collctype", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pc", ",", "nil", "\n", "}" ]
// PgCollationByCollnameCollencodingCollnamespace retrieves a row from 'pg_catalog.pg_collation' as a PgCollation. // // Generated from index 'pg_collation_name_enc_nsp_index'.
[ "PgCollationByCollnameCollencodingCollnamespace", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_collation", "as", "a", "PgCollation", ".", "Generated", "from", "index", "pg_collation_name_enc_nsp_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L42261-L42280
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgCollationByOid
func PgCollationByOid(db XODB, oid pgtypes.Oid) (*PgCollation, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, collname, collnamespace, collowner, collencoding, collcollate, collctype ` + `FROM pg_catalog.pg_collation ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pc := PgCollation{} err = db.QueryRow(sqlstr, oid).Scan(&pc.Tableoid, &pc.Cmax, &pc.Xmax, &pc.Cmin, &pc.Xmin, &pc.Oid, &pc.Ctid, &pc.Collname, &pc.Collnamespace, &pc.Collowner, &pc.Collencoding, &pc.Collcollate, &pc.Collctype) if err != nil { return nil, err } return &pc, nil }
go
func PgCollationByOid(db XODB, oid pgtypes.Oid) (*PgCollation, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, collname, collnamespace, collowner, collencoding, collcollate, collctype ` + `FROM pg_catalog.pg_collation ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pc := PgCollation{} err = db.QueryRow(sqlstr, oid).Scan(&pc.Tableoid, &pc.Cmax, &pc.Xmax, &pc.Cmin, &pc.Xmin, &pc.Oid, &pc.Ctid, &pc.Collname, &pc.Collnamespace, &pc.Collowner, &pc.Collencoding, &pc.Collcollate, &pc.Collctype) if err != nil { return nil, err } return &pc, nil }
[ "func", "PgCollationByOid", "(", "db", "XODB", ",", "oid", "pgtypes", ".", "Oid", ")", "(", "*", "PgCollation", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, collname, collnamespace, collowner, collencoding, collcollate, collctype `", "+", "`FROM pg_catalog.pg_collation `", "+", "`WHERE oid = $1`", "\n", "XOLog", "(", "sqlstr", ",", "oid", ")", "\n", "pc", ":=", "PgCollation", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "oid", ")", ".", "Scan", "(", "&", "pc", ".", "Tableoid", ",", "&", "pc", ".", "Cmax", ",", "&", "pc", ".", "Xmax", ",", "&", "pc", ".", "Cmin", ",", "&", "pc", ".", "Xmin", ",", "&", "pc", ".", "Oid", ",", "&", "pc", ".", "Ctid", ",", "&", "pc", ".", "Collname", ",", "&", "pc", ".", "Collnamespace", ",", "&", "pc", ".", "Collowner", ",", "&", "pc", ".", "Collencoding", ",", "&", "pc", ".", "Collcollate", ",", "&", "pc", ".", "Collctype", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pc", ",", "nil", "\n", "}" ]
// PgCollationByOid retrieves a row from 'pg_catalog.pg_collation' as a PgCollation. // // Generated from index 'pg_collation_oid_index'.
[ "PgCollationByOid", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_collation", "as", "a", "PgCollation", ".", "Generated", "from", "index", "pg_collation_oid_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L42285-L42304
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgConstraintsByConnameConnamespace
func PgConstraintsByConnameConnamespace(db XODB, conname pgtypes.Name, connamespace pgtypes.Oid) ([]*PgConstraint, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, conname, connamespace, contype, condeferrable, condeferred, convalidated, conrelid, contypid, conindid, confrelid, confupdtype, confdeltype, confmatchtype, conislocal, coninhcount, connoinherit, conkey, confkey, conpfeqop, conppeqop, conffeqop, conexclop, conbin, consrc ` + `FROM pg_catalog.pg_constraint ` + `WHERE conname = $1 AND connamespace = $2` // run query XOLog(sqlstr, conname, connamespace) q, err := db.Query(sqlstr, conname, connamespace) if err != nil { return nil, err } defer q.Close() // load results res := []*PgConstraint{} for q.Next() { pc := PgConstraint{} // scan err = q.Scan(&pc.Tableoid, &pc.Cmax, &pc.Xmax, &pc.Cmin, &pc.Xmin, &pc.Oid, &pc.Ctid, &pc.Conname, &pc.Connamespace, &pc.Contype, &pc.Condeferrable, &pc.Condeferred, &pc.Convalidated, &pc.Conrelid, &pc.Contypid, &pc.Conindid, &pc.Confrelid, &pc.Confupdtype, &pc.Confdeltype, &pc.Confmatchtype, &pc.Conislocal, &pc.Coninhcount, &pc.Connoinherit, &pc.Conkey, &pc.Confkey, &pc.Conpfeqop, &pc.Conppeqop, &pc.Conffeqop, &pc.Conexclop, &pc.Conbin, &pc.Consrc) if err != nil { return nil, err } res = append(res, &pc) } return res, nil }
go
func PgConstraintsByConnameConnamespace(db XODB, conname pgtypes.Name, connamespace pgtypes.Oid) ([]*PgConstraint, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, conname, connamespace, contype, condeferrable, condeferred, convalidated, conrelid, contypid, conindid, confrelid, confupdtype, confdeltype, confmatchtype, conislocal, coninhcount, connoinherit, conkey, confkey, conpfeqop, conppeqop, conffeqop, conexclop, conbin, consrc ` + `FROM pg_catalog.pg_constraint ` + `WHERE conname = $1 AND connamespace = $2` // run query XOLog(sqlstr, conname, connamespace) q, err := db.Query(sqlstr, conname, connamespace) if err != nil { return nil, err } defer q.Close() // load results res := []*PgConstraint{} for q.Next() { pc := PgConstraint{} // scan err = q.Scan(&pc.Tableoid, &pc.Cmax, &pc.Xmax, &pc.Cmin, &pc.Xmin, &pc.Oid, &pc.Ctid, &pc.Conname, &pc.Connamespace, &pc.Contype, &pc.Condeferrable, &pc.Condeferred, &pc.Convalidated, &pc.Conrelid, &pc.Contypid, &pc.Conindid, &pc.Confrelid, &pc.Confupdtype, &pc.Confdeltype, &pc.Confmatchtype, &pc.Conislocal, &pc.Coninhcount, &pc.Connoinherit, &pc.Conkey, &pc.Confkey, &pc.Conpfeqop, &pc.Conppeqop, &pc.Conffeqop, &pc.Conexclop, &pc.Conbin, &pc.Consrc) if err != nil { return nil, err } res = append(res, &pc) } return res, nil }
[ "func", "PgConstraintsByConnameConnamespace", "(", "db", "XODB", ",", "conname", "pgtypes", ".", "Name", ",", "connamespace", "pgtypes", ".", "Oid", ")", "(", "[", "]", "*", "PgConstraint", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, conname, connamespace, contype, condeferrable, condeferred, convalidated, conrelid, contypid, conindid, confrelid, confupdtype, confdeltype, confmatchtype, conislocal, coninhcount, connoinherit, conkey, confkey, conpfeqop, conppeqop, conffeqop, conexclop, conbin, consrc `", "+", "`FROM pg_catalog.pg_constraint `", "+", "`WHERE conname = $1 AND connamespace = $2`", "\n", "XOLog", "(", "sqlstr", ",", "conname", ",", "connamespace", ")", "\n", "q", ",", "err", ":=", "db", ".", "Query", "(", "sqlstr", ",", "conname", ",", "connamespace", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "q", ".", "Close", "(", ")", "\n", "res", ":=", "[", "]", "*", "PgConstraint", "{", "}", "\n", "for", "q", ".", "Next", "(", ")", "{", "pc", ":=", "PgConstraint", "{", "}", "\n", "err", "=", "q", ".", "Scan", "(", "&", "pc", ".", "Tableoid", ",", "&", "pc", ".", "Cmax", ",", "&", "pc", ".", "Xmax", ",", "&", "pc", ".", "Cmin", ",", "&", "pc", ".", "Xmin", ",", "&", "pc", ".", "Oid", ",", "&", "pc", ".", "Ctid", ",", "&", "pc", ".", "Conname", ",", "&", "pc", ".", "Connamespace", ",", "&", "pc", ".", "Contype", ",", "&", "pc", ".", "Condeferrable", ",", "&", "pc", ".", "Condeferred", ",", "&", "pc", ".", "Convalidated", ",", "&", "pc", ".", "Conrelid", ",", "&", "pc", ".", "Contypid", ",", "&", "pc", ".", "Conindid", ",", "&", "pc", ".", "Confrelid", ",", "&", "pc", ".", "Confupdtype", ",", "&", "pc", ".", "Confdeltype", ",", "&", "pc", ".", "Confmatchtype", ",", "&", "pc", ".", "Conislocal", ",", "&", "pc", ".", "Coninhcount", ",", "&", "pc", ".", "Connoinherit", ",", "&", "pc", ".", "Conkey", ",", "&", "pc", ".", "Confkey", ",", "&", "pc", ".", "Conpfeqop", ",", "&", "pc", ".", "Conppeqop", ",", "&", "pc", ".", "Conffeqop", ",", "&", "pc", ".", "Conexclop", ",", "&", "pc", ".", "Conbin", ",", "&", "pc", ".", "Consrc", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "res", "=", "append", "(", "res", ",", "&", "pc", ")", "\n", "}", "\n", "return", "res", ",", "nil", "\n", "}" ]
// PgConstraintsByConnameConnamespace retrieves a row from 'pg_catalog.pg_constraint' as a PgConstraint. // // Generated from index 'pg_constraint_conname_nsp_index'.
[ "PgConstraintsByConnameConnamespace", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_constraint", "as", "a", "PgConstraint", ".", "Generated", "from", "index", "pg_constraint_conname_nsp_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L42309-L42341
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgConstraintByOid
func PgConstraintByOid(db XODB, oid pgtypes.Oid) (*PgConstraint, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, conname, connamespace, contype, condeferrable, condeferred, convalidated, conrelid, contypid, conindid, confrelid, confupdtype, confdeltype, confmatchtype, conislocal, coninhcount, connoinherit, conkey, confkey, conpfeqop, conppeqop, conffeqop, conexclop, conbin, consrc ` + `FROM pg_catalog.pg_constraint ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pc := PgConstraint{} err = db.QueryRow(sqlstr, oid).Scan(&pc.Tableoid, &pc.Cmax, &pc.Xmax, &pc.Cmin, &pc.Xmin, &pc.Oid, &pc.Ctid, &pc.Conname, &pc.Connamespace, &pc.Contype, &pc.Condeferrable, &pc.Condeferred, &pc.Convalidated, &pc.Conrelid, &pc.Contypid, &pc.Conindid, &pc.Confrelid, &pc.Confupdtype, &pc.Confdeltype, &pc.Confmatchtype, &pc.Conislocal, &pc.Coninhcount, &pc.Connoinherit, &pc.Conkey, &pc.Confkey, &pc.Conpfeqop, &pc.Conppeqop, &pc.Conffeqop, &pc.Conexclop, &pc.Conbin, &pc.Consrc) if err != nil { return nil, err } return &pc, nil }
go
func PgConstraintByOid(db XODB, oid pgtypes.Oid) (*PgConstraint, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, conname, connamespace, contype, condeferrable, condeferred, convalidated, conrelid, contypid, conindid, confrelid, confupdtype, confdeltype, confmatchtype, conislocal, coninhcount, connoinherit, conkey, confkey, conpfeqop, conppeqop, conffeqop, conexclop, conbin, consrc ` + `FROM pg_catalog.pg_constraint ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pc := PgConstraint{} err = db.QueryRow(sqlstr, oid).Scan(&pc.Tableoid, &pc.Cmax, &pc.Xmax, &pc.Cmin, &pc.Xmin, &pc.Oid, &pc.Ctid, &pc.Conname, &pc.Connamespace, &pc.Contype, &pc.Condeferrable, &pc.Condeferred, &pc.Convalidated, &pc.Conrelid, &pc.Contypid, &pc.Conindid, &pc.Confrelid, &pc.Confupdtype, &pc.Confdeltype, &pc.Confmatchtype, &pc.Conislocal, &pc.Coninhcount, &pc.Connoinherit, &pc.Conkey, &pc.Confkey, &pc.Conpfeqop, &pc.Conppeqop, &pc.Conffeqop, &pc.Conexclop, &pc.Conbin, &pc.Consrc) if err != nil { return nil, err } return &pc, nil }
[ "func", "PgConstraintByOid", "(", "db", "XODB", ",", "oid", "pgtypes", ".", "Oid", ")", "(", "*", "PgConstraint", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, conname, connamespace, contype, condeferrable, condeferred, convalidated, conrelid, contypid, conindid, confrelid, confupdtype, confdeltype, confmatchtype, conislocal, coninhcount, connoinherit, conkey, confkey, conpfeqop, conppeqop, conffeqop, conexclop, conbin, consrc `", "+", "`FROM pg_catalog.pg_constraint `", "+", "`WHERE oid = $1`", "\n", "XOLog", "(", "sqlstr", ",", "oid", ")", "\n", "pc", ":=", "PgConstraint", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "oid", ")", ".", "Scan", "(", "&", "pc", ".", "Tableoid", ",", "&", "pc", ".", "Cmax", ",", "&", "pc", ".", "Xmax", ",", "&", "pc", ".", "Cmin", ",", "&", "pc", ".", "Xmin", ",", "&", "pc", ".", "Oid", ",", "&", "pc", ".", "Ctid", ",", "&", "pc", ".", "Conname", ",", "&", "pc", ".", "Connamespace", ",", "&", "pc", ".", "Contype", ",", "&", "pc", ".", "Condeferrable", ",", "&", "pc", ".", "Condeferred", ",", "&", "pc", ".", "Convalidated", ",", "&", "pc", ".", "Conrelid", ",", "&", "pc", ".", "Contypid", ",", "&", "pc", ".", "Conindid", ",", "&", "pc", ".", "Confrelid", ",", "&", "pc", ".", "Confupdtype", ",", "&", "pc", ".", "Confdeltype", ",", "&", "pc", ".", "Confmatchtype", ",", "&", "pc", ".", "Conislocal", ",", "&", "pc", ".", "Coninhcount", ",", "&", "pc", ".", "Connoinherit", ",", "&", "pc", ".", "Conkey", ",", "&", "pc", ".", "Confkey", ",", "&", "pc", ".", "Conpfeqop", ",", "&", "pc", ".", "Conppeqop", ",", "&", "pc", ".", "Conffeqop", ",", "&", "pc", ".", "Conexclop", ",", "&", "pc", ".", "Conbin", ",", "&", "pc", ".", "Consrc", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pc", ",", "nil", "\n", "}" ]
// PgConstraintByOid retrieves a row from 'pg_catalog.pg_constraint' as a PgConstraint. // // Generated from index 'pg_constraint_oid_index'.
[ "PgConstraintByOid", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_constraint", "as", "a", "PgConstraint", ".", "Generated", "from", "index", "pg_constraint_oid_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L42420-L42439
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgConversionByConnamespaceConforencodingContoencodingOid
func PgConversionByConnamespaceConforencodingContoencodingOid(db XODB, connamespace pgtypes.Oid, conforencoding int, contoencoding int, oid pgtypes.Oid) (*PgConversion, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, conname, connamespace, conowner, conforencoding, contoencoding, conproc, condefault ` + `FROM pg_catalog.pg_conversion ` + `WHERE connamespace = $1 AND conforencoding = $2 AND contoencoding = $3 AND oid = $4` // run query XOLog(sqlstr, connamespace, conforencoding, contoencoding, oid) pc := PgConversion{} err = db.QueryRow(sqlstr, connamespace, conforencoding, contoencoding, oid).Scan(&pc.Tableoid, &pc.Cmax, &pc.Xmax, &pc.Cmin, &pc.Xmin, &pc.Oid, &pc.Ctid, &pc.Conname, &pc.Connamespace, &pc.Conowner, &pc.Conforencoding, &pc.Contoencoding, &pc.Conproc, &pc.Condefault) if err != nil { return nil, err } return &pc, nil }
go
func PgConversionByConnamespaceConforencodingContoencodingOid(db XODB, connamespace pgtypes.Oid, conforencoding int, contoencoding int, oid pgtypes.Oid) (*PgConversion, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, conname, connamespace, conowner, conforencoding, contoencoding, conproc, condefault ` + `FROM pg_catalog.pg_conversion ` + `WHERE connamespace = $1 AND conforencoding = $2 AND contoencoding = $3 AND oid = $4` // run query XOLog(sqlstr, connamespace, conforencoding, contoencoding, oid) pc := PgConversion{} err = db.QueryRow(sqlstr, connamespace, conforencoding, contoencoding, oid).Scan(&pc.Tableoid, &pc.Cmax, &pc.Xmax, &pc.Cmin, &pc.Xmin, &pc.Oid, &pc.Ctid, &pc.Conname, &pc.Connamespace, &pc.Conowner, &pc.Conforencoding, &pc.Contoencoding, &pc.Conproc, &pc.Condefault) if err != nil { return nil, err } return &pc, nil }
[ "func", "PgConversionByConnamespaceConforencodingContoencodingOid", "(", "db", "XODB", ",", "connamespace", "pgtypes", ".", "Oid", ",", "conforencoding", "int", ",", "contoencoding", "int", ",", "oid", "pgtypes", ".", "Oid", ")", "(", "*", "PgConversion", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, conname, connamespace, conowner, conforencoding, contoencoding, conproc, condefault `", "+", "`FROM pg_catalog.pg_conversion `", "+", "`WHERE connamespace = $1 AND conforencoding = $2 AND contoencoding = $3 AND oid = $4`", "\n", "XOLog", "(", "sqlstr", ",", "connamespace", ",", "conforencoding", ",", "contoencoding", ",", "oid", ")", "\n", "pc", ":=", "PgConversion", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "connamespace", ",", "conforencoding", ",", "contoencoding", ",", "oid", ")", ".", "Scan", "(", "&", "pc", ".", "Tableoid", ",", "&", "pc", ".", "Cmax", ",", "&", "pc", ".", "Xmax", ",", "&", "pc", ".", "Cmin", ",", "&", "pc", ".", "Xmin", ",", "&", "pc", ".", "Oid", ",", "&", "pc", ".", "Ctid", ",", "&", "pc", ".", "Conname", ",", "&", "pc", ".", "Connamespace", ",", "&", "pc", ".", "Conowner", ",", "&", "pc", ".", "Conforencoding", ",", "&", "pc", ".", "Contoencoding", ",", "&", "pc", ".", "Conproc", ",", "&", "pc", ".", "Condefault", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pc", ",", "nil", "\n", "}" ]
// PgConversionByConnamespaceConforencodingContoencodingOid retrieves a row from 'pg_catalog.pg_conversion' as a PgConversion. // // Generated from index 'pg_conversion_default_index'.
[ "PgConversionByConnamespaceConforencodingContoencodingOid", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_conversion", "as", "a", "PgConversion", ".", "Generated", "from", "index", "pg_conversion_default_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L42444-L42463
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgDatabaseByDatname
func PgDatabaseByDatname(db XODB, datname pgtypes.Name) (*PgDatabase, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, datname, datdba, encoding, datcollate, datctype, datistemplate, datallowconn, datconnlimit, datlastsysoid, datfrozenxid, datminmxid, dattablespace, datacl ` + `FROM pg_catalog.pg_database ` + `WHERE datname = $1` // run query XOLog(sqlstr, datname) pd := PgDatabase{} err = db.QueryRow(sqlstr, datname).Scan(&pd.Tableoid, &pd.Cmax, &pd.Xmax, &pd.Cmin, &pd.Xmin, &pd.Oid, &pd.Ctid, &pd.Datname, &pd.Datdba, &pd.Encoding, &pd.Datcollate, &pd.Datctype, &pd.Datistemplate, &pd.Datallowconn, &pd.Datconnlimit, &pd.Datlastsysoid, &pd.Datfrozenxid, &pd.Datminmxid, &pd.Dattablespace, &pd.Datacl) if err != nil { return nil, err } return &pd, nil }
go
func PgDatabaseByDatname(db XODB, datname pgtypes.Name) (*PgDatabase, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, datname, datdba, encoding, datcollate, datctype, datistemplate, datallowconn, datconnlimit, datlastsysoid, datfrozenxid, datminmxid, dattablespace, datacl ` + `FROM pg_catalog.pg_database ` + `WHERE datname = $1` // run query XOLog(sqlstr, datname) pd := PgDatabase{} err = db.QueryRow(sqlstr, datname).Scan(&pd.Tableoid, &pd.Cmax, &pd.Xmax, &pd.Cmin, &pd.Xmin, &pd.Oid, &pd.Ctid, &pd.Datname, &pd.Datdba, &pd.Encoding, &pd.Datcollate, &pd.Datctype, &pd.Datistemplate, &pd.Datallowconn, &pd.Datconnlimit, &pd.Datlastsysoid, &pd.Datfrozenxid, &pd.Datminmxid, &pd.Dattablespace, &pd.Datacl) if err != nil { return nil, err } return &pd, nil }
[ "func", "PgDatabaseByDatname", "(", "db", "XODB", ",", "datname", "pgtypes", ".", "Name", ")", "(", "*", "PgDatabase", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, datname, datdba, encoding, datcollate, datctype, datistemplate, datallowconn, datconnlimit, datlastsysoid, datfrozenxid, datminmxid, dattablespace, datacl `", "+", "`FROM pg_catalog.pg_database `", "+", "`WHERE datname = $1`", "\n", "XOLog", "(", "sqlstr", ",", "datname", ")", "\n", "pd", ":=", "PgDatabase", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "datname", ")", ".", "Scan", "(", "&", "pd", ".", "Tableoid", ",", "&", "pd", ".", "Cmax", ",", "&", "pd", ".", "Xmax", ",", "&", "pd", ".", "Cmin", ",", "&", "pd", ".", "Xmin", ",", "&", "pd", ".", "Oid", ",", "&", "pd", ".", "Ctid", ",", "&", "pd", ".", "Datname", ",", "&", "pd", ".", "Datdba", ",", "&", "pd", ".", "Encoding", ",", "&", "pd", ".", "Datcollate", ",", "&", "pd", ".", "Datctype", ",", "&", "pd", ".", "Datistemplate", ",", "&", "pd", ".", "Datallowconn", ",", "&", "pd", ".", "Datconnlimit", ",", "&", "pd", ".", "Datlastsysoid", ",", "&", "pd", ".", "Datfrozenxid", ",", "&", "pd", ".", "Datminmxid", ",", "&", "pd", ".", "Dattablespace", ",", "&", "pd", ".", "Datacl", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pd", ",", "nil", "\n", "}" ]
// PgDatabaseByDatname retrieves a row from 'pg_catalog.pg_database' as a PgDatabase. // // Generated from index 'pg_database_datname_index'.
[ "PgDatabaseByDatname", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_database", "as", "a", "PgDatabase", ".", "Generated", "from", "index", "pg_database_datname_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L42516-L42535
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgDbRoleSettingBySetdatabaseSetrole
func PgDbRoleSettingBySetdatabaseSetrole(db XODB, setdatabase pgtypes.Oid, setrole pgtypes.Oid) (*PgDbRoleSetting, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, ctid, setdatabase, setrole, setconfig ` + `FROM pg_catalog.pg_db_role_setting ` + `WHERE setdatabase = $1 AND setrole = $2` // run query XOLog(sqlstr, setdatabase, setrole) pdrs := PgDbRoleSetting{} err = db.QueryRow(sqlstr, setdatabase, setrole).Scan(&pdrs.Tableoid, &pdrs.Cmax, &pdrs.Xmax, &pdrs.Cmin, &pdrs.Xmin, &pdrs.Ctid, &pdrs.Setdatabase, &pdrs.Setrole, &pdrs.Setconfig) if err != nil { return nil, err } return &pdrs, nil }
go
func PgDbRoleSettingBySetdatabaseSetrole(db XODB, setdatabase pgtypes.Oid, setrole pgtypes.Oid) (*PgDbRoleSetting, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, ctid, setdatabase, setrole, setconfig ` + `FROM pg_catalog.pg_db_role_setting ` + `WHERE setdatabase = $1 AND setrole = $2` // run query XOLog(sqlstr, setdatabase, setrole) pdrs := PgDbRoleSetting{} err = db.QueryRow(sqlstr, setdatabase, setrole).Scan(&pdrs.Tableoid, &pdrs.Cmax, &pdrs.Xmax, &pdrs.Cmin, &pdrs.Xmin, &pdrs.Ctid, &pdrs.Setdatabase, &pdrs.Setrole, &pdrs.Setconfig) if err != nil { return nil, err } return &pdrs, nil }
[ "func", "PgDbRoleSettingBySetdatabaseSetrole", "(", "db", "XODB", ",", "setdatabase", "pgtypes", ".", "Oid", ",", "setrole", "pgtypes", ".", "Oid", ")", "(", "*", "PgDbRoleSetting", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, ctid, setdatabase, setrole, setconfig `", "+", "`FROM pg_catalog.pg_db_role_setting `", "+", "`WHERE setdatabase = $1 AND setrole = $2`", "\n", "XOLog", "(", "sqlstr", ",", "setdatabase", ",", "setrole", ")", "\n", "pdrs", ":=", "PgDbRoleSetting", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "setdatabase", ",", "setrole", ")", ".", "Scan", "(", "&", "pdrs", ".", "Tableoid", ",", "&", "pdrs", ".", "Cmax", ",", "&", "pdrs", ".", "Xmax", ",", "&", "pdrs", ".", "Cmin", ",", "&", "pdrs", ".", "Xmin", ",", "&", "pdrs", ".", "Ctid", ",", "&", "pdrs", ".", "Setdatabase", ",", "&", "pdrs", ".", "Setrole", ",", "&", "pdrs", ".", "Setconfig", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pdrs", ",", "nil", "\n", "}" ]
// PgDbRoleSettingBySetdatabaseSetrole retrieves a row from 'pg_catalog.pg_db_role_setting' as a PgDbRoleSetting. // // Generated from index 'pg_db_role_setting_databaseid_rol_index'.
[ "PgDbRoleSettingBySetdatabaseSetrole", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_db_role_setting", "as", "a", "PgDbRoleSetting", ".", "Generated", "from", "index", "pg_db_role_setting_databaseid_rol_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L42564-L42583
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgDefaultACLByOid
func PgDefaultACLByOid(db XODB, oid pgtypes.Oid) (*PgDefaultACL, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, defaclrole, defaclnamespace, defaclobjtype, defaclacl ` + `FROM pg_catalog.pg_default_acl ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pda := PgDefaultACL{} err = db.QueryRow(sqlstr, oid).Scan(&pda.Tableoid, &pda.Cmax, &pda.Xmax, &pda.Cmin, &pda.Xmin, &pda.Oid, &pda.Ctid, &pda.Defaclrole, &pda.Defaclnamespace, &pda.Defaclobjtype, &pda.Defaclacl) if err != nil { return nil, err } return &pda, nil }
go
func PgDefaultACLByOid(db XODB, oid pgtypes.Oid) (*PgDefaultACL, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, defaclrole, defaclnamespace, defaclobjtype, defaclacl ` + `FROM pg_catalog.pg_default_acl ` + `WHERE oid = $1` // run query XOLog(sqlstr, oid) pda := PgDefaultACL{} err = db.QueryRow(sqlstr, oid).Scan(&pda.Tableoid, &pda.Cmax, &pda.Xmax, &pda.Cmin, &pda.Xmin, &pda.Oid, &pda.Ctid, &pda.Defaclrole, &pda.Defaclnamespace, &pda.Defaclobjtype, &pda.Defaclacl) if err != nil { return nil, err } return &pda, nil }
[ "func", "PgDefaultACLByOid", "(", "db", "XODB", ",", "oid", "pgtypes", ".", "Oid", ")", "(", "*", "PgDefaultACL", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, defaclrole, defaclnamespace, defaclobjtype, defaclacl `", "+", "`FROM pg_catalog.pg_default_acl `", "+", "`WHERE oid = $1`", "\n", "XOLog", "(", "sqlstr", ",", "oid", ")", "\n", "pda", ":=", "PgDefaultACL", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "oid", ")", ".", "Scan", "(", "&", "pda", ".", "Tableoid", ",", "&", "pda", ".", "Cmax", ",", "&", "pda", ".", "Xmax", ",", "&", "pda", ".", "Cmin", ",", "&", "pda", ".", "Xmin", ",", "&", "pda", ".", "Oid", ",", "&", "pda", ".", "Ctid", ",", "&", "pda", ".", "Defaclrole", ",", "&", "pda", ".", "Defaclnamespace", ",", "&", "pda", ".", "Defaclobjtype", ",", "&", "pda", ".", "Defaclacl", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pda", ",", "nil", "\n", "}" ]
// PgDefaultACLByOid retrieves a row from 'pg_catalog.pg_default_acl' as a PgDefaultACL. // // Generated from index 'pg_default_acl_oid_index'.
[ "PgDefaultACLByOid", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_default_acl", "as", "a", "PgDefaultACL", ".", "Generated", "from", "index", "pg_default_acl_oid_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L42588-L42607
train
xo/xo
examples/pgcatalog/pgcatalog/pgcatalog.xo.go
PgDefaultACLByDefaclroleDefaclnamespaceDefaclobjtype
func PgDefaultACLByDefaclroleDefaclnamespaceDefaclobjtype(db XODB, defaclrole pgtypes.Oid, defaclnamespace pgtypes.Oid, defaclobjtype uint8) (*PgDefaultACL, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, defaclrole, defaclnamespace, defaclobjtype, defaclacl ` + `FROM pg_catalog.pg_default_acl ` + `WHERE defaclrole = $1 AND defaclnamespace = $2 AND defaclobjtype = $3` // run query XOLog(sqlstr, defaclrole, defaclnamespace, defaclobjtype) pda := PgDefaultACL{} err = db.QueryRow(sqlstr, defaclrole, defaclnamespace, defaclobjtype).Scan(&pda.Tableoid, &pda.Cmax, &pda.Xmax, &pda.Cmin, &pda.Xmin, &pda.Oid, &pda.Ctid, &pda.Defaclrole, &pda.Defaclnamespace, &pda.Defaclobjtype, &pda.Defaclacl) if err != nil { return nil, err } return &pda, nil }
go
func PgDefaultACLByDefaclroleDefaclnamespaceDefaclobjtype(db XODB, defaclrole pgtypes.Oid, defaclnamespace pgtypes.Oid, defaclobjtype uint8) (*PgDefaultACL, error) { var err error // sql query const sqlstr = `SELECT ` + `tableoid, cmax, xmax, cmin, xmin, oid, ctid, defaclrole, defaclnamespace, defaclobjtype, defaclacl ` + `FROM pg_catalog.pg_default_acl ` + `WHERE defaclrole = $1 AND defaclnamespace = $2 AND defaclobjtype = $3` // run query XOLog(sqlstr, defaclrole, defaclnamespace, defaclobjtype) pda := PgDefaultACL{} err = db.QueryRow(sqlstr, defaclrole, defaclnamespace, defaclobjtype).Scan(&pda.Tableoid, &pda.Cmax, &pda.Xmax, &pda.Cmin, &pda.Xmin, &pda.Oid, &pda.Ctid, &pda.Defaclrole, &pda.Defaclnamespace, &pda.Defaclobjtype, &pda.Defaclacl) if err != nil { return nil, err } return &pda, nil }
[ "func", "PgDefaultACLByDefaclroleDefaclnamespaceDefaclobjtype", "(", "db", "XODB", ",", "defaclrole", "pgtypes", ".", "Oid", ",", "defaclnamespace", "pgtypes", ".", "Oid", ",", "defaclobjtype", "uint8", ")", "(", "*", "PgDefaultACL", ",", "error", ")", "{", "var", "err", "error", "\n", "const", "sqlstr", "=", "`SELECT `", "+", "`tableoid, cmax, xmax, cmin, xmin, oid, ctid, defaclrole, defaclnamespace, defaclobjtype, defaclacl `", "+", "`FROM pg_catalog.pg_default_acl `", "+", "`WHERE defaclrole = $1 AND defaclnamespace = $2 AND defaclobjtype = $3`", "\n", "XOLog", "(", "sqlstr", ",", "defaclrole", ",", "defaclnamespace", ",", "defaclobjtype", ")", "\n", "pda", ":=", "PgDefaultACL", "{", "}", "\n", "err", "=", "db", ".", "QueryRow", "(", "sqlstr", ",", "defaclrole", ",", "defaclnamespace", ",", "defaclobjtype", ")", ".", "Scan", "(", "&", "pda", ".", "Tableoid", ",", "&", "pda", ".", "Cmax", ",", "&", "pda", ".", "Xmax", ",", "&", "pda", ".", "Cmin", ",", "&", "pda", ".", "Xmin", ",", "&", "pda", ".", "Oid", ",", "&", "pda", ".", "Ctid", ",", "&", "pda", ".", "Defaclrole", ",", "&", "pda", ".", "Defaclnamespace", ",", "&", "pda", ".", "Defaclobjtype", ",", "&", "pda", ".", "Defaclacl", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "pda", ",", "nil", "\n", "}" ]
// PgDefaultACLByDefaclroleDefaclnamespaceDefaclobjtype retrieves a row from 'pg_catalog.pg_default_acl' as a PgDefaultACL. // // Generated from index 'pg_default_acl_role_nsp_obj_index'.
[ "PgDefaultACLByDefaclroleDefaclnamespaceDefaclobjtype", "retrieves", "a", "row", "from", "pg_catalog", ".", "pg_default_acl", "as", "a", "PgDefaultACL", ".", "Generated", "from", "index", "pg_default_acl_role_nsp_obj_index", "." ]
1a94fa516029cb306cce6d379d086e4d5b5bb232
https://github.com/xo/xo/blob/1a94fa516029cb306cce6d379d086e4d5b5bb232/examples/pgcatalog/pgcatalog/pgcatalog.xo.go#L42612-L42631
train