id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
19,500
trustmaster/goflow
graph_connect.go
incSendChanRefCount
func (n *Graph) incSendChanRefCount(c reflect.Value) { n.sendChanMutex.Lock() defer n.sendChanMutex.Unlock() ptr := c.Pointer() cnt := n.sendChanRefCount[ptr] cnt++ n.sendChanRefCount[ptr] = cnt }
go
func (n *Graph) incSendChanRefCount(c reflect.Value) { n.sendChanMutex.Lock() defer n.sendChanMutex.Unlock() ptr := c.Pointer() cnt := n.sendChanRefCount[ptr] cnt++ n.sendChanRefCount[ptr] = cnt }
[ "func", "(", "n", "*", "Graph", ")", "incSendChanRefCount", "(", "c", "reflect", ".", "Value", ")", "{", "n", ".", "sendChanMutex", ".", "Lock", "(", ")", "\n", "defer", "n", ".", "sendChanMutex", ".", "Unlock", "(", ")", "\n\n", "ptr", ":=", "c", ...
// IncSendChanRefCount increments SendChanRefCount. // The count is needed when multiple senders are connected // to the same receiver. When the network is terminated and // senders need to close their output port, this counter // can help to avoid closing the same channel multiple times.
[ "IncSendChanRefCount", "increments", "SendChanRefCount", ".", "The", "count", "is", "needed", "when", "multiple", "senders", "are", "connected", "to", "the", "same", "receiver", ".", "When", "the", "network", "is", "terminated", "and", "senders", "need", "to", "...
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/graph_connect.go#L195-L203
19,501
trustmaster/goflow
graph_connect.go
decSendChanRefCount
func (n *Graph) decSendChanRefCount(c reflect.Value) bool { n.sendChanMutex.Lock() defer n.sendChanMutex.Unlock() ptr := c.Pointer() cnt := n.sendChanRefCount[ptr] if cnt == 0 { return true //yes you may try to close a nonexistant channel, see what happens... } cnt-- n.sendChanRefCount[ptr] = cnt return cnt...
go
func (n *Graph) decSendChanRefCount(c reflect.Value) bool { n.sendChanMutex.Lock() defer n.sendChanMutex.Unlock() ptr := c.Pointer() cnt := n.sendChanRefCount[ptr] if cnt == 0 { return true //yes you may try to close a nonexistant channel, see what happens... } cnt-- n.sendChanRefCount[ptr] = cnt return cnt...
[ "func", "(", "n", "*", "Graph", ")", "decSendChanRefCount", "(", "c", "reflect", ".", "Value", ")", "bool", "{", "n", ".", "sendChanMutex", ".", "Lock", "(", ")", "\n", "defer", "n", ".", "sendChanMutex", ".", "Unlock", "(", ")", "\n\n", "ptr", ":=",...
// DecSendChanRefCount decrements SendChanRefCount // It returns true if the RefCount has reached 0
[ "DecSendChanRefCount", "decrements", "SendChanRefCount", "It", "returns", "true", "if", "the", "RefCount", "has", "reached", "0" ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/graph_connect.go#L207-L219
19,502
trustmaster/goflow
graph_ports.go
getInPort
func (n *Graph) getInPort(name string) (reflect.Value, error) { pName, ok := n.inPorts[name] if !ok { return reflect.ValueOf(nil), fmt.Errorf("Inport not found: '%s'", name) } return pName.channel, nil }
go
func (n *Graph) getInPort(name string) (reflect.Value, error) { pName, ok := n.inPorts[name] if !ok { return reflect.ValueOf(nil), fmt.Errorf("Inport not found: '%s'", name) } return pName.channel, nil }
[ "func", "(", "n", "*", "Graph", ")", "getInPort", "(", "name", "string", ")", "(", "reflect", ".", "Value", ",", "error", ")", "{", "pName", ",", "ok", ":=", "n", ".", "inPorts", "[", "name", "]", "\n", "if", "!", "ok", "{", "return", "reflect", ...
// getInPort returns the inport with given name as reflect.Value channel.
[ "getInPort", "returns", "the", "inport", "with", "given", "name", "as", "reflect", ".", "Value", "channel", "." ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/graph_ports.go#L9-L15
19,503
trustmaster/goflow
graph_ports.go
getOutPort
func (n *Graph) getOutPort(name string) (reflect.Value, error) { pName, ok := n.outPorts[name] if !ok { return reflect.ValueOf(nil), fmt.Errorf("Outport not found: '%s'", name) } return pName.channel, nil }
go
func (n *Graph) getOutPort(name string) (reflect.Value, error) { pName, ok := n.outPorts[name] if !ok { return reflect.ValueOf(nil), fmt.Errorf("Outport not found: '%s'", name) } return pName.channel, nil }
[ "func", "(", "n", "*", "Graph", ")", "getOutPort", "(", "name", "string", ")", "(", "reflect", ".", "Value", ",", "error", ")", "{", "pName", ",", "ok", ":=", "n", ".", "outPorts", "[", "name", "]", "\n", "if", "!", "ok", "{", "return", "reflect"...
// getOutPort returns the outport with given name as reflect.Value channel.
[ "getOutPort", "returns", "the", "outport", "with", "given", "name", "as", "reflect", ".", "Value", "channel", "." ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/graph_ports.go#L18-L24
19,504
trustmaster/goflow
graph_ports.go
MapInPort
func (n *Graph) MapInPort(name, procName, procPort string) error { var channel reflect.Value var err error if p, procFound := n.procs[procName]; procFound { if g, isNet := p.(*Graph); isNet { // Is a subnet channel, err = g.getInPort(procPort) } else { // Is a proc channel, err = n.getProcPort(procNa...
go
func (n *Graph) MapInPort(name, procName, procPort string) error { var channel reflect.Value var err error if p, procFound := n.procs[procName]; procFound { if g, isNet := p.(*Graph); isNet { // Is a subnet channel, err = g.getInPort(procPort) } else { // Is a proc channel, err = n.getProcPort(procNa...
[ "func", "(", "n", "*", "Graph", ")", "MapInPort", "(", "name", ",", "procName", ",", "procPort", "string", ")", "error", "{", "var", "channel", "reflect", ".", "Value", "\n", "var", "err", "error", "\n", "if", "p", ",", "procFound", ":=", "n", ".", ...
// MapInPort adds an inport to the net and maps it to a contained proc's port.
[ "MapInPort", "adds", "an", "inport", "to", "the", "net", "and", "maps", "it", "to", "a", "contained", "proc", "s", "port", "." ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/graph_ports.go#L27-L45
19,505
trustmaster/goflow
graph_iip.go
AddIIP
func (n *Graph) AddIIP(processName, portName string, data interface{}) error { if _, exists := n.procs[processName]; exists { n.iips = append(n.iips, iip{data: data, proc: processName, port: portName}) return nil } return fmt.Errorf("AddIIP error: could not find '%s.%s'", processName, portName) }
go
func (n *Graph) AddIIP(processName, portName string, data interface{}) error { if _, exists := n.procs[processName]; exists { n.iips = append(n.iips, iip{data: data, proc: processName, port: portName}) return nil } return fmt.Errorf("AddIIP error: could not find '%s.%s'", processName, portName) }
[ "func", "(", "n", "*", "Graph", ")", "AddIIP", "(", "processName", ",", "portName", "string", ",", "data", "interface", "{", "}", ")", "error", "{", "if", "_", ",", "exists", ":=", "n", ".", "procs", "[", "processName", "]", ";", "exists", "{", "n"...
// AddIIP adds an Initial Information packet to the network
[ "AddIIP", "adds", "an", "Initial", "Information", "packet", "to", "the", "network" ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/graph_iip.go#L17-L23
19,506
trustmaster/goflow
graph_iip.go
RemoveIIP
func (n *Graph) RemoveIIP(processName, portName string) error { for i, p := range n.iips { if p.proc == processName && p.port == portName { // Remove item from the slice n.iips[len(n.iips)-1], n.iips[i], n.iips = iip{}, n.iips[len(n.iips)-1], n.iips[:len(n.iips)-1] return nil } } return fmt.Errorf("Remo...
go
func (n *Graph) RemoveIIP(processName, portName string) error { for i, p := range n.iips { if p.proc == processName && p.port == portName { // Remove item from the slice n.iips[len(n.iips)-1], n.iips[i], n.iips = iip{}, n.iips[len(n.iips)-1], n.iips[:len(n.iips)-1] return nil } } return fmt.Errorf("Remo...
[ "func", "(", "n", "*", "Graph", ")", "RemoveIIP", "(", "processName", ",", "portName", "string", ")", "error", "{", "for", "i", ",", "p", ":=", "range", "n", ".", "iips", "{", "if", "p", ".", "proc", "==", "processName", "&&", "p", ".", "port", "...
// RemoveIIP detaches an IIP from specific process and port
[ "RemoveIIP", "detaches", "an", "IIP", "from", "specific", "process", "and", "port" ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/graph_iip.go#L26-L35
19,507
trustmaster/goflow
graph_iip.go
sendIIPs
func (n *Graph) sendIIPs() error { // Send initial IPs for _, ip := range n.iips { // Get the reciever port channel var channel reflect.Value found := false shouldClose := false // Try to find it among network inports for _, inPort := range n.inPorts { if inPort.proc == ip.proc && inPort.port == ip.po...
go
func (n *Graph) sendIIPs() error { // Send initial IPs for _, ip := range n.iips { // Get the reciever port channel var channel reflect.Value found := false shouldClose := false // Try to find it among network inports for _, inPort := range n.inPorts { if inPort.proc == ip.proc && inPort.port == ip.po...
[ "func", "(", "n", "*", "Graph", ")", "sendIIPs", "(", ")", "error", "{", "// Send initial IPs", "for", "_", ",", "ip", ":=", "range", "n", ".", "iips", "{", "// Get the reciever port channel", "var", "channel", "reflect", ".", "Value", "\n", "found", ":=",...
// sendIIPs sends Initial Information Packets upon network start
[ "sendIIPs", "sends", "Initial", "Information", "Packets", "upon", "network", "start" ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/graph_iip.go#L38-L95
19,508
trustmaster/goflow
graph.go
NewGraph
func NewGraph(config ...GraphConfig) *Graph { conf := defaultGraphConfig() if len(config) == 1 { conf = config[0] } return &Graph{ conf: conf, waitGrp: new(sync.WaitGroup), procs: make(map[string]interface{}, conf.Capacity), inPorts: make(map[string]port, conf.Cap...
go
func NewGraph(config ...GraphConfig) *Graph { conf := defaultGraphConfig() if len(config) == 1 { conf = config[0] } return &Graph{ conf: conf, waitGrp: new(sync.WaitGroup), procs: make(map[string]interface{}, conf.Capacity), inPorts: make(map[string]port, conf.Cap...
[ "func", "NewGraph", "(", "config", "...", "GraphConfig", ")", "*", "Graph", "{", "conf", ":=", "defaultGraphConfig", "(", ")", "\n", "if", "len", "(", "config", ")", "==", "1", "{", "conf", "=", "config", "[", "0", "]", "\n", "}", "\n\n", "return", ...
// NewGraph returns a new initialized empty graph instance
[ "NewGraph", "returns", "a", "new", "initialized", "empty", "graph", "instance" ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/graph.go#L46-L63
19,509
trustmaster/goflow
graph.go
AddGraph
func (n *Graph) AddGraph(name string) error { return n.Add(name, NewDefaultGraph()) }
go
func (n *Graph) AddGraph(name string) error { return n.Add(name, NewDefaultGraph()) }
[ "func", "(", "n", "*", "Graph", ")", "AddGraph", "(", "name", "string", ")", "error", "{", "return", "n", ".", "Add", "(", "name", ",", "NewDefaultGraph", "(", ")", ")", "\n", "}" ]
// AddGraph adds a new blank graph instance to a network. That instance can // be modified then at run-time.
[ "AddGraph", "adds", "a", "new", "blank", "graph", "instance", "to", "a", "network", ".", "That", "instance", "can", "be", "modified", "then", "at", "run", "-", "time", "." ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/graph.go#L94-L96
19,510
trustmaster/goflow
graph.go
AddNew
func (n *Graph) AddNew(processName string, componentName string, f *Factory) error { proc, err := f.Create(componentName) if err != nil { return err } return n.Add(processName, proc) }
go
func (n *Graph) AddNew(processName string, componentName string, f *Factory) error { proc, err := f.Create(componentName) if err != nil { return err } return n.Add(processName, proc) }
[ "func", "(", "n", "*", "Graph", ")", "AddNew", "(", "processName", "string", ",", "componentName", "string", ",", "f", "*", "Factory", ")", "error", "{", "proc", ",", "err", ":=", "f", ".", "Create", "(", "componentName", ")", "\n", "if", "err", "!="...
// AddNew creates a new process instance using component factory and adds it to the network.
[ "AddNew", "creates", "a", "new", "process", "instance", "using", "component", "factory", "and", "adds", "it", "to", "the", "network", "." ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/graph.go#L99-L105
19,511
trustmaster/goflow
graph.go
Remove
func (n *Graph) Remove(processName string) error { if _, exists := n.procs[processName]; !exists { return fmt.Errorf("Could not remove process: '%s' does not exist", processName) } delete(n.procs, processName) return nil }
go
func (n *Graph) Remove(processName string) error { if _, exists := n.procs[processName]; !exists { return fmt.Errorf("Could not remove process: '%s' does not exist", processName) } delete(n.procs, processName) return nil }
[ "func", "(", "n", "*", "Graph", ")", "Remove", "(", "processName", "string", ")", "error", "{", "if", "_", ",", "exists", ":=", "n", ".", "procs", "[", "processName", "]", ";", "!", "exists", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ...
// Remove deletes a process from the graph. First it stops the process if running. // Then it disconnects it from other processes and removes the connections from // the graph. Then it drops the process itself.
[ "Remove", "deletes", "a", "process", "from", "the", "graph", ".", "First", "it", "stops", "the", "process", "if", "running", ".", "Then", "it", "disconnects", "it", "from", "other", "processes", "and", "removes", "the", "connections", "from", "the", "graph",...
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/graph.go#L110-L116
19,512
leekchan/accounting
accounting.go
DefaultAccounting
func DefaultAccounting(symbol string, precision int) *Accounting { ac := &Accounting{Symbol:symbol,Precision:precision} ac.init() ac.isInitialized = true return ac }
go
func DefaultAccounting(symbol string, precision int) *Accounting { ac := &Accounting{Symbol:symbol,Precision:precision} ac.init() ac.isInitialized = true return ac }
[ "func", "DefaultAccounting", "(", "symbol", "string", ",", "precision", "int", ")", "*", "Accounting", "{", "ac", ":=", "&", "Accounting", "{", "Symbol", ":", "symbol", ",", "Precision", ":", "precision", "}", "\n", "ac", ".", "init", "(", ")", "\n", "...
// DefaultAccounting returns the Accounting with default settings
[ "DefaultAccounting", "returns", "the", "Accounting", "with", "default", "settings" ]
18a1925d6514182eb0947a2c117debce233d2e57
https://github.com/leekchan/accounting/blob/18a1925d6514182eb0947a2c117debce233d2e57/accounting.go#L24-L29
19,513
leekchan/accounting
accounting.go
NewAccounting
func NewAccounting(symbol string, precision int, thousand, decimal, format, formatNegative, formatZero string) *Accounting { ac := &Accounting{ Symbol: symbol, Precision: precision, Thousand: thousand, Decimal: decimal, Format: format, FormatNegative: formatNegative, FormatZero: formatZero, } ac.isInit...
go
func NewAccounting(symbol string, precision int, thousand, decimal, format, formatNegative, formatZero string) *Accounting { ac := &Accounting{ Symbol: symbol, Precision: precision, Thousand: thousand, Decimal: decimal, Format: format, FormatNegative: formatNegative, FormatZero: formatZero, } ac.isInit...
[ "func", "NewAccounting", "(", "symbol", "string", ",", "precision", "int", ",", "thousand", ",", "decimal", ",", "format", ",", "formatNegative", ",", "formatZero", "string", ")", "*", "Accounting", "{", "ac", ":=", "&", "Accounting", "{", "Symbol", ":", "...
// NewAccounting returns the Accounting with default settings
[ "NewAccounting", "returns", "the", "Accounting", "with", "default", "settings" ]
18a1925d6514182eb0947a2c117debce233d2e57
https://github.com/leekchan/accounting/blob/18a1925d6514182eb0947a2c117debce233d2e57/accounting.go#L33-L45
19,514
leekchan/accounting
accounting.go
FormatMoneyInt
func (accounting *Accounting) FormatMoneyInt(value int) string { if !accounting.isInitialized { accounting.init() } formattedNumber := FormatNumberInt(value, accounting.Precision, accounting.Thousand, accounting.Decimal) return accounting.formatMoneyString(formattedNumber) }
go
func (accounting *Accounting) FormatMoneyInt(value int) string { if !accounting.isInitialized { accounting.init() } formattedNumber := FormatNumberInt(value, accounting.Precision, accounting.Thousand, accounting.Decimal) return accounting.formatMoneyString(formattedNumber) }
[ "func", "(", "accounting", "*", "Accounting", ")", "FormatMoneyInt", "(", "value", "int", ")", "string", "{", "if", "!", "accounting", ".", "isInitialized", "{", "accounting", ".", "init", "(", ")", "\n", "}", "\n", "formattedNumber", ":=", "FormatNumberInt"...
// FormatMoneyInt only supports int type value. It is faster than FormatMoney, // because it does not do any runtime type evaluation.
[ "FormatMoneyInt", "only", "supports", "int", "type", "value", ".", "It", "is", "faster", "than", "FormatMoney", "because", "it", "does", "not", "do", "any", "runtime", "type", "evaluation", "." ]
18a1925d6514182eb0947a2c117debce233d2e57
https://github.com/leekchan/accounting/blob/18a1925d6514182eb0947a2c117debce233d2e57/accounting.go#L132-L138
19,515
leekchan/accounting
accounting.go
FormatMoneyDecimal
func (accounting *Accounting) FormatMoneyDecimal(value decimal.Decimal) string { accounting.init() formattedNumber := FormatNumberDecimal(value, accounting.Precision, accounting.Thousand, accounting.Decimal) return accounting.formatMoneyString(formattedNumber) }
go
func (accounting *Accounting) FormatMoneyDecimal(value decimal.Decimal) string { accounting.init() formattedNumber := FormatNumberDecimal(value, accounting.Precision, accounting.Thousand, accounting.Decimal) return accounting.formatMoneyString(formattedNumber) }
[ "func", "(", "accounting", "*", "Accounting", ")", "FormatMoneyDecimal", "(", "value", "decimal", ".", "Decimal", ")", "string", "{", "accounting", ".", "init", "(", ")", "\n", "formattedNumber", ":=", "FormatNumberDecimal", "(", "value", ",", "accounting", "....
// FormatMoneyDecimal only supports decimal.Decimal value. It is faster than FormatMoney, // because it does not do any runtime type evaluation.
[ "FormatMoneyDecimal", "only", "supports", "decimal", ".", "Decimal", "value", ".", "It", "is", "faster", "than", "FormatMoney", "because", "it", "does", "not", "do", "any", "runtime", "type", "evaluation", "." ]
18a1925d6514182eb0947a2c117debce233d2e57
https://github.com/leekchan/accounting/blob/18a1925d6514182eb0947a2c117debce233d2e57/accounting.go#L175-L179
19,516
leekchan/accounting
formatnumber.go
FormatNumberInt
func FormatNumberInt(x int, precision int, thousand string, decimalStr string) string { var result string var minus bool if x < 0 { if x * -1 < 0 { return FormatNumber(x, precision, thousand, decimalStr) } minus = true x *= -1 } for x >= 1000 { result = fmt.Sprintf("%s%03d%s", thousand, x%1000, res...
go
func FormatNumberInt(x int, precision int, thousand string, decimalStr string) string { var result string var minus bool if x < 0 { if x * -1 < 0 { return FormatNumber(x, precision, thousand, decimalStr) } minus = true x *= -1 } for x >= 1000 { result = fmt.Sprintf("%s%03d%s", thousand, x%1000, res...
[ "func", "FormatNumberInt", "(", "x", "int", ",", "precision", "int", ",", "thousand", "string", ",", "decimalStr", "string", ")", "string", "{", "var", "result", "string", "\n", "var", "minus", "bool", "\n\n", "if", "x", "<", "0", "{", "if", "x", "*", ...
// FormatNumberInt only supports int value. It is faster than FormatNumber, // because it does not do any runtime type evaluation.
[ "FormatNumberInt", "only", "supports", "int", "value", ".", "It", "is", "faster", "than", "FormatNumber", "because", "it", "does", "not", "do", "any", "runtime", "type", "evaluation", "." ]
18a1925d6514182eb0947a2c117debce233d2e57
https://github.com/leekchan/accounting/blob/18a1925d6514182eb0947a2c117debce233d2e57/formatnumber.go#L103-L131
19,517
leekchan/accounting
formatnumber.go
FormatNumberFloat64
func FormatNumberFloat64(x float64, precision int, thousand string, decimalStr string) string { return formatNumberString(fmt.Sprintf(fmt.Sprintf("%%.%df", precision), x), precision, thousand, decimalStr) }
go
func FormatNumberFloat64(x float64, precision int, thousand string, decimalStr string) string { return formatNumberString(fmt.Sprintf(fmt.Sprintf("%%.%df", precision), x), precision, thousand, decimalStr) }
[ "func", "FormatNumberFloat64", "(", "x", "float64", ",", "precision", "int", ",", "thousand", "string", ",", "decimalStr", "string", ")", "string", "{", "return", "formatNumberString", "(", "fmt", ".", "Sprintf", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ...
// FormatNumberFloat64 only supports float64 value. // It is faster than FormatNumber, because it does not do any runtime type evaluation.
[ "FormatNumberFloat64", "only", "supports", "float64", "value", ".", "It", "is", "faster", "than", "FormatNumber", "because", "it", "does", "not", "do", "any", "runtime", "type", "evaluation", "." ]
18a1925d6514182eb0947a2c117debce233d2e57
https://github.com/leekchan/accounting/blob/18a1925d6514182eb0947a2c117debce233d2e57/formatnumber.go#L135-L137
19,518
leekchan/accounting
formatnumber.go
FormatNumberDecimal
func FormatNumberDecimal(x decimal.Decimal, precision int, thousand string, decimalStr string) string { return formatNumberString(x.StringFixed(int32(precision)), precision, thousand, decimalStr) }
go
func FormatNumberDecimal(x decimal.Decimal, precision int, thousand string, decimalStr string) string { return formatNumberString(x.StringFixed(int32(precision)), precision, thousand, decimalStr) }
[ "func", "FormatNumberDecimal", "(", "x", "decimal", ".", "Decimal", ",", "precision", "int", ",", "thousand", "string", ",", "decimalStr", "string", ")", "string", "{", "return", "formatNumberString", "(", "x", ".", "StringFixed", "(", "int32", "(", "precision...
// FormatNumberDecimal only supports decimal.Decimal value. // It is faster than FormatNumber, because it does not do any runtime type evaluation.
[ "FormatNumberDecimal", "only", "supports", "decimal", ".", "Decimal", "value", ".", "It", "is", "faster", "than", "FormatNumber", "because", "it", "does", "not", "do", "any", "runtime", "type", "evaluation", "." ]
18a1925d6514182eb0947a2c117debce233d2e57
https://github.com/leekchan/accounting/blob/18a1925d6514182eb0947a2c117debce233d2e57/formatnumber.go#L155-L157
19,519
lileio/lile
cmd.go
BaseCommand
func BaseCommand(serviceName, shortDescription string) *cobra.Command { command := &cobra.Command{ Use: serviceName, Short: shortDescription, } command.PersistentFlags().StringVar(&service.Config.Host, "grpc_host", "0.0.0.0", "gRPC service hostname") command.PersistentFlags().IntVar(&service.Config.Port, "gr...
go
func BaseCommand(serviceName, shortDescription string) *cobra.Command { command := &cobra.Command{ Use: serviceName, Short: shortDescription, } command.PersistentFlags().StringVar(&service.Config.Host, "grpc_host", "0.0.0.0", "gRPC service hostname") command.PersistentFlags().IntVar(&service.Config.Port, "gr...
[ "func", "BaseCommand", "(", "serviceName", ",", "shortDescription", "string", ")", "*", "cobra", ".", "Command", "{", "command", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "serviceName", ",", "Short", ":", "shortDescription", ",", "}", "\n\n", "c...
// BaseCommand provides the basic flags vars for running a service
[ "BaseCommand", "provides", "the", "basic", "flags", "vars", "for", "running", "a", "service" ]
becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e
https://github.com/lileio/lile/blob/becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e/cmd.go#L6-L18
19,520
lileio/lile
run.go
ServeGRPC
func ServeGRPC() error { var err error service.ServiceListener, err = net.Listen("tcp", service.Config.Address()) if err != nil { return err } logrus.Infof("Serving gRPC on %s", service.Config.Address()) return createGrpcServer().Serve(service.ServiceListener) }
go
func ServeGRPC() error { var err error service.ServiceListener, err = net.Listen("tcp", service.Config.Address()) if err != nil { return err } logrus.Infof("Serving gRPC on %s", service.Config.Address()) return createGrpcServer().Serve(service.ServiceListener) }
[ "func", "ServeGRPC", "(", ")", "error", "{", "var", "err", "error", "\n", "service", ".", "ServiceListener", ",", "err", "=", "net", ".", "Listen", "(", "\"", "\"", ",", "service", ".", "Config", ".", "Address", "(", ")", ")", "\n", "if", "err", "!...
// ServeGRPC creates and runs a blocking gRPC server
[ "ServeGRPC", "creates", "and", "runs", "a", "blocking", "gRPC", "server" ]
becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e
https://github.com/lileio/lile/blob/becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e/run.go#L37-L46
19,521
lileio/lile
run.go
Shutdown
func Shutdown() { logrus.Infof("lile: Gracefully shutting down gRPC and Prometheus") if service.Registry != nil { service.Registry.DeRegister(service) } service.GRPCServer.GracefulStop() // 30 seconds is the default grace period in Kubernetes ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)...
go
func Shutdown() { logrus.Infof("lile: Gracefully shutting down gRPC and Prometheus") if service.Registry != nil { service.Registry.DeRegister(service) } service.GRPCServer.GracefulStop() // 30 seconds is the default grace period in Kubernetes ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)...
[ "func", "Shutdown", "(", ")", "{", "logrus", ".", "Infof", "(", "\"", "\"", ")", "\n\n", "if", "service", ".", "Registry", "!=", "nil", "{", "service", ".", "Registry", ".", "DeRegister", "(", "service", ")", "\n", "}", "\n\n", "service", ".", "GRPCS...
// Shutdown gracefully shuts down the gRPC and metrics servers
[ "Shutdown", "gracefully", "shuts", "down", "the", "gRPC", "and", "metrics", "servers" ]
becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e
https://github.com/lileio/lile/blob/becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e/run.go#L49-L64
19,522
lileio/lile
lile/cmd/project.go
SnakeCaseName
func (p project) SnakeCaseName() string { return strings.Replace(strcase.ToSnake(p.Name), "-", "_", -1) }
go
func (p project) SnakeCaseName() string { return strings.Replace(strcase.ToSnake(p.Name), "-", "_", -1) }
[ "func", "(", "p", "project", ")", "SnakeCaseName", "(", ")", "string", "{", "return", "strings", ".", "Replace", "(", "strcase", ".", "ToSnake", "(", "p", ".", "Name", ")", ",", "\"", "\"", ",", "\"", "\"", ",", "-", "1", ")", "\n", "}" ]
// SnakeCaseName returns a snake_cased_type name of the service
[ "SnakeCaseName", "returns", "a", "snake_cased_type", "name", "of", "the", "service" ]
becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e
https://github.com/lileio/lile/blob/becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e/lile/cmd/project.go#L70-L72
19,523
lileio/lile
lile.go
Address
func (c *ServerConfig) Address() string { return fmt.Sprintf("%s:%d", c.Host, c.Port) }
go
func (c *ServerConfig) Address() string { return fmt.Sprintf("%s:%d", c.Host, c.Port) }
[ "func", "(", "c", "*", "ServerConfig", ")", "Address", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "Host", ",", "c", ".", "Port", ")", "\n", "}" ]
// Address Gets a logical addr for a ServerConfig
[ "Address", "Gets", "a", "logical", "addr", "for", "a", "ServerConfig" ]
becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e
https://github.com/lileio/lile/blob/becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e/lile.go#L35-L37
19,524
lileio/lile
lile.go
NewService
func NewService(n string) *Service { return &Service{ ID: generateID(n), Name: n, Config: ServerConfig{Host: "0.0.0.0", Port: 8000}, PrometheusConfig: ServerConfig{Host: "0.0.0.0", Port: 9000}, GRPCImplementation: func(s *grpc.Server) {}, UnaryInts: []grpc.UnaryS...
go
func NewService(n string) *Service { return &Service{ ID: generateID(n), Name: n, Config: ServerConfig{Host: "0.0.0.0", Port: 8000}, PrometheusConfig: ServerConfig{Host: "0.0.0.0", Port: 9000}, GRPCImplementation: func(s *grpc.Server) {}, UnaryInts: []grpc.UnaryS...
[ "func", "NewService", "(", "n", "string", ")", "*", "Service", "{", "return", "&", "Service", "{", "ID", ":", "generateID", "(", "n", ")", ",", "Name", ":", "n", ",", "Config", ":", "ServerConfig", "{", "Host", ":", "\"", "\"", ",", "Port", ":", ...
// NewService creates a new service with a given name
[ "NewService", "creates", "a", "new", "service", "with", "a", "given", "name" ]
becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e
https://github.com/lileio/lile/blob/becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e/lile.go#L67-L83
19,525
lileio/lile
lile.go
Name
func Name(n string) { service.ID = generateID(n) service.Name = n AddUnaryInterceptor(otgrpc.OpenTracingServerInterceptor( fromenv.Tracer(n))) }
go
func Name(n string) { service.ID = generateID(n) service.Name = n AddUnaryInterceptor(otgrpc.OpenTracingServerInterceptor( fromenv.Tracer(n))) }
[ "func", "Name", "(", "n", "string", ")", "{", "service", ".", "ID", "=", "generateID", "(", "n", ")", "\n", "service", ".", "Name", "=", "n", "\n", "AddUnaryInterceptor", "(", "otgrpc", ".", "OpenTracingServerInterceptor", "(", "fromenv", ".", "Tracer", ...
// Name sets the name for the service
[ "Name", "sets", "the", "name", "for", "the", "service" ]
becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e
https://github.com/lileio/lile/blob/becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e/lile.go#L91-L96
19,526
lileio/lile
lile.go
AddUnaryInterceptor
func AddUnaryInterceptor(unint grpc.UnaryServerInterceptor) { service.UnaryInts = append(service.UnaryInts, unint) }
go
func AddUnaryInterceptor(unint grpc.UnaryServerInterceptor) { service.UnaryInts = append(service.UnaryInts, unint) }
[ "func", "AddUnaryInterceptor", "(", "unint", "grpc", ".", "UnaryServerInterceptor", ")", "{", "service", ".", "UnaryInts", "=", "append", "(", "service", ".", "UnaryInts", ",", "unint", ")", "\n", "}" ]
// AddUnaryInterceptor adds a unary interceptor to the RPC server
[ "AddUnaryInterceptor", "adds", "a", "unary", "interceptor", "to", "the", "RPC", "server" ]
becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e
https://github.com/lileio/lile/blob/becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e/lile.go#L104-L106
19,527
lileio/lile
lile.go
AddStreamInterceptor
func AddStreamInterceptor(sint grpc.StreamServerInterceptor) { service.StreamInts = append(service.StreamInts, sint) }
go
func AddStreamInterceptor(sint grpc.StreamServerInterceptor) { service.StreamInts = append(service.StreamInts, sint) }
[ "func", "AddStreamInterceptor", "(", "sint", "grpc", ".", "StreamServerInterceptor", ")", "{", "service", ".", "StreamInts", "=", "append", "(", "service", ".", "StreamInts", ",", "sint", ")", "\n", "}" ]
// AddStreamInterceptor adds a stream interceptor to the RPC server
[ "AddStreamInterceptor", "adds", "a", "stream", "interceptor", "to", "the", "RPC", "server" ]
becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e
https://github.com/lileio/lile/blob/becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e/lile.go#L109-L111
19,528
lileio/lile
lile.go
URLForService
func URLForService(name string) string { host := name port := "80" if val, ok := os.LookupEnv("SERVICE_HOST_OVERRIDE"); ok { host = val } if val, ok := os.LookupEnv("SERVICE_PORT_OVERRIDE"); ok { port = val } if service.Registry != nil { url, err := service.Registry.Get(name) if err != nil { fmt.Pr...
go
func URLForService(name string) string { host := name port := "80" if val, ok := os.LookupEnv("SERVICE_HOST_OVERRIDE"); ok { host = val } if val, ok := os.LookupEnv("SERVICE_PORT_OVERRIDE"); ok { port = val } if service.Registry != nil { url, err := service.Registry.Get(name) if err != nil { fmt.Pr...
[ "func", "URLForService", "(", "name", "string", ")", "string", "{", "host", ":=", "name", "\n", "port", ":=", "\"", "\"", "\n\n", "if", "val", ",", "ok", ":=", "os", ".", "LookupEnv", "(", "\"", "\"", ")", ";", "ok", "{", "host", "=", "val", "\n"...
// URLForService returns a service URL via a registry or a simple DNS name // if not available via the registry
[ "URLForService", "returns", "a", "service", "URL", "via", "a", "registry", "or", "a", "simple", "DNS", "name", "if", "not", "available", "via", "the", "registry" ]
becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e
https://github.com/lileio/lile/blob/becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e/lile.go#L115-L137
19,529
lileio/lile
lile.go
ContextClientInterceptor
func ContextClientInterceptor() grpc.UnaryClientInterceptor { return func( ctx context.Context, method string, req, resp interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption, ) error { pairs := make([]string, 0) if md, ok := metadata.FromIncomingContext(ctx); ok { f...
go
func ContextClientInterceptor() grpc.UnaryClientInterceptor { return func( ctx context.Context, method string, req, resp interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption, ) error { pairs := make([]string, 0) if md, ok := metadata.FromIncomingContext(ctx); ok { f...
[ "func", "ContextClientInterceptor", "(", ")", "grpc", ".", "UnaryClientInterceptor", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "method", "string", ",", "req", ",", "resp", "interface", "{", "}", ",", "cc", "*", "grpc", ".", "Client...
// ContextClientInterceptor passes around headers for tracing and linkerd
[ "ContextClientInterceptor", "passes", "around", "headers", "for", "tracing", "and", "linkerd" ]
becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e
https://github.com/lileio/lile/blob/becf404ea65c4dd7cbe6e8c6dd2a313d07359b4e/lile.go#L140-L170
19,530
constabulary/gb
cmd/env.go
MustGetwd
func MustGetwd() string { wd, err := os.Getwd() if err != nil { log.Fatalf("unable to determine current working directory: %v", err) } return wd }
go
func MustGetwd() string { wd, err := os.Getwd() if err != nil { log.Fatalf("unable to determine current working directory: %v", err) } return wd }
[ "func", "MustGetwd", "(", ")", "string", "{", "wd", ",", "err", ":=", "os", ".", "Getwd", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fatalf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "wd", "\n", "}" ]
// MustGetwd returns current working directory and fails otherwise
[ "MustGetwd", "returns", "current", "working", "directory", "and", "fails", "otherwise" ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cmd/env.go#L11-L17
19,531
constabulary/gb
cmd/env.go
MergeEnv
func MergeEnv(env []string, args map[string]string) []string { m := make(map[string]string) for _, e := range env { v := strings.SplitN(e, "=", 2) m[v[0]] = v[1] } for k, v := range args { m[k] = v } env = make([]string, 0, len(m)) for k, v := range m { env = append(env, fmt.Sprintf("%s=%s", k, v)) } r...
go
func MergeEnv(env []string, args map[string]string) []string { m := make(map[string]string) for _, e := range env { v := strings.SplitN(e, "=", 2) m[v[0]] = v[1] } for k, v := range args { m[k] = v } env = make([]string, 0, len(m)) for k, v := range m { env = append(env, fmt.Sprintf("%s=%s", k, v)) } r...
[ "func", "MergeEnv", "(", "env", "[", "]", "string", ",", "args", "map", "[", "string", "]", "string", ")", "[", "]", "string", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "for", "_", ",", "e", ":=", "range", "en...
// MergeEnv merges args into env, overwriting entries.
[ "MergeEnv", "merges", "args", "into", "env", "overwriting", "entries", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cmd/env.go#L20-L34
19,532
constabulary/gb
executor.go
ExecuteConcurrent
func ExecuteConcurrent(a *Action, n int, interrupt <-chan struct{}) error { var mu sync.Mutex // protects seen seen := make(map[*Action]chan error) get := func(result chan error) error { err := <-result result <- err return err } permits := make(chan bool, n) for i := 0; i < cap(permits); i++ { permits ...
go
func ExecuteConcurrent(a *Action, n int, interrupt <-chan struct{}) error { var mu sync.Mutex // protects seen seen := make(map[*Action]chan error) get := func(result chan error) error { err := <-result result <- err return err } permits := make(chan bool, n) for i := 0; i < cap(permits); i++ { permits ...
[ "func", "ExecuteConcurrent", "(", "a", "*", "Action", ",", "n", "int", ",", "interrupt", "<-", "chan", "struct", "{", "}", ")", "error", "{", "var", "mu", "sync", ".", "Mutex", "// protects seen", "\n", "seen", ":=", "make", "(", "map", "[", "*", "Ac...
// ExecuteConcurrent executes all actions in a tree concurrently. // Each Action will wait until its dependant actions are complete.
[ "ExecuteConcurrent", "executes", "all", "actions", "in", "a", "tree", "concurrently", ".", "Each", "Action", "will", "wait", "until", "its", "dependant", "actions", "are", "complete", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/executor.go#L36-L104
19,533
constabulary/gb
cmd/cmd.go
RunCommand
func RunCommand(fs *flag.FlagSet, cmd *Command, projectroot, goroot string, args []string) error { if cmd.AddFlags != nil { cmd.AddFlags(fs) } if err := fs.Parse(args); err != nil { fs.Usage() os.Exit(1) } args = fs.Args() // reset to the remaining arguments ctx, err := NewContext(projectroot, gb.GcToolcha...
go
func RunCommand(fs *flag.FlagSet, cmd *Command, projectroot, goroot string, args []string) error { if cmd.AddFlags != nil { cmd.AddFlags(fs) } if err := fs.Parse(args); err != nil { fs.Usage() os.Exit(1) } args = fs.Args() // reset to the remaining arguments ctx, err := NewContext(projectroot, gb.GcToolcha...
[ "func", "RunCommand", "(", "fs", "*", "flag", ".", "FlagSet", ",", "cmd", "*", "Command", ",", "projectroot", ",", "goroot", "string", ",", "args", "[", "]", "string", ")", "error", "{", "if", "cmd", ".", "AddFlags", "!=", "nil", "{", "cmd", ".", "...
// RunCommand detects the project root, parses flags and runs the Command.
[ "RunCommand", "detects", "the", "project", "root", "parses", "flags", "and", "runs", "the", "Command", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cmd/cmd.go#L49-L67
19,534
constabulary/gb
cmd/cmd.go
NewContext
func NewContext(projectroot string, options ...func(*gb.Context) error) (*gb.Context, error) { if projectroot == "" { return nil, errors.New("project root is blank") } root, err := FindProjectroot(projectroot) if err != nil { return nil, errors.Wrap(err, "could not locate project root") } proj := gb.NewProje...
go
func NewContext(projectroot string, options ...func(*gb.Context) error) (*gb.Context, error) { if projectroot == "" { return nil, errors.New("project root is blank") } root, err := FindProjectroot(projectroot) if err != nil { return nil, errors.Wrap(err, "could not locate project root") } proj := gb.NewProje...
[ "func", "NewContext", "(", "projectroot", "string", ",", "options", "...", "func", "(", "*", "gb", ".", "Context", ")", "error", ")", "(", "*", "gb", ".", "Context", ",", "error", ")", "{", "if", "projectroot", "==", "\"", "\"", "{", "return", "nil",...
// NewContext creates a gb.Context for the project root.
[ "NewContext", "creates", "a", "gb", ".", "Context", "for", "the", "project", "root", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cmd/cmd.go#L70-L87
19,535
constabulary/gb
internal/untar/untar.go
Untar
func Untar(dest string, r io.Reader) error { if exists(dest) { return errors.Errorf("%q must not exist", dest) } parent, _ := filepath.Split(dest) tmpdir, err := ioutil.TempDir(parent, ".untar") if err != nil { return err } if err := untar(tmpdir, r); err != nil { os.RemoveAll(tmpdir) return err } if...
go
func Untar(dest string, r io.Reader) error { if exists(dest) { return errors.Errorf("%q must not exist", dest) } parent, _ := filepath.Split(dest) tmpdir, err := ioutil.TempDir(parent, ".untar") if err != nil { return err } if err := untar(tmpdir, r); err != nil { os.RemoveAll(tmpdir) return err } if...
[ "func", "Untar", "(", "dest", "string", ",", "r", "io", ".", "Reader", ")", "error", "{", "if", "exists", "(", "dest", ")", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ",", "dest", ")", "\n", "}", "\n", "parent", ",", "_", ":=", "f...
// Untar extracts the contents of r to the destination dest. // dest must not aleady exist.
[ "Untar", "extracts", "the", "contents", "of", "r", "to", "the", "destination", "dest", ".", "dest", "must", "not", "aleady", "exist", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/internal/untar/untar.go#L15-L35
19,536
constabulary/gb
cmd/gb/internal/match/match.go
ImportPaths
func ImportPaths(srcdir, cwd string, args []string) []string { args = importPathsNoDotExpansion(srcdir, cwd, args) var out []string for _, a := range args { if strings.Contains(a, "...") { pkgs, err := matchPackages(srcdir, a) if err != nil { fmt.Printf("could not load all packages: %v\n", err) } o...
go
func ImportPaths(srcdir, cwd string, args []string) []string { args = importPathsNoDotExpansion(srcdir, cwd, args) var out []string for _, a := range args { if strings.Contains(a, "...") { pkgs, err := matchPackages(srcdir, a) if err != nil { fmt.Printf("could not load all packages: %v\n", err) } o...
[ "func", "ImportPaths", "(", "srcdir", ",", "cwd", "string", ",", "args", "[", "]", "string", ")", "[", "]", "string", "{", "args", "=", "importPathsNoDotExpansion", "(", "srcdir", ",", "cwd", ",", "args", ")", "\n", "var", "out", "[", "]", "string", ...
// ImportPaths returns the import paths to use for the given command line.
[ "ImportPaths", "returns", "the", "import", "paths", "to", "use", "for", "the", "given", "command", "line", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cmd/gb/internal/match/match.go#L37-L52
19,537
constabulary/gb
cmd/gb/internal/match/match.go
matchPackages
func matchPackages(srcdir, pattern string) ([]string, error) { match := matchPattern(pattern) treeCanMatch := treeCanMatchPattern(pattern) var pkgs []string src := srcdir + string(filepath.Separator) err := filepath.Walk(src, func(path string, fi os.FileInfo, err error) error { if err != nil || !fi.IsDir() || ...
go
func matchPackages(srcdir, pattern string) ([]string, error) { match := matchPattern(pattern) treeCanMatch := treeCanMatchPattern(pattern) var pkgs []string src := srcdir + string(filepath.Separator) err := filepath.Walk(src, func(path string, fi os.FileInfo, err error) error { if err != nil || !fi.IsDir() || ...
[ "func", "matchPackages", "(", "srcdir", ",", "pattern", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "match", ":=", "matchPattern", "(", "pattern", ")", "\n", "treeCanMatch", ":=", "treeCanMatchPattern", "(", "pattern", ")", "\n\n", "var...
// matchPackages returns all the packages that can be found under the srcdir directory. // The pattern is a path including "...".
[ "matchPackages", "returns", "all", "the", "packages", "that", "can", "be", "found", "under", "the", "srcdir", "directory", ".", "The", "pattern", "is", "a", "path", "including", "...", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cmd/gb/internal/match/match.go#L104-L134
19,538
constabulary/gb
build.go
BuildPackage
func BuildPackage(targets map[string]*Action, pkg *Package) (*Action, error) { // if this action is already present in the map, return it // rather than creating a new action. if a, ok := targets[pkg.ImportPath]; ok { return a, nil } // step 0. are we stale ? // if this package is not stale, then by definitio...
go
func BuildPackage(targets map[string]*Action, pkg *Package) (*Action, error) { // if this action is already present in the map, return it // rather than creating a new action. if a, ok := targets[pkg.ImportPath]; ok { return a, nil } // step 0. are we stale ? // if this package is not stale, then by definitio...
[ "func", "BuildPackage", "(", "targets", "map", "[", "string", "]", "*", "Action", ",", "pkg", "*", "Package", ")", "(", "*", "Action", ",", "error", ")", "{", "// if this action is already present in the map, return it", "// rather than creating a new action.", "if", ...
// BuildPackage returns an Action representing the steps required to // build this package.
[ "BuildPackage", "returns", "an", "Action", "representing", "the", "steps", "required", "to", "build", "this", "package", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/build.go#L75-L110
19,539
constabulary/gb
build.go
BuildDependencies
func BuildDependencies(targets map[string]*Action, pkg *Package) ([]*Action, error) { var deps []*Action pkgs := pkg.Imports var extra []string switch { case pkg.Main: // all binaries depend on runtime, even if they do not // explicitly import it. extra = append(extra, "runtime") if pkg.race { // race ...
go
func BuildDependencies(targets map[string]*Action, pkg *Package) ([]*Action, error) { var deps []*Action pkgs := pkg.Imports var extra []string switch { case pkg.Main: // all binaries depend on runtime, even if they do not // explicitly import it. extra = append(extra, "runtime") if pkg.race { // race ...
[ "func", "BuildDependencies", "(", "targets", "map", "[", "string", "]", "*", "Action", ",", "pkg", "*", "Package", ")", "(", "[", "]", "*", "Action", ",", "error", ")", "{", "var", "deps", "[", "]", "*", "Action", "\n", "pkgs", ":=", "pkg", ".", ...
// BuildDependencies returns a slice of Actions representing the steps required // to build all dependant packages of this package.
[ "BuildDependencies", "returns", "a", "slice", "of", "Actions", "representing", "the", "steps", "required", "to", "build", "all", "dependant", "packages", "of", "this", "package", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/build.go#L228-L274
19,540
constabulary/gb
context.go
GOOS
func GOOS(goos string) func(*Context) error { return func(c *Context) error { if goos == "" { return fmt.Errorf("GOOS cannot be blank") } c.gotargetos = goos return nil } }
go
func GOOS(goos string) func(*Context) error { return func(c *Context) error { if goos == "" { return fmt.Errorf("GOOS cannot be blank") } c.gotargetos = goos return nil } }
[ "func", "GOOS", "(", "goos", "string", ")", "func", "(", "*", "Context", ")", "error", "{", "return", "func", "(", "c", "*", "Context", ")", "error", "{", "if", "goos", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ...
// GOOS configures the Context to use goos as the target os.
[ "GOOS", "configures", "the", "Context", "to", "use", "goos", "as", "the", "target", "os", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/context.go#L66-L74
19,541
constabulary/gb
context.go
GOARCH
func GOARCH(goarch string) func(*Context) error { return func(c *Context) error { if goarch == "" { return fmt.Errorf("GOARCH cannot be blank") } c.gotargetarch = goarch return nil } }
go
func GOARCH(goarch string) func(*Context) error { return func(c *Context) error { if goarch == "" { return fmt.Errorf("GOARCH cannot be blank") } c.gotargetarch = goarch return nil } }
[ "func", "GOARCH", "(", "goarch", "string", ")", "func", "(", "*", "Context", ")", "error", "{", "return", "func", "(", "c", "*", "Context", ")", "error", "{", "if", "goarch", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ...
// GOARCH configures the Context to use goarch as the target arch.
[ "GOARCH", "configures", "the", "Context", "to", "use", "goarch", "as", "the", "target", "arch", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/context.go#L77-L85
19,542
constabulary/gb
context.go
Tags
func Tags(tags ...string) func(*Context) error { return func(c *Context) error { c.buildtags = append(c.buildtags, tags...) return nil } }
go
func Tags(tags ...string) func(*Context) error { return func(c *Context) error { c.buildtags = append(c.buildtags, tags...) return nil } }
[ "func", "Tags", "(", "tags", "...", "string", ")", "func", "(", "*", "Context", ")", "error", "{", "return", "func", "(", "c", "*", "Context", ")", "error", "{", "c", ".", "buildtags", "=", "append", "(", "c", ".", "buildtags", ",", "tags", "...", ...
// Tags configured the context to use these additional build tags
[ "Tags", "configured", "the", "context", "to", "use", "these", "additional", "build", "tags" ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/context.go#L88-L93
19,543
constabulary/gb
context.go
Gcflags
func Gcflags(flags ...string) func(*Context) error { return func(c *Context) error { c.gcflags = append(c.gcflags, flags...) return nil } }
go
func Gcflags(flags ...string) func(*Context) error { return func(c *Context) error { c.gcflags = append(c.gcflags, flags...) return nil } }
[ "func", "Gcflags", "(", "flags", "...", "string", ")", "func", "(", "*", "Context", ")", "error", "{", "return", "func", "(", "c", "*", "Context", ")", "error", "{", "c", ".", "gcflags", "=", "append", "(", "c", ".", "gcflags", ",", "flags", "...",...
// Gcflags appends flags to the list passed to the compiler.
[ "Gcflags", "appends", "flags", "to", "the", "list", "passed", "to", "the", "compiler", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/context.go#L96-L101
19,544
constabulary/gb
context.go
Ldflags
func Ldflags(flags ...string) func(*Context) error { return func(c *Context) error { c.ldflags = append(c.ldflags, flags...) return nil } }
go
func Ldflags(flags ...string) func(*Context) error { return func(c *Context) error { c.ldflags = append(c.ldflags, flags...) return nil } }
[ "func", "Ldflags", "(", "flags", "...", "string", ")", "func", "(", "*", "Context", ")", "error", "{", "return", "func", "(", "c", "*", "Context", ")", "error", "{", "c", ".", "ldflags", "=", "append", "(", "c", ".", "ldflags", ",", "flags", "...",...
// Ldflags appends flags to the list passed to the linker.
[ "Ldflags", "appends", "flags", "to", "the", "list", "passed", "to", "the", "linker", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/context.go#L104-L109
19,545
constabulary/gb
context.go
WithRace
func WithRace(c *Context) error { c.race = true Tags("race")(c) Gcflags("-race")(c) Ldflags("-race")(c) return nil }
go
func WithRace(c *Context) error { c.race = true Tags("race")(c) Gcflags("-race")(c) Ldflags("-race")(c) return nil }
[ "func", "WithRace", "(", "c", "*", "Context", ")", "error", "{", "c", ".", "race", "=", "true", "\n", "Tags", "(", "\"", "\"", ")", "(", "c", ")", "\n", "Gcflags", "(", "\"", "\"", ")", "(", "c", ")", "\n", "Ldflags", "(", "\"", "\"", ")", ...
// WithRace enables the race detector and adds the tag "race" to // the Context build tags.
[ "WithRace", "enables", "the", "race", "detector", "and", "adds", "the", "tag", "race", "to", "the", "Context", "build", "tags", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/context.go#L123-L129
19,546
constabulary/gb
context.go
NewContext
func NewContext(p Project, opts ...func(*Context) error) (*Context, error) { envOr := func(key, def string) string { if v := os.Getenv(key); v != "" { return v } return def } defaults := []func(*Context) error{ // must come before GcToolchain() func(c *Context) error { c.gohostos = runtime.GOOS c...
go
func NewContext(p Project, opts ...func(*Context) error) (*Context, error) { envOr := func(key, def string) string { if v := os.Getenv(key); v != "" { return v } return def } defaults := []func(*Context) error{ // must come before GcToolchain() func(c *Context) error { c.gohostos = runtime.GOOS c...
[ "func", "NewContext", "(", "p", "Project", ",", "opts", "...", "func", "(", "*", "Context", ")", "error", ")", "(", "*", "Context", ",", "error", ")", "{", "envOr", ":=", "func", "(", "key", ",", "def", "string", ")", "string", "{", "if", "v", ":...
// NewContext returns a new build context from this project. // By default this context will use the gc toolchain with the // host's GOOS and GOARCH values.
[ "NewContext", "returns", "a", "new", "build", "context", "from", "this", "project", ".", "By", "default", "this", "context", "will", "use", "the", "gc", "toolchain", "with", "the", "host", "s", "GOOS", "and", "GOARCH", "values", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/context.go#L134-L207
19,547
constabulary/gb
context.go
NewPackage
func (c *Context) NewPackage(p *build.Package) (*Package, error) { pkg, err := c.newPackage(p) if err != nil { return nil, err } pkg.NotStale = !pkg.isStale() return pkg, nil }
go
func (c *Context) NewPackage(p *build.Package) (*Package, error) { pkg, err := c.newPackage(p) if err != nil { return nil, err } pkg.NotStale = !pkg.isStale() return pkg, nil }
[ "func", "(", "c", "*", "Context", ")", "NewPackage", "(", "p", "*", "build", ".", "Package", ")", "(", "*", "Package", ",", "error", ")", "{", "pkg", ",", "err", ":=", "c", ".", "newPackage", "(", "p", ")", "\n", "if", "err", "!=", "nil", "{", ...
// NewPackage creates a resolved Package for p.
[ "NewPackage", "creates", "a", "resolved", "Package", "for", "p", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/context.go#L218-L225
19,548
constabulary/gb
context.go
Pkgdir
func (c *Context) Pkgdir() string { return filepath.Join(c.Project.Pkgdir(), c.ctxString()) }
go
func (c *Context) Pkgdir() string { return filepath.Join(c.Project.Pkgdir(), c.ctxString()) }
[ "func", "(", "c", "*", "Context", ")", "Pkgdir", "(", ")", "string", "{", "return", "filepath", ".", "Join", "(", "c", ".", "Project", ".", "Pkgdir", "(", ")", ",", "c", ".", "ctxString", "(", ")", ")", "\n", "}" ]
// Pkgdir returns the path to precompiled packages.
[ "Pkgdir", "returns", "the", "path", "to", "precompiled", "packages", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/context.go#L228-L230
19,549
constabulary/gb
context.go
ResolvePackage
func (c *Context) ResolvePackage(path string) (*Package, error) { if path == "." { return nil, errors.Errorf("%q is not a package", filepath.Join(c.Projectdir(), "src")) } path, err := relImportPath(filepath.Join(c.Projectdir(), "src"), path) if err != nil { return nil, err } if path == "." || path == ".." ||...
go
func (c *Context) ResolvePackage(path string) (*Package, error) { if path == "." { return nil, errors.Errorf("%q is not a package", filepath.Join(c.Projectdir(), "src")) } path, err := relImportPath(filepath.Join(c.Projectdir(), "src"), path) if err != nil { return nil, err } if path == "." || path == ".." ||...
[ "func", "(", "c", "*", "Context", ")", "ResolvePackage", "(", "path", "string", ")", "(", "*", "Package", ",", "error", ")", "{", "if", "path", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "filepath", ...
// ResolvePackage resolves the package at path using the current context.
[ "ResolvePackage", "resolves", "the", "package", "at", "path", "using", "the", "current", "context", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/context.go#L246-L258
19,550
constabulary/gb
context.go
loadPackage
func (c *Context) loadPackage(stack []string, path string) (*Package, error) { if pkg, ok := c.pkgs[path]; ok { // already loaded, just return return pkg, nil } p, err := c.importer.Import(path) if err != nil { return nil, err } stack = append(stack, p.ImportPath) var stale bool for i, im := range p.Imp...
go
func (c *Context) loadPackage(stack []string, path string) (*Package, error) { if pkg, ok := c.pkgs[path]; ok { // already loaded, just return return pkg, nil } p, err := c.importer.Import(path) if err != nil { return nil, err } stack = append(stack, p.ImportPath) var stale bool for i, im := range p.Imp...
[ "func", "(", "c", "*", "Context", ")", "loadPackage", "(", "stack", "[", "]", "string", ",", "path", "string", ")", "(", "*", "Package", ",", "error", ")", "{", "if", "pkg", ",", "ok", ":=", "c", ".", "pkgs", "[", "path", "]", ";", "ok", "{", ...
// loadPackage recursively resolves path as a package. If successful loadPackage // records the package in the Context's internal package cache.
[ "loadPackage", "recursively", "resolves", "path", "as", "a", "package", ".", "If", "successful", "loadPackage", "records", "the", "package", "in", "the", "Context", "s", "internal", "package", "cache", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/context.go#L262-L299
19,551
constabulary/gb
context.go
Destroy
func (c *Context) Destroy() error { c.debug("removing work directory: %v", c.workdir) return os.RemoveAll(c.workdir) }
go
func (c *Context) Destroy() error { c.debug("removing work directory: %v", c.workdir) return os.RemoveAll(c.workdir) }
[ "func", "(", "c", "*", "Context", ")", "Destroy", "(", ")", "error", "{", "c", ".", "debug", "(", "\"", "\"", ",", "c", ".", "workdir", ")", "\n", "return", "os", ".", "RemoveAll", "(", "c", ".", "workdir", ")", "\n", "}" ]
// Destroy removes the temporary working files of this context.
[ "Destroy", "removes", "the", "temporary", "working", "files", "of", "this", "context", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/context.go#L302-L305
19,552
constabulary/gb
context.go
ctxString
func (c *Context) ctxString() string { v := []string{ c.gotargetos, c.gotargetarch, } v = append(v, c.buildtags...) return strings.Join(v, "-") }
go
func (c *Context) ctxString() string { v := []string{ c.gotargetos, c.gotargetarch, } v = append(v, c.buildtags...) return strings.Join(v, "-") }
[ "func", "(", "c", "*", "Context", ")", "ctxString", "(", ")", "string", "{", "v", ":=", "[", "]", "string", "{", "c", ".", "gotargetos", ",", "c", ".", "gotargetarch", ",", "}", "\n", "v", "=", "append", "(", "v", ",", "c", ".", "buildtags", "....
// ctxString returns a string representation of the unique properties // of the context.
[ "ctxString", "returns", "a", "string", "representation", "of", "the", "unique", "properties", "of", "the", "context", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/context.go#L309-L316
19,553
constabulary/gb
cmd/gb/signal.go
processSignals
func processSignals() { sig := make(chan os.Signal) signal.Notify(sig, signalsToIgnore...) go func() { <-sig close(interrupted) }() }
go
func processSignals() { sig := make(chan os.Signal) signal.Notify(sig, signalsToIgnore...) go func() { <-sig close(interrupted) }() }
[ "func", "processSignals", "(", ")", "{", "sig", ":=", "make", "(", "chan", "os", ".", "Signal", ")", "\n", "signal", ".", "Notify", "(", "sig", ",", "signalsToIgnore", "...", ")", "\n", "go", "func", "(", ")", "{", "<-", "sig", "\n", "close", "(", ...
// processSignals setups signal handler.
[ "processSignals", "setups", "signal", "handler", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cmd/gb/signal.go#L17-L24
19,554
constabulary/gb
internal/fileutils/fileutils.go
Copypath
func Copypath(dst string, src string) error { err := filepath.Walk(src, func(path string, info os.FileInfo, err error) error { if err != nil { return err } if strings.HasPrefix(filepath.Base(path), ".") { if info.IsDir() { return filepath.SkipDir } return nil } if info.IsDir() { return n...
go
func Copypath(dst string, src string) error { err := filepath.Walk(src, func(path string, info os.FileInfo, err error) error { if err != nil { return err } if strings.HasPrefix(filepath.Base(path), ".") { if info.IsDir() { return filepath.SkipDir } return nil } if info.IsDir() { return n...
[ "func", "Copypath", "(", "dst", "string", ",", "src", "string", ")", "error", "{", "err", ":=", "filepath", ".", "Walk", "(", "src", ",", "func", "(", "path", "string", ",", "info", "os", ".", "FileInfo", ",", "err", "error", ")", "error", "{", "if...
// Copypath copies the contents of src to dst, excluding any file or // directory that starts with a period.
[ "Copypath", "copies", "the", "contents", "of", "src", "to", "dst", "excluding", "any", "file", "or", "directory", "that", "starts", "with", "a", "period", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/internal/fileutils/fileutils.go#L20-L52
19,555
constabulary/gb
internal/fileutils/fileutils.go
Copyfile
func Copyfile(dst, src string) error { err := mkdir(filepath.Dir(dst)) if err != nil { return errors.Wrap(err, "copyfile: mkdirall") } r, err := os.Open(src) if err != nil { return errors.Wrapf(err, "copyfile: open(%q)", src) } defer r.Close() w, err := os.Create(dst) if err != nil { return errors.Wrapf(...
go
func Copyfile(dst, src string) error { err := mkdir(filepath.Dir(dst)) if err != nil { return errors.Wrap(err, "copyfile: mkdirall") } r, err := os.Open(src) if err != nil { return errors.Wrapf(err, "copyfile: open(%q)", src) } defer r.Close() w, err := os.Create(dst) if err != nil { return errors.Wrapf(...
[ "func", "Copyfile", "(", "dst", ",", "src", "string", ")", "error", "{", "err", ":=", "mkdir", "(", "filepath", ".", "Dir", "(", "dst", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ...
// Copyfile copies file to destination creating destination directory if needed
[ "Copyfile", "copies", "file", "to", "destination", "creating", "destination", "directory", "if", "needed" ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/internal/fileutils/fileutils.go#L55-L75
19,556
constabulary/gb
cgo.go
rungcc1
func rungcc1(pkg *Package, cgoCFLAGS []string, ofile, cfile string) error { args := []string{"-g", "-O2", "-I", pkg.Dir, "-I", filepath.Dir(ofile), } args = append(args, cgoCFLAGS...) args = append(args, "-o", ofile, "-c", cfile, ) t0 := time.Now() gcc := gccCmd(pkg, pkg.Dir) var buf bytes.Buffer err :...
go
func rungcc1(pkg *Package, cgoCFLAGS []string, ofile, cfile string) error { args := []string{"-g", "-O2", "-I", pkg.Dir, "-I", filepath.Dir(ofile), } args = append(args, cgoCFLAGS...) args = append(args, "-o", ofile, "-c", cfile, ) t0 := time.Now() gcc := gccCmd(pkg, pkg.Dir) var buf bytes.Buffer err :...
[ "func", "rungcc1", "(", "pkg", "*", "Package", ",", "cgoCFLAGS", "[", "]", "string", ",", "ofile", ",", "cfile", "string", ")", "error", "{", "args", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "pkg", ".", ...
// rungcc1 invokes gcc to compile cfile into ofile
[ "rungcc1", "invokes", "gcc", "to", "compile", "cfile", "into", "ofile" ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cgo.go#L206-L226
19,557
constabulary/gb
cgo.go
gccld
func gccld(pkg *Package, cgoCFLAGS, cgoLDFLAGS []string, ofile string, ofiles []string) error { args := []string{} args = append(args, "-o", ofile) args = append(args, ofiles...) args = append(args, cgoLDFLAGS...) // this has to go at the end, because reasons! t0 := time.Now() var cmd []string if len(pkg.CXXFil...
go
func gccld(pkg *Package, cgoCFLAGS, cgoLDFLAGS []string, ofile string, ofiles []string) error { args := []string{} args = append(args, "-o", ofile) args = append(args, ofiles...) args = append(args, cgoLDFLAGS...) // this has to go at the end, because reasons! t0 := time.Now() var cmd []string if len(pkg.CXXFil...
[ "func", "gccld", "(", "pkg", "*", "Package", ",", "cgoCFLAGS", ",", "cgoLDFLAGS", "[", "]", "string", ",", "ofile", "string", ",", "ofiles", "[", "]", "string", ")", "error", "{", "args", ":=", "[", "]", "string", "{", "}", "\n", "args", "=", "appe...
// gccld links the o files from rungcc1 into a single _cgo_.o.
[ "gccld", "links", "the", "o", "files", "from", "rungcc1", "into", "a", "single", "_cgo_", ".", "o", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cgo.go#L252-L273
19,558
constabulary/gb
cgo.go
rungcc3
func rungcc3(pkg *Package, dir string, ofile string, ofiles []string) error { args := []string{} args = append(args, "-o", ofile) args = append(args, ofiles...) args = append(args, "-Wl,-r", "-nostdlib") if gccSupportsNoPie(pkg) { args = append(args, "-no-pie") } var cmd []string if len(pkg.CXXFiles) > 0 || l...
go
func rungcc3(pkg *Package, dir string, ofile string, ofiles []string) error { args := []string{} args = append(args, "-o", ofile) args = append(args, ofiles...) args = append(args, "-Wl,-r", "-nostdlib") if gccSupportsNoPie(pkg) { args = append(args, "-no-pie") } var cmd []string if len(pkg.CXXFiles) > 0 || l...
[ "func", "rungcc3", "(", "pkg", "*", "Package", ",", "dir", "string", ",", "ofile", "string", ",", "ofiles", "[", "]", "string", ")", "error", "{", "args", ":=", "[", "]", "string", "{", "}", "\n", "args", "=", "append", "(", "args", ",", "\"", "\...
// rungcc3 links all previous ofiles together with libgcc into a single _all.o.
[ "rungcc3", "links", "all", "previous", "ofiles", "together", "with", "libgcc", "into", "a", "single", "_all", ".", "o", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cgo.go#L276-L306
19,559
constabulary/gb
cgo.go
libgcc
func libgcc(ctx *Context) (string, error) { args := []string{ "-print-libgcc-file-name", } var buf bytes.Buffer cmd := gccCmd(&Package{Context: ctx}, "") // TODO(dfc) hack err := runOut(&buf, ".", nil, cmd[0], args...) return strings.TrimSpace(buf.String()), err }
go
func libgcc(ctx *Context) (string, error) { args := []string{ "-print-libgcc-file-name", } var buf bytes.Buffer cmd := gccCmd(&Package{Context: ctx}, "") // TODO(dfc) hack err := runOut(&buf, ".", nil, cmd[0], args...) return strings.TrimSpace(buf.String()), err }
[ "func", "libgcc", "(", "ctx", "*", "Context", ")", "(", "string", ",", "error", ")", "{", "args", ":=", "[", "]", "string", "{", "\"", "\"", ",", "}", "\n", "var", "buf", "bytes", ".", "Buffer", "\n", "cmd", ":=", "gccCmd", "(", "&", "Package", ...
// libgcc returns the value of gcc -print-libgcc-file-name.
[ "libgcc", "returns", "the", "value", "of", "gcc", "-", "print", "-", "libgcc", "-", "file", "-", "name", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cgo.go#L309-L317
19,560
constabulary/gb
cgo.go
envList
func envList(key, def string) []string { v := os.Getenv(key) if v == "" { v = def } return strings.Fields(v) }
go
func envList(key, def string) []string { v := os.Getenv(key) if v == "" { v = def } return strings.Fields(v) }
[ "func", "envList", "(", "key", ",", "def", "string", ")", "[", "]", "string", "{", "v", ":=", "os", ".", "Getenv", "(", "key", ")", "\n", "if", "v", "==", "\"", "\"", "{", "v", "=", "def", "\n", "}", "\n", "return", "strings", ".", "Fields", ...
// envList returns the value of the given environment variable broken // into fields, using the default value when the variable is empty.
[ "envList", "returns", "the", "value", "of", "the", "given", "environment", "variable", "broken", "into", "fields", "using", "the", "default", "value", "when", "the", "variable", "is", "empty", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cgo.go#L339-L345
19,561
constabulary/gb
cgo.go
cflags
func cflags(p *Package, def bool) (cppflags, cflags, cxxflags, ldflags []string) { var defaults string if def { defaults = "-g -O2" } cppflags = stringList(envList("CGO_CPPFLAGS", ""), p.CgoCPPFLAGS) cflags = stringList(envList("CGO_CFLAGS", defaults), p.CgoCFLAGS) cxxflags = stringList(envList("CGO_CXXFLAGS",...
go
func cflags(p *Package, def bool) (cppflags, cflags, cxxflags, ldflags []string) { var defaults string if def { defaults = "-g -O2" } cppflags = stringList(envList("CGO_CPPFLAGS", ""), p.CgoCPPFLAGS) cflags = stringList(envList("CGO_CFLAGS", defaults), p.CgoCFLAGS) cxxflags = stringList(envList("CGO_CXXFLAGS",...
[ "func", "cflags", "(", "p", "*", "Package", ",", "def", "bool", ")", "(", "cppflags", ",", "cflags", ",", "cxxflags", ",", "ldflags", "[", "]", "string", ")", "{", "var", "defaults", "string", "\n", "if", "def", "{", "defaults", "=", "\"", "\"", "\...
// Return the flags to use when invoking the C or C++ compilers, or cgo.
[ "Return", "the", "flags", "to", "use", "when", "invoking", "the", "C", "or", "C", "++", "compilers", "or", "cgo", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cgo.go#L348-L359
19,562
constabulary/gb
cgo.go
pkgconfig
func pkgconfig(p *Package) ([]string, []string, error) { if len(p.CgoPkgConfig) == 0 { return nil, nil, nil // nothing to do } args := []string{ "--cflags", } args = append(args, p.CgoPkgConfig...) var out bytes.Buffer err := runOut(&out, p.Dir, nil, "pkg-config", args...) if err != nil { return nil, nil,...
go
func pkgconfig(p *Package) ([]string, []string, error) { if len(p.CgoPkgConfig) == 0 { return nil, nil, nil // nothing to do } args := []string{ "--cflags", } args = append(args, p.CgoPkgConfig...) var out bytes.Buffer err := runOut(&out, p.Dir, nil, "pkg-config", args...) if err != nil { return nil, nil,...
[ "func", "pkgconfig", "(", "p", "*", "Package", ")", "(", "[", "]", "string", ",", "[", "]", "string", ",", "error", ")", "{", "if", "len", "(", "p", ".", "CgoPkgConfig", ")", "==", "0", "{", "return", "nil", ",", "nil", ",", "nil", "// nothing to...
// call pkg-config and return the cflags and ldflags.
[ "call", "pkg", "-", "config", "and", "return", "the", "cflags", "and", "ldflags", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cgo.go#L362-L388
19,563
constabulary/gb
cgo.go
runcgo1
func runcgo1(pkg *Package, cflags, ldflags []string) error { cgo := cgotool(pkg.Context) workdir := cgoworkdir(pkg) if err := mkdir(workdir); err != nil { return err } args := []string{"-objdir", workdir} switch { case version.Version > 1.5: args = append(args, "-importpath", pkg.ImportPath, "--", ...
go
func runcgo1(pkg *Package, cflags, ldflags []string) error { cgo := cgotool(pkg.Context) workdir := cgoworkdir(pkg) if err := mkdir(workdir); err != nil { return err } args := []string{"-objdir", workdir} switch { case version.Version > 1.5: args = append(args, "-importpath", pkg.ImportPath, "--", ...
[ "func", "runcgo1", "(", "pkg", "*", "Package", ",", "cflags", ",", "ldflags", "[", "]", "string", ")", "error", "{", "cgo", ":=", "cgotool", "(", "pkg", ".", "Context", ")", "\n", "workdir", ":=", "cgoworkdir", "(", "pkg", ")", "\n", "if", "err", "...
// runcgo1 invokes the cgo tool to process pkg.CgoFiles.
[ "runcgo1", "invokes", "the", "cgo", "tool", "to", "process", "pkg", ".", "CgoFiles", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cgo.go#L399-L432
19,564
constabulary/gb
cgo.go
runcgo2
func runcgo2(pkg *Package, dynout, ofile string) error { cgo := cgotool(pkg.Context) workdir := cgoworkdir(pkg) args := []string{ "-objdir", workdir, } switch { case version.Version > 1.5: args = append(args, "-dynpackage", pkg.Name, "-dynimport", ofile, "-dynout", dynout, ) default: return err...
go
func runcgo2(pkg *Package, dynout, ofile string) error { cgo := cgotool(pkg.Context) workdir := cgoworkdir(pkg) args := []string{ "-objdir", workdir, } switch { case version.Version > 1.5: args = append(args, "-dynpackage", pkg.Name, "-dynimport", ofile, "-dynout", dynout, ) default: return err...
[ "func", "runcgo2", "(", "pkg", "*", "Package", ",", "dynout", ",", "ofile", "string", ")", "error", "{", "cgo", ":=", "cgotool", "(", "pkg", ".", "Context", ")", "\n", "workdir", ":=", "cgoworkdir", "(", "pkg", ")", "\n\n", "args", ":=", "[", "]", ...
// runcgo2 invokes the cgo tool to create _cgo_import.go
[ "runcgo2", "invokes", "the", "cgo", "tool", "to", "create", "_cgo_import", ".", "go" ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cgo.go#L435-L459
19,565
constabulary/gb
cgo.go
cgoworkdir
func cgoworkdir(pkg *Package) string { return filepath.Join(pkg.Workdir(), pkg.pkgname(), "_cgo") }
go
func cgoworkdir(pkg *Package) string { return filepath.Join(pkg.Workdir(), pkg.pkgname(), "_cgo") }
[ "func", "cgoworkdir", "(", "pkg", "*", "Package", ")", "string", "{", "return", "filepath", ".", "Join", "(", "pkg", ".", "Workdir", "(", ")", ",", "pkg", ".", "pkgname", "(", ")", ",", "\"", "\"", ")", "\n", "}" ]
// cgoworkdir returns the cgo working directory for this package.
[ "cgoworkdir", "returns", "the", "cgo", "working", "directory", "for", "this", "package", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cgo.go#L462-L464
19,566
constabulary/gb
cgo.go
gccCmd
func gccCmd(pkg *Package, objdir string) []string { return ccompilerCmd(pkg, "CC", defaultCC, objdir) }
go
func gccCmd(pkg *Package, objdir string) []string { return ccompilerCmd(pkg, "CC", defaultCC, objdir) }
[ "func", "gccCmd", "(", "pkg", "*", "Package", ",", "objdir", "string", ")", "[", "]", "string", "{", "return", "ccompilerCmd", "(", "pkg", ",", "\"", "\"", ",", "defaultCC", ",", "objdir", ")", "\n", "}" ]
// gccCmd returns a gcc command line prefix.
[ "gccCmd", "returns", "a", "gcc", "command", "line", "prefix", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cgo.go#L467-L469
19,567
constabulary/gb
cgo.go
gxxCmd
func gxxCmd(pkg *Package, objdir string) []string { return ccompilerCmd(pkg, "CXX", defaultCXX, objdir) }
go
func gxxCmd(pkg *Package, objdir string) []string { return ccompilerCmd(pkg, "CXX", defaultCXX, objdir) }
[ "func", "gxxCmd", "(", "pkg", "*", "Package", ",", "objdir", "string", ")", "[", "]", "string", "{", "return", "ccompilerCmd", "(", "pkg", ",", "\"", "\"", ",", "defaultCXX", ",", "objdir", ")", "\n", "}" ]
// gxxCmd returns a g++ command line prefix.
[ "gxxCmd", "returns", "a", "g", "++", "command", "line", "prefix", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cgo.go#L472-L474
19,568
constabulary/gb
cgo.go
ccompilerCmd
func ccompilerCmd(pkg *Package, envvar, defcmd, objdir string) []string { compiler := envList(envvar, defcmd) a := []string{compiler[0]} if objdir != "" { a = append(a, "-I", objdir) } a = append(a, compiler[1:]...) // Definitely want -fPIC but on Windows gcc complains // "-fPIC ignored for target (all code i...
go
func ccompilerCmd(pkg *Package, envvar, defcmd, objdir string) []string { compiler := envList(envvar, defcmd) a := []string{compiler[0]} if objdir != "" { a = append(a, "-I", objdir) } a = append(a, compiler[1:]...) // Definitely want -fPIC but on Windows gcc complains // "-fPIC ignored for target (all code i...
[ "func", "ccompilerCmd", "(", "pkg", "*", "Package", ",", "envvar", ",", "defcmd", ",", "objdir", "string", ")", "[", "]", "string", "{", "compiler", ":=", "envList", "(", "envvar", ",", "defcmd", ")", "\n", "a", ":=", "[", "]", "string", "{", "compil...
// ccompilerCmd returns a command line prefix for the given environment // variable and using the default command when the variable is empty.
[ "ccompilerCmd", "returns", "a", "command", "line", "prefix", "for", "the", "given", "environment", "variable", "and", "using", "the", "default", "command", "when", "the", "variable", "is", "empty", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cgo.go#L478-L519
19,569
constabulary/gb
cgo.go
linkCmd
func linkCmd(pkg *Package, envvar, defcmd string) string { compiler := envList(envvar, defcmd) return compiler[0] }
go
func linkCmd(pkg *Package, envvar, defcmd string) string { compiler := envList(envvar, defcmd) return compiler[0] }
[ "func", "linkCmd", "(", "pkg", "*", "Package", ",", "envvar", ",", "defcmd", "string", ")", "string", "{", "compiler", ":=", "envList", "(", "envvar", ",", "defcmd", ")", "\n", "return", "compiler", "[", "0", "]", "\n", "}" ]
// linkCmd returns the name of the binary to use for linking for the given // environment variable and using the default command when the variable is // empty.
[ "linkCmd", "returns", "the", "name", "of", "the", "binary", "to", "use", "for", "linking", "for", "the", "given", "environment", "variable", "and", "using", "the", "default", "command", "when", "the", "variable", "is", "empty", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cgo.go#L524-L527
19,570
constabulary/gb
gb.go
stripext
func stripext(path string) string { return path[:len(path)-len(filepath.Ext(path))] }
go
func stripext(path string) string { return path[:len(path)-len(filepath.Ext(path))] }
[ "func", "stripext", "(", "path", "string", ")", "string", "{", "return", "path", "[", ":", "len", "(", "path", ")", "-", "len", "(", "filepath", ".", "Ext", "(", "path", ")", ")", "]", "\n", "}" ]
// stripext strips the extension from a filename. // The extension is defined by filepath.Ext.
[ "stripext", "strips", "the", "extension", "from", "a", "filename", ".", "The", "extension", "is", "defined", "by", "filepath", ".", "Ext", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/gb.go#L71-L73
19,571
constabulary/gb
depfile.go
addDepfileDeps
func addDepfileDeps(bc *build.Context, ctx *Context) (Importer, error) { i := Importer(new(nullImporter)) df, err := readDepfile(ctx) if err != nil { if !os.IsNotExist(errors.Cause(err)) { return nil, errors.Wrap(err, "could not parse depfile") } ctx.debug("no depfile, nothing to do.") return i, nil } r...
go
func addDepfileDeps(bc *build.Context, ctx *Context) (Importer, error) { i := Importer(new(nullImporter)) df, err := readDepfile(ctx) if err != nil { if !os.IsNotExist(errors.Cause(err)) { return nil, errors.Wrap(err, "could not parse depfile") } ctx.debug("no depfile, nothing to do.") return i, nil } r...
[ "func", "addDepfileDeps", "(", "bc", "*", "build", ".", "Context", ",", "ctx", "*", "Context", ")", "(", "Importer", ",", "error", ")", "{", "i", ":=", "Importer", "(", "new", "(", "nullImporter", ")", ")", "\n", "df", ",", "err", ":=", "readDepfile"...
// addDepfileDeps inserts into the Context's importer list // a set of importers for entries in the depfile.
[ "addDepfileDeps", "inserts", "into", "the", "Context", "s", "importer", "list", "a", "set", "of", "importers", "for", "entries", "in", "the", "depfile", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/depfile.go#L25-L95
19,572
constabulary/gb
package.go
newPackage
func (ctx *Context) newPackage(p *build.Package) (*Package, error) { pkg := &Package{ Context: ctx, Package: p, } for _, i := range p.Imports { dep, ok := ctx.pkgs[i] if !ok { return nil, errors.Errorf("newPackage(%q): could not locate dependant package %q ", p.Name, i) } pkg.Imports = append(pkg.Impo...
go
func (ctx *Context) newPackage(p *build.Package) (*Package, error) { pkg := &Package{ Context: ctx, Package: p, } for _, i := range p.Imports { dep, ok := ctx.pkgs[i] if !ok { return nil, errors.Errorf("newPackage(%q): could not locate dependant package %q ", p.Name, i) } pkg.Imports = append(pkg.Impo...
[ "func", "(", "ctx", "*", "Context", ")", "newPackage", "(", "p", "*", "build", ".", "Package", ")", "(", "*", "Package", ",", "error", ")", "{", "pkg", ":=", "&", "Package", "{", "Context", ":", "ctx", ",", "Package", ":", "p", ",", "}", "\n", ...
// newPackage creates a resolved Package without setting pkg.Stale.
[ "newPackage", "creates", "a", "resolved", "Package", "without", "setting", "pkg", ".", "Stale", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/package.go#L26-L39
19,573
constabulary/gb
package.go
complete
func (p *Package) complete() bool { // If we're giving the compiler the entire package (no C etc files), tell it that, // so that it can give good error messages about forward declarations. // Exceptions: a few standard packages have forward declarations for // pieces supplied behind-the-scenes by package runtime. ...
go
func (p *Package) complete() bool { // If we're giving the compiler the entire package (no C etc files), tell it that, // so that it can give good error messages about forward declarations. // Exceptions: a few standard packages have forward declarations for // pieces supplied behind-the-scenes by package runtime. ...
[ "func", "(", "p", "*", "Package", ")", "complete", "(", ")", "bool", "{", "// If we're giving the compiler the entire package (no C etc files), tell it that,", "// so that it can give good error messages about forward declarations.", "// Exceptions: a few standard packages have forward dec...
// complete indicates if this is a pure Go package
[ "complete", "indicates", "if", "this", "is", "a", "pure", "Go", "package" ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/package.go#L60-L73
19,574
constabulary/gb
package.go
Binfile
func (pkg *Package) Binfile() string { target := filepath.Join(pkg.bindir(), pkg.binname()) // if this is a cross compile or GOOS/GOARCH are both defined or there are build tags, add ctxString. if pkg.isCrossCompile() || (os.Getenv("GOOS") != "" && os.Getenv("GOARCH") != "") { target += "-" + pkg.ctxString() } e...
go
func (pkg *Package) Binfile() string { target := filepath.Join(pkg.bindir(), pkg.binname()) // if this is a cross compile or GOOS/GOARCH are both defined or there are build tags, add ctxString. if pkg.isCrossCompile() || (os.Getenv("GOOS") != "" && os.Getenv("GOARCH") != "") { target += "-" + pkg.ctxString() } e...
[ "func", "(", "pkg", "*", "Package", ")", "Binfile", "(", ")", "string", "{", "target", ":=", "filepath", ".", "Join", "(", "pkg", ".", "bindir", "(", ")", ",", "pkg", ".", "binname", "(", ")", ")", "\n\n", "// if this is a cross compile or GOOS/GOARCH are ...
// Binfile returns the destination of the compiled target of this command.
[ "Binfile", "returns", "the", "destination", "of", "the", "compiled", "target", "of", "this", "command", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/package.go#L76-L90
19,575
constabulary/gb
package.go
objfile
func (pkg *Package) objfile() string { return filepath.Join(pkg.Workdir(), pkg.objname()) }
go
func (pkg *Package) objfile() string { return filepath.Join(pkg.Workdir(), pkg.objname()) }
[ "func", "(", "pkg", "*", "Package", ")", "objfile", "(", ")", "string", "{", "return", "filepath", ".", "Join", "(", "pkg", ".", "Workdir", "(", ")", ",", "pkg", ".", "objname", "(", ")", ")", "\n", "}" ]
// objfile returns the name of the object file for this package
[ "objfile", "returns", "the", "name", "of", "the", "object", "file", "for", "this", "package" ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/package.go#L114-L116
19,576
constabulary/gb
package.go
pkgpath
func (pkg *Package) pkgpath() string { importpath := filepath.FromSlash(pkg.ImportPath) + ".a" switch { case pkg.isCrossCompile(): return filepath.Join(pkg.Pkgdir(), importpath) case pkg.Goroot && pkg.race: // race enabled standard lib return filepath.Join(runtime.GOROOT(), "pkg", pkg.gotargetos+"_"+pkg.gotar...
go
func (pkg *Package) pkgpath() string { importpath := filepath.FromSlash(pkg.ImportPath) + ".a" switch { case pkg.isCrossCompile(): return filepath.Join(pkg.Pkgdir(), importpath) case pkg.Goroot && pkg.race: // race enabled standard lib return filepath.Join(runtime.GOROOT(), "pkg", pkg.gotargetos+"_"+pkg.gotar...
[ "func", "(", "pkg", "*", "Package", ")", "pkgpath", "(", ")", "string", "{", "importpath", ":=", "filepath", ".", "FromSlash", "(", "pkg", ".", "ImportPath", ")", "+", "\"", "\"", "\n", "switch", "{", "case", "pkg", ".", "isCrossCompile", "(", ")", "...
// pkgpath returns the destination for object cached for this Package.
[ "pkgpath", "returns", "the", "destination", "for", "object", "cached", "for", "this", "Package", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/package.go#L152-L166
19,577
constabulary/gb
package.go
isStale
func (pkg *Package) isStale() bool { switch pkg.ImportPath { case "C", "unsafe": // synthetic packages are never stale return false } if !pkg.Goroot && pkg.Force { return true } // tests are always stale, they are never installed if pkg.TestScope { return true } // Package is stale if completely unb...
go
func (pkg *Package) isStale() bool { switch pkg.ImportPath { case "C", "unsafe": // synthetic packages are never stale return false } if !pkg.Goroot && pkg.Force { return true } // tests are always stale, they are never installed if pkg.TestScope { return true } // Package is stale if completely unb...
[ "func", "(", "pkg", "*", "Package", ")", "isStale", "(", ")", "bool", "{", "switch", "pkg", ".", "ImportPath", "{", "case", "\"", "\"", ",", "\"", "\"", ":", "// synthetic packages are never stale", "return", "false", "\n", "}", "\n\n", "if", "!", "pkg",...
// isStale returns true if the source pkg is considered to be stale with // respect to its installed version.
[ "isStale", "returns", "true", "if", "the", "source", "pkg", "is", "considered", "to", "be", "stale", "with", "respect", "to", "its", "installed", "version", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/package.go#L170-L259
19,578
constabulary/gb
cmd/gb/stringset.go
difference
func difference(a, b map[string]bool) map[string]bool { r := make(map[string]bool) for k := range a { if !b[k] { r[k] = true } } for k := range b { if !a[k] { r[k] = true } } return r }
go
func difference(a, b map[string]bool) map[string]bool { r := make(map[string]bool) for k := range a { if !b[k] { r[k] = true } } for k := range b { if !a[k] { r[k] = true } } return r }
[ "func", "difference", "(", "a", ",", "b", "map", "[", "string", "]", "bool", ")", "map", "[", "string", "]", "bool", "{", "r", ":=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "for", "k", ":=", "range", "a", "{", "if", "!", "b...
// difference returns the symetric difference of a and b.
[ "difference", "returns", "the", "symetric", "difference", "of", "a", "and", "b", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/cmd/gb/stringset.go#L27-L40
19,579
constabulary/gb
internal/depfile/depfile.go
ParseFile
func ParseFile(path string) (map[string]map[string]string, error) { r, err := os.Open(path) if err != nil { return nil, errors.Wrapf(err, "ParseFile") } defer r.Close() return Parse(r) }
go
func ParseFile(path string) (map[string]map[string]string, error) { r, err := os.Open(path) if err != nil { return nil, errors.Wrapf(err, "ParseFile") } defer r.Close() return Parse(r) }
[ "func", "ParseFile", "(", "path", "string", ")", "(", "map", "[", "string", "]", "map", "[", "string", "]", "string", ",", "error", ")", "{", "r", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "retu...
// ParseFile parses path into a tagged key value map. // See Parse for the syntax of the file.
[ "ParseFile", "parses", "path", "into", "a", "tagged", "key", "value", "map", ".", "See", "Parse", "for", "the", "syntax", "of", "the", "file", "." ]
f11784c79acf8d0c0a516774585aed66dc0dc439
https://github.com/constabulary/gb/blob/f11784c79acf8d0c0a516774585aed66dc0dc439/internal/depfile/depfile.go#L16-L23
19,580
jarcoal/httpmock
transport.go
checkStackTracer
func checkStackTracer(req *http.Request, err error) error { if nf, ok := err.(stackTracer); ok { if nf.customFn != nil { pc := make([]uintptr, 128) npc := runtime.Callers(2, pc) pc = pc[:npc] var mesg bytes.Buffer var netHTTPBegin, netHTTPEnd bool // Start recording at first net/http call if any....
go
func checkStackTracer(req *http.Request, err error) error { if nf, ok := err.(stackTracer); ok { if nf.customFn != nil { pc := make([]uintptr, 128) npc := runtime.Callers(2, pc) pc = pc[:npc] var mesg bytes.Buffer var netHTTPBegin, netHTTPEnd bool // Start recording at first net/http call if any....
[ "func", "checkStackTracer", "(", "req", "*", "http", ".", "Request", ",", "err", "error", ")", "error", "{", "if", "nf", ",", "ok", ":=", "err", ".", "(", "stackTracer", ")", ";", "ok", "{", "if", "nf", ".", "customFn", "!=", "nil", "{", "pc", ":...
// checkStackTracer checks for specific error returned by // NewNotFoundResponder function or Debug Responder method.
[ "checkStackTracer", "checks", "for", "specific", "error", "returned", "by", "NewNotFoundResponder", "function", "or", "Debug", "Responder", "method", "." ]
ac2099de8d3789d30b99b740d1a9d242097462df
https://github.com/jarcoal/httpmock/blob/ac2099de8d3789d30b99b740d1a9d242097462df/transport.go#L266-L326
19,581
jarcoal/httpmock
transport.go
responderForKey
func (m *MockTransport) responderForKey(key routeKey) (Responder, routeKey, []string) { m.mu.RLock() defer m.mu.RUnlock() return m.responders[key], key, nil }
go
func (m *MockTransport) responderForKey(key routeKey) (Responder, routeKey, []string) { m.mu.RLock() defer m.mu.RUnlock() return m.responders[key], key, nil }
[ "func", "(", "m", "*", "MockTransport", ")", "responderForKey", "(", "key", "routeKey", ")", "(", "Responder", ",", "routeKey", ",", "[", "]", "string", ")", "{", "m", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "m", ".", "mu", ".", "RUnlock"...
// responderForKey returns a responder for a given key.
[ "responderForKey", "returns", "a", "responder", "for", "a", "given", "key", "." ]
ac2099de8d3789d30b99b740d1a9d242097462df
https://github.com/jarcoal/httpmock/blob/ac2099de8d3789d30b99b740d1a9d242097462df/transport.go#L329-L333
19,582
jarcoal/httpmock
transport.go
regexpResponderForKey
func (m *MockTransport) regexpResponderForKey(key routeKey) (Responder, routeKey, []string) { m.mu.RLock() defer m.mu.RUnlock() for _, regInfo := range m.regexpResponders { if regInfo.method == key.Method { if sm := regInfo.rx.FindStringSubmatch(key.URL); sm != nil { if len(sm) == 1 { sm = nil } el...
go
func (m *MockTransport) regexpResponderForKey(key routeKey) (Responder, routeKey, []string) { m.mu.RLock() defer m.mu.RUnlock() for _, regInfo := range m.regexpResponders { if regInfo.method == key.Method { if sm := regInfo.rx.FindStringSubmatch(key.URL); sm != nil { if len(sm) == 1 { sm = nil } el...
[ "func", "(", "m", "*", "MockTransport", ")", "regexpResponderForKey", "(", "key", "routeKey", ")", "(", "Responder", ",", "routeKey", ",", "[", "]", "string", ")", "{", "m", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "m", ".", "mu", ".", "RU...
// responderForKeyUsingRegexp returns the first responder matching a given key using regexps.
[ "responderForKeyUsingRegexp", "returns", "the", "first", "responder", "matching", "a", "given", "key", "using", "regexps", "." ]
ac2099de8d3789d30b99b740d1a9d242097462df
https://github.com/jarcoal/httpmock/blob/ac2099de8d3789d30b99b740d1a9d242097462df/transport.go#L336-L355
19,583
jarcoal/httpmock
transport.go
RegisterNoResponder
func (m *MockTransport) RegisterNoResponder(responder Responder) { m.mu.Lock() m.noResponder = responder m.mu.Unlock() }
go
func (m *MockTransport) RegisterNoResponder(responder Responder) { m.mu.Lock() m.noResponder = responder m.mu.Unlock() }
[ "func", "(", "m", "*", "MockTransport", ")", "RegisterNoResponder", "(", "responder", "Responder", ")", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n", "m", ".", "noResponder", "=", "responder", "\n", "m", ".", "mu", ".", "Unlock", "(", ")", "\n", ...
// RegisterNoResponder is used to register a responder that will be called if no other responder is // found. The default is ConnectionFailure.
[ "RegisterNoResponder", "is", "used", "to", "register", "a", "responder", "that", "will", "be", "called", "if", "no", "other", "responder", "is", "found", ".", "The", "default", "is", "ConnectionFailure", "." ]
ac2099de8d3789d30b99b740d1a9d242097462df
https://github.com/jarcoal/httpmock/blob/ac2099de8d3789d30b99b740d1a9d242097462df/transport.go#L555-L559
19,584
jarcoal/httpmock
transport.go
GetTotalCallCount
func (m *MockTransport) GetTotalCallCount() int { m.mu.RLock() count := m.totalCallCount m.mu.RUnlock() return count }
go
func (m *MockTransport) GetTotalCallCount() int { m.mu.RLock() count := m.totalCallCount m.mu.RUnlock() return count }
[ "func", "(", "m", "*", "MockTransport", ")", "GetTotalCallCount", "(", ")", "int", "{", "m", ".", "mu", ".", "RLock", "(", ")", "\n", "count", ":=", "m", ".", "totalCallCount", "\n", "m", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "count"...
// GetTotalCallCount returns the totalCallCount.
[ "GetTotalCallCount", "returns", "the", "totalCallCount", "." ]
ac2099de8d3789d30b99b740d1a9d242097462df
https://github.com/jarcoal/httpmock/blob/ac2099de8d3789d30b99b740d1a9d242097462df/transport.go#L600-L605
19,585
jarcoal/httpmock
response.go
Times
func (r Responder) Times(n int, fn ...func(...interface{})) Responder { return r.times("Times", n, fn...) }
go
func (r Responder) Times(n int, fn ...func(...interface{})) Responder { return r.times("Times", n, fn...) }
[ "func", "(", "r", "Responder", ")", "Times", "(", "n", "int", ",", "fn", "...", "func", "(", "...", "interface", "{", "}", ")", ")", "Responder", "{", "return", "r", ".", "times", "(", "\"", "\"", ",", "n", ",", "fn", "...", ")", "\n", "}" ]
// Times returns a Responder callable n times before returning an // error. If the Responder is called more than n times and fn is // passed and non-nil, it acts as the fn parameter of // NewNotFoundResponder, allowing to dump the stack trace to localize // the origin of the call.
[ "Times", "returns", "a", "Responder", "callable", "n", "times", "before", "returning", "an", "error", ".", "If", "the", "Responder", "is", "called", "more", "than", "n", "times", "and", "fn", "is", "passed", "and", "non", "-", "nil", "it", "acts", "as", ...
ac2099de8d3789d30b99b740d1a9d242097462df
https://github.com/jarcoal/httpmock/blob/ac2099de8d3789d30b99b740d1a9d242097462df/response.go#L40-L42
19,586
speps/go-hashids
hashids.go
Encode
func (h *HashID) Encode(numbers []int) (string, error) { numbers64 := make([]int64, 0, len(numbers)) for _, id := range numbers { numbers64 = append(numbers64, int64(id)) } return h.EncodeInt64(numbers64) }
go
func (h *HashID) Encode(numbers []int) (string, error) { numbers64 := make([]int64, 0, len(numbers)) for _, id := range numbers { numbers64 = append(numbers64, int64(id)) } return h.EncodeInt64(numbers64) }
[ "func", "(", "h", "*", "HashID", ")", "Encode", "(", "numbers", "[", "]", "int", ")", "(", "string", ",", "error", ")", "{", "numbers64", ":=", "make", "(", "[", "]", "int64", ",", "0", ",", "len", "(", "numbers", ")", ")", "\n", "for", "_", ...
// Encode hashes an array of int to a string containing at least MinLength characters taken from the Alphabet. // Use Decode using the same Alphabet and Salt to get back the array of int.
[ "Encode", "hashes", "an", "array", "of", "int", "to", "a", "string", "containing", "at", "least", "MinLength", "characters", "taken", "from", "the", "Alphabet", ".", "Use", "Decode", "using", "the", "same", "Alphabet", "and", "Salt", "to", "get", "back", "...
6ba254bc2e328fdc3fca46bfbccea4ab8052755f
https://github.com/speps/go-hashids/blob/6ba254bc2e328fdc3fca46bfbccea4ab8052755f/hashids.go#L147-L153
19,587
speps/go-hashids
hashids.go
DecodeWithError
func (h *HashID) DecodeWithError(hash string) ([]int, error) { result64, err := h.DecodeInt64WithError(hash) if err != nil { return nil, err } result := make([]int, 0, len(result64)) for _, id := range result64 { result = append(result, int(id)) } return result, nil }
go
func (h *HashID) DecodeWithError(hash string) ([]int, error) { result64, err := h.DecodeInt64WithError(hash) if err != nil { return nil, err } result := make([]int, 0, len(result64)) for _, id := range result64 { result = append(result, int(id)) } return result, nil }
[ "func", "(", "h", "*", "HashID", ")", "DecodeWithError", "(", "hash", "string", ")", "(", "[", "]", "int", ",", "error", ")", "{", "result64", ",", "err", ":=", "h", ".", "DecodeInt64WithError", "(", "hash", ")", "\n", "if", "err", "!=", "nil", "{"...
// Decode unhashes the string passed to an array of int. // It is symmetric with Encode if the Alphabet and Salt are the same ones which were used to hash. // MinLength has no effect on Decode.
[ "Decode", "unhashes", "the", "string", "passed", "to", "an", "array", "of", "int", ".", "It", "is", "symmetric", "with", "Encode", "if", "the", "Alphabet", "and", "Salt", "are", "the", "same", "ones", "which", "were", "used", "to", "hash", ".", "MinLengt...
6ba254bc2e328fdc3fca46bfbccea4ab8052755f
https://github.com/speps/go-hashids/blob/6ba254bc2e328fdc3fca46bfbccea4ab8052755f/hashids.go#L266-L276
19,588
speps/go-hashids
hashids.go
DecodeInt64WithError
func (h *HashID) DecodeInt64WithError(hash string) ([]int64, error) { hashes := splitRunes([]rune(hash), h.guards) hashIndex := 0 if len(hashes) == 2 || len(hashes) == 3 { hashIndex = 1 } result := make([]int64, 0, 10) hashBreakdown := hashes[hashIndex] if len(hashBreakdown) > 0 { lottery := hashBreakdown[...
go
func (h *HashID) DecodeInt64WithError(hash string) ([]int64, error) { hashes := splitRunes([]rune(hash), h.guards) hashIndex := 0 if len(hashes) == 2 || len(hashes) == 3 { hashIndex = 1 } result := make([]int64, 0, 10) hashBreakdown := hashes[hashIndex] if len(hashBreakdown) > 0 { lottery := hashBreakdown[...
[ "func", "(", "h", "*", "HashID", ")", "DecodeInt64WithError", "(", "hash", "string", ")", "(", "[", "]", "int64", ",", "error", ")", "{", "hashes", ":=", "splitRunes", "(", "[", "]", "rune", "(", "hash", ")", ",", "h", ".", "guards", ")", "\n", "...
// DecodeInt64 unhashes the string passed to an array of int64. // It is symmetric with EncodeInt64 if the Alphabet and Salt are the same ones which were used to hash. // MinLength has no effect on DecodeInt64.
[ "DecodeInt64", "unhashes", "the", "string", "passed", "to", "an", "array", "of", "int64", ".", "It", "is", "symmetric", "with", "EncodeInt64", "if", "the", "Alphabet", "and", "Salt", "are", "the", "same", "ones", "which", "were", "used", "to", "hash", ".",...
6ba254bc2e328fdc3fca46bfbccea4ab8052755f
https://github.com/speps/go-hashids/blob/6ba254bc2e328fdc3fca46bfbccea4ab8052755f/hashids.go#L293-L330
19,589
josephspurrier/goversioninfo
lang_cs.go
UnmarshalJSON
func (cs *CharsetID) UnmarshalJSON(p []byte) error { if len(p) == 0 { return nil } if p[0] != '"' { var u uint16 if err := json.Unmarshal(p, &u); err != nil { return err } *cs = CharsetID(u) return nil } var s string if err := json.Unmarshal(p, &s); err != nil { return err } u, err := strconv.P...
go
func (cs *CharsetID) UnmarshalJSON(p []byte) error { if len(p) == 0 { return nil } if p[0] != '"' { var u uint16 if err := json.Unmarshal(p, &u); err != nil { return err } *cs = CharsetID(u) return nil } var s string if err := json.Unmarshal(p, &s); err != nil { return err } u, err := strconv.P...
[ "func", "(", "cs", "*", "CharsetID", ")", "UnmarshalJSON", "(", "p", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "p", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "if", "p", "[", "0", "]", "!=", "'\"'", "{", "var", "u", ...
// UnmarshalJSON converts the string to a CharsetID
[ "UnmarshalJSON", "converts", "the", "string", "to", "a", "CharsetID" ]
63e6d1acd3dd857ec6b8c54fbf52e10ce24a8786
https://github.com/josephspurrier/goversioninfo/blob/63e6d1acd3dd857ec6b8c54fbf52e10ce24a8786/lang_cs.go#L31-L53
19,590
josephspurrier/goversioninfo
lang_cs.go
UnmarshalJSON
func (lng *LangID) UnmarshalJSON(p []byte) error { if len(p) == 0 { return nil } if p[0] != '"' { var u uint16 if err := json.Unmarshal(p, &u); err != nil { return err } *lng = LangID(u) return nil } var s string if err := json.Unmarshal(p, &s); err != nil { return err } u, err := strconv.Parse...
go
func (lng *LangID) UnmarshalJSON(p []byte) error { if len(p) == 0 { return nil } if p[0] != '"' { var u uint16 if err := json.Unmarshal(p, &u); err != nil { return err } *lng = LangID(u) return nil } var s string if err := json.Unmarshal(p, &s); err != nil { return err } u, err := strconv.Parse...
[ "func", "(", "lng", "*", "LangID", ")", "UnmarshalJSON", "(", "p", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "p", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "if", "p", "[", "0", "]", "!=", "'\"'", "{", "var", "u", "...
// UnmarshalJSON converts the string to a LangID
[ "UnmarshalJSON", "converts", "the", "string", "to", "a", "LangID" ]
63e6d1acd3dd857ec6b8c54fbf52e10ce24a8786
https://github.com/josephspurrier/goversioninfo/blob/63e6d1acd3dd857ec6b8c54fbf52e10ce24a8786/lang_cs.go#L60-L82
19,591
josephspurrier/goversioninfo
structbuild.go
Build
func (v *VersionInfo) Build() { vi := VSVersionInfo{} // 0 for binary, 1 for text vi.WType = 0x00 vi.SzKey = padString("VS_VERSION_INFO", 0) // Align to 32-bit boundary // 6 is for the size of WLength, WValueLength, and WType (each is 1 word or 2 bytes: FF FF) soFar := 2 for (len(vi.SzKey)+6+soFar)%4 != 0 { ...
go
func (v *VersionInfo) Build() { vi := VSVersionInfo{} // 0 for binary, 1 for text vi.WType = 0x00 vi.SzKey = padString("VS_VERSION_INFO", 0) // Align to 32-bit boundary // 6 is for the size of WLength, WValueLength, and WType (each is 1 word or 2 bytes: FF FF) soFar := 2 for (len(vi.SzKey)+6+soFar)%4 != 0 { ...
[ "func", "(", "v", "*", "VersionInfo", ")", "Build", "(", ")", "{", "vi", ":=", "VSVersionInfo", "{", "}", "\n\n", "// 0 for binary, 1 for text", "vi", ".", "WType", "=", "0x00", "\n\n", "vi", ".", "SzKey", "=", "padString", "(", "\"", "\"", ",", "0", ...
// Build fills the structs with data from the config file
[ "Build", "fills", "the", "structs", "with", "data", "from", "the", "config", "file" ]
63e6d1acd3dd857ec6b8c54fbf52e10ce24a8786
https://github.com/josephspurrier/goversioninfo/blob/63e6d1acd3dd857ec6b8c54fbf52e10ce24a8786/structbuild.go#L295-L330
19,592
josephspurrier/goversioninfo
goversioninfo.go
GetVersionString
func (f FileVersion) GetVersionString() string { return fmt.Sprintf("%d.%d.%d.%d", f.Major, f.Minor, f.Patch, f.Build) }
go
func (f FileVersion) GetVersionString() string { return fmt.Sprintf("%d.%d.%d.%d", f.Major, f.Minor, f.Patch, f.Build) }
[ "func", "(", "f", "FileVersion", ")", "GetVersionString", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "f", ".", "Major", ",", "f", ".", "Minor", ",", "f", ".", "Patch", ",", "f", ".", "Build", ")", "\n", "}" ]
// GetVersionString returns a string representation of the version
[ "GetVersionString", "returns", "a", "string", "representation", "of", "the", "version" ]
63e6d1acd3dd857ec6b8c54fbf52e10ce24a8786
https://github.com/josephspurrier/goversioninfo/blob/63e6d1acd3dd857ec6b8c54fbf52e10ce24a8786/goversioninfo.go#L147-L149
19,593
josephspurrier/goversioninfo
goversioninfo.go
WriteSyso
func (vi *VersionInfo) WriteSyso(filename string, arch string) error { // Channel for generating IDs newID := make(chan uint16) go func() { for i := uint16(1); ; i++ { newID <- i } }() // Create a new RSRC section coff := coff.NewRSRC() // Set the architechture err := coff.Arch(arch) if err != nil { ...
go
func (vi *VersionInfo) WriteSyso(filename string, arch string) error { // Channel for generating IDs newID := make(chan uint16) go func() { for i := uint16(1); ; i++ { newID <- i } }() // Create a new RSRC section coff := coff.NewRSRC() // Set the architechture err := coff.Arch(arch) if err != nil { ...
[ "func", "(", "vi", "*", "VersionInfo", ")", "WriteSyso", "(", "filename", "string", ",", "arch", "string", ")", "error", "{", "// Channel for generating IDs", "newID", ":=", "make", "(", "chan", "uint16", ")", "\n", "go", "func", "(", ")", "{", "for", "i...
// WriteSyso creates a resource file from the version info and optionally an icon. // arch must be an architecture string accepted by coff.Arch, like "386" or "amd64"
[ "WriteSyso", "creates", "a", "resource", "file", "from", "the", "version", "info", "and", "optionally", "an", "icon", ".", "arch", "must", "be", "an", "architecture", "string", "accepted", "by", "coff", ".", "Arch", "like", "386", "or", "amd64" ]
63e6d1acd3dd857ec6b8c54fbf52e10ce24a8786
https://github.com/josephspurrier/goversioninfo/blob/63e6d1acd3dd857ec6b8c54fbf52e10ce24a8786/goversioninfo.go#L182-L228
19,594
josephspurrier/goversioninfo
goversioninfo.go
WriteHex
func (vi *VersionInfo) WriteHex(filename string) error { return ioutil.WriteFile(filename, vi.Buffer.Bytes(), 0655) }
go
func (vi *VersionInfo) WriteHex(filename string) error { return ioutil.WriteFile(filename, vi.Buffer.Bytes(), 0655) }
[ "func", "(", "vi", "*", "VersionInfo", ")", "WriteHex", "(", "filename", "string", ")", "error", "{", "return", "ioutil", ".", "WriteFile", "(", "filename", ",", "vi", ".", "Buffer", ".", "Bytes", "(", ")", ",", "0655", ")", "\n", "}" ]
// WriteHex creates a hex file for debugging version info
[ "WriteHex", "creates", "a", "hex", "file", "for", "debugging", "version", "info" ]
63e6d1acd3dd857ec6b8c54fbf52e10ce24a8786
https://github.com/josephspurrier/goversioninfo/blob/63e6d1acd3dd857ec6b8c54fbf52e10ce24a8786/goversioninfo.go#L231-L233
19,595
gramework/gramework
gqlhandler/gqlhandler.go
New
func New(schema *graphql.Schema) (*State, error) { if schema == nil { return nil, ErrNilSchema } s := &State{ schema: schema, } return s, nil }
go
func New(schema *graphql.Schema) (*State, error) { if schema == nil { return nil, ErrNilSchema } s := &State{ schema: schema, } return s, nil }
[ "func", "New", "(", "schema", "*", "graphql", ".", "Schema", ")", "(", "*", "State", ",", "error", ")", "{", "if", "schema", "==", "nil", "{", "return", "nil", ",", "ErrNilSchema", "\n", "}", "\n\n", "s", ":=", "&", "State", "{", "schema", ":", "...
// New returns gql handler state based on given schema
[ "New", "returns", "gql", "handler", "state", "based", "on", "given", "schema" ]
31c8d0b9955432cea19730996643bd857481d6a8
https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/gqlhandler/gqlhandler.go#L23-L32
19,596
gramework/gramework
gqlhandler/gqlhandler.go
Handler
func (s *State) Handler(ctx *gramework.Context) { if s.schema == nil { ctx.Logger.Error("schema is nil") ctx.Err500() return } // ok, we have the schema. try to decode request req, err := ctx.DecodeGQL() if err != nil { ctx.Logger.Warn("gql request decoding failed") ctx.Error("Invalid request", 400) r...
go
func (s *State) Handler(ctx *gramework.Context) { if s.schema == nil { ctx.Logger.Error("schema is nil") ctx.Err500() return } // ok, we have the schema. try to decode request req, err := ctx.DecodeGQL() if err != nil { ctx.Logger.Warn("gql request decoding failed") ctx.Error("Invalid request", 400) r...
[ "func", "(", "s", "*", "State", ")", "Handler", "(", "ctx", "*", "gramework", ".", "Context", ")", "{", "if", "s", ".", "schema", "==", "nil", "{", "ctx", ".", "Logger", ".", "Error", "(", "\"", "\"", ")", "\n", "ctx", ".", "Err500", "(", ")", ...
// Handler is the simplest
[ "Handler", "is", "the", "simplest" ]
31c8d0b9955432cea19730996643bd857481d6a8
https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/gqlhandler/gqlhandler.go#L35-L67
19,597
gramework/gramework
app_serve.go
Serve
func (app *App) Serve(ln net.Listener) error { var err error srv := app.copyServer() app.runningServersMu.Lock() app.runningServers = append(app.runningServers, runningServerInfo{ bind: ln.Addr().String(), srv: srv, }) app.runningServersMu.Unlock() if err = srv.Serve(ln); err != nil { app.internalLog.Erro...
go
func (app *App) Serve(ln net.Listener) error { var err error srv := app.copyServer() app.runningServersMu.Lock() app.runningServers = append(app.runningServers, runningServerInfo{ bind: ln.Addr().String(), srv: srv, }) app.runningServersMu.Unlock() if err = srv.Serve(ln); err != nil { app.internalLog.Erro...
[ "func", "(", "app", "*", "App", ")", "Serve", "(", "ln", "net", ".", "Listener", ")", "error", "{", "var", "err", "error", "\n", "srv", ":=", "app", ".", "copyServer", "(", ")", "\n", "app", ".", "runningServersMu", ".", "Lock", "(", ")", "\n", "...
// Serve app on given listener
[ "Serve", "app", "on", "given", "listener" ]
31c8d0b9955432cea19730996643bd857481d6a8
https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/app_serve.go#L18-L32
19,598
gramework/gramework
infrastructure/getTypeByString.go
GetTypeByString
func GetTypeByString(typeName string) (ServiceType, error) { switch ServiceType(typeName) { case HTTP: return HTTP, nil case HTTPS: return HTTPS, nil case TCP: return TCP, nil case UDP: return UDP, nil case Custom: return Custom, nil default: return ServiceType(typeName), ErrServiceTypeNotFound } }
go
func GetTypeByString(typeName string) (ServiceType, error) { switch ServiceType(typeName) { case HTTP: return HTTP, nil case HTTPS: return HTTPS, nil case TCP: return TCP, nil case UDP: return UDP, nil case Custom: return Custom, nil default: return ServiceType(typeName), ErrServiceTypeNotFound } }
[ "func", "GetTypeByString", "(", "typeName", "string", ")", "(", "ServiceType", ",", "error", ")", "{", "switch", "ServiceType", "(", "typeName", ")", "{", "case", "HTTP", ":", "return", "HTTP", ",", "nil", "\n", "case", "HTTPS", ":", "return", "HTTPS", "...
// GetTypeByString returns a ServiceType associated with // given typeName and nil, if type is known, otherwise // instantiates a ServiceType with given typeName // but returns ErrServiceTypeNotFound
[ "GetTypeByString", "returns", "a", "ServiceType", "associated", "with", "given", "typeName", "and", "nil", "if", "type", "is", "known", "otherwise", "instantiates", "a", "ServiceType", "with", "given", "typeName", "but", "returns", "ErrServiceTypeNotFound" ]
31c8d0b9955432cea19730996643bd857481d6a8
https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/infrastructure/getTypeByString.go#L17-L32
19,599
gramework/gramework
router.go
SPAIndex
func (r *Router) SPAIndex(pathOrHandler interface{}) *Router { switch v := pathOrHandler.(type) { case string: r.NotFound(func(ctx *Context) { ctx.HTML() ctx.SendFile(v) }) default: r.NotFound(r.determineHandler(v)) } return r }
go
func (r *Router) SPAIndex(pathOrHandler interface{}) *Router { switch v := pathOrHandler.(type) { case string: r.NotFound(func(ctx *Context) { ctx.HTML() ctx.SendFile(v) }) default: r.NotFound(r.determineHandler(v)) } return r }
[ "func", "(", "r", "*", "Router", ")", "SPAIndex", "(", "pathOrHandler", "interface", "{", "}", ")", "*", "Router", "{", "switch", "v", ":=", "pathOrHandler", ".", "(", "type", ")", "{", "case", "string", ":", "r", ".", "NotFound", "(", "func", "(", ...
// SPAIndex serves an index file or handler on any unregistered route
[ "SPAIndex", "serves", "an", "index", "file", "or", "handler", "on", "any", "unregistered", "route" ]
31c8d0b9955432cea19730996643bd857481d6a8
https://github.com/gramework/gramework/blob/31c8d0b9955432cea19730996643bd857481d6a8/router.go#L89-L100