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
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
149,200
mrmorphic/hwio
module_bb_pwm.go
SetPeriod
func (module *BBPWMModule) SetPeriod(pin Pin, ns int64) error { openPin := module.openPins[pin] if openPin == nil { return fmt.Errorf("PWM pin is being written but is not enabled. Have you called EnablePin?") } return openPin.setPeriod(ns) }
go
func (module *BBPWMModule) SetPeriod(pin Pin, ns int64) error { openPin := module.openPins[pin] if openPin == nil { return fmt.Errorf("PWM pin is being written but is not enabled. Have you called EnablePin?") } return openPin.setPeriod(ns) }
[ "func", "(", "module", "*", "BBPWMModule", ")", "SetPeriod", "(", "pin", "Pin", ",", "ns", "int64", ")", "error", "{", "openPin", ":=", "module", ".", "openPins", "[", "pin", "]", "\n", "if", "openPin", "==", "nil", "{", "return", "fmt", ".", "Errorf...
// Set the period of this pin, in nanoseconds
[ "Set", "the", "period", "of", "this", "pin", "in", "nanoseconds" ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/module_bb_pwm.go#L122-L129
149,201
mrmorphic/hwio
module_bb_pwm.go
SetDuty
func (module *BBPWMModule) SetDuty(pin Pin, ns int64) error { openPin := module.openPins[pin] if openPin == nil { return fmt.Errorf("PWM pin is being written but is not enabled. Have you called EnablePin?") } return openPin.setDuty(ns) }
go
func (module *BBPWMModule) SetDuty(pin Pin, ns int64) error { openPin := module.openPins[pin] if openPin == nil { return fmt.Errorf("PWM pin is being written but is not enabled. Have you called EnablePin?") } return openPin.setDuty(ns) }
[ "func", "(", "module", "*", "BBPWMModule", ")", "SetDuty", "(", "pin", "Pin", ",", "ns", "int64", ")", "error", "{", "openPin", ":=", "module", ".", "openPins", "[", "pin", "]", "\n", "if", "openPin", "==", "nil", "{", "return", "fmt", ".", "Errorf",...
// Set the duty time, the amount of time during each period that that output is HIGH.
[ "Set", "the", "duty", "time", "the", "amount", "of", "time", "during", "each", "period", "that", "that", "output", "is", "HIGH", "." ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/module_bb_pwm.go#L132-L139
149,202
mrmorphic/hwio
module_bb_pwm.go
ensureSlot
func (module *BBPWMModule) ensureSlot(item string) error { path, e := findFirstMatchingFile("/sys/devices/bone_capemgr.*/slots") if e != nil { return e } file, e := os.Open(path) if e != nil { return e } scanner := bufio.NewScanner(file) for scanner.Scan() { line := scanner.Text() if strings.Index(lin...
go
func (module *BBPWMModule) ensureSlot(item string) error { path, e := findFirstMatchingFile("/sys/devices/bone_capemgr.*/slots") if e != nil { return e } file, e := os.Open(path) if e != nil { return e } scanner := bufio.NewScanner(file) for scanner.Scan() { line := scanner.Text() if strings.Index(lin...
[ "func", "(", "module", "*", "BBPWMModule", ")", "ensureSlot", "(", "item", "string", ")", "error", "{", "path", ",", "e", ":=", "findFirstMatchingFile", "(", "\"", "\"", ")", "\n", "if", "e", "!=", "nil", "{", "return", "e", "\n", "}", "\n\n", "file"...
// Add the named thing to the capemanager slots file. // @todo refactor for beaglebone black driver, and refactor analog as well which does the same thing.
[ "Add", "the", "named", "thing", "to", "the", "capemanager", "slots", "file", "." ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/module_bb_pwm.go#L179-L203
149,203
mrmorphic/hwio
devices/hd44780/hd44780_i2c.go
NoBlink
func (display *HD44780) NoBlink() { display.displayControl &= ^LCD_BLINKON display.Command(LCD_DISPLAYCONTROL | display.displayControl) }
go
func (display *HD44780) NoBlink() { display.displayControl &= ^LCD_BLINKON display.Command(LCD_DISPLAYCONTROL | display.displayControl) }
[ "func", "(", "display", "*", "HD44780", ")", "NoBlink", "(", ")", "{", "display", ".", "displayControl", "&=", "^", "LCD_BLINKON", "\n", "display", ".", "Command", "(", "LCD_DISPLAYCONTROL", "|", "display", ".", "displayControl", ")", "\n", "}" ]
// Turn on and off the blinking cursor
[ "Turn", "on", "and", "off", "the", "blinking", "cursor" ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/hd44780/hd44780_i2c.go#L234-L237
149,204
mrmorphic/hwio
devices/hd44780/hd44780_i2c.go
LeftToRight
func (display *HD44780) LeftToRight() { display.displayMode |= LCD_ENTRYLEFT display.Command(LCD_ENTRYMODESET | display.displayMode) }
go
func (display *HD44780) LeftToRight() { display.displayMode |= LCD_ENTRYLEFT display.Command(LCD_ENTRYMODESET | display.displayMode) }
[ "func", "(", "display", "*", "HD44780", ")", "LeftToRight", "(", ")", "{", "display", ".", "displayMode", "|=", "LCD_ENTRYLEFT", "\n", "display", ".", "Command", "(", "LCD_ENTRYMODESET", "|", "display", ".", "displayMode", ")", "\n", "}" ]
// This is for text that flows Left to Right
[ "This", "is", "for", "text", "that", "flows", "Left", "to", "Right" ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/hd44780/hd44780_i2c.go#L253-L256
149,205
mrmorphic/hwio
devices/hd44780/hd44780_i2c.go
RightToLeft
func (display *HD44780) RightToLeft() { display.displayMode &= ^LCD_ENTRYLEFT display.Command(LCD_ENTRYMODESET | display.displayMode) }
go
func (display *HD44780) RightToLeft() { display.displayMode &= ^LCD_ENTRYLEFT display.Command(LCD_ENTRYMODESET | display.displayMode) }
[ "func", "(", "display", "*", "HD44780", ")", "RightToLeft", "(", ")", "{", "display", ".", "displayMode", "&=", "^", "LCD_ENTRYLEFT", "\n", "display", ".", "Command", "(", "LCD_ENTRYMODESET", "|", "display", ".", "displayMode", ")", "\n", "}" ]
// This is for text that flows Right to Left
[ "This", "is", "for", "text", "that", "flows", "Right", "to", "Left" ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/hd44780/hd44780_i2c.go#L259-L262
149,206
mrmorphic/hwio
devices/hd44780/hd44780_i2c.go
Autoscroll
func (display *HD44780) Autoscroll() { display.displayMode |= LCD_ENTRYSHIFTINCREMENT display.Command(LCD_ENTRYMODESET | display.displayMode) }
go
func (display *HD44780) Autoscroll() { display.displayMode |= LCD_ENTRYSHIFTINCREMENT display.Command(LCD_ENTRYMODESET | display.displayMode) }
[ "func", "(", "display", "*", "HD44780", ")", "Autoscroll", "(", ")", "{", "display", ".", "displayMode", "|=", "LCD_ENTRYSHIFTINCREMENT", "\n", "display", ".", "Command", "(", "LCD_ENTRYMODESET", "|", "display", ".", "displayMode", ")", "\n", "}" ]
// This will 'right justify' text from the cursor
[ "This", "will", "right", "justify", "text", "from", "the", "cursor" ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/hd44780/hd44780_i2c.go#L265-L268
149,207
mrmorphic/hwio
devices/hd44780/hd44780_i2c.go
NoAutoscroll
func (display *HD44780) NoAutoscroll() { display.displayMode &= ^LCD_ENTRYSHIFTINCREMENT display.Command(LCD_ENTRYMODESET | display.displayMode) }
go
func (display *HD44780) NoAutoscroll() { display.displayMode &= ^LCD_ENTRYSHIFTINCREMENT display.Command(LCD_ENTRYMODESET | display.displayMode) }
[ "func", "(", "display", "*", "HD44780", ")", "NoAutoscroll", "(", ")", "{", "display", ".", "displayMode", "&=", "^", "LCD_ENTRYSHIFTINCREMENT", "\n", "display", ".", "Command", "(", "LCD_ENTRYMODESET", "|", "display", ".", "displayMode", ")", "\n", "}" ]
// This will 'left justify' text from the cursor
[ "This", "will", "left", "justify", "text", "from", "the", "cursor" ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/hd44780/hd44780_i2c.go#L271-L274
149,208
mrmorphic/hwio
devices/hd44780/hd44780_i2c.go
write4bits
func (display *HD44780) write4bits(data byte, mode byte) { // map the 4 low bits of data into d var d byte = 0 if data&0x08 != 0 { d |= display.d7 } if data&0x04 != 0 { d |= display.d6 } if data&0x02 != 0 { d |= display.d5 } if data&0x01 != 0 { d |= display.d4 } display.expanderWrite(d | mode) displ...
go
func (display *HD44780) write4bits(data byte, mode byte) { // map the 4 low bits of data into d var d byte = 0 if data&0x08 != 0 { d |= display.d7 } if data&0x04 != 0 { d |= display.d6 } if data&0x02 != 0 { d |= display.d5 } if data&0x01 != 0 { d |= display.d4 } display.expanderWrite(d | mode) displ...
[ "func", "(", "display", "*", "HD44780", ")", "write4bits", "(", "data", "byte", ",", "mode", "byte", ")", "{", "// map the 4 low bits of data into d", "var", "d", "byte", "=", "0", "\n", "if", "data", "&", "0x08", "!=", "0", "{", "d", "|=", "display", ...
// write 4 bits to the port extender. The low 4 bits of data are mapped to the d7-d4 pins on the device, // so you cannot OR other control bits to the data. Mode is provided for that.
[ "write", "4", "bits", "to", "the", "port", "extender", ".", "The", "low", "4", "bits", "of", "data", "are", "mapped", "to", "the", "d7", "-", "d4", "pins", "on", "the", "device", "so", "you", "cannot", "OR", "other", "control", "bits", "to", "the", ...
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/hd44780/hd44780_i2c.go#L312-L329
149,209
mrmorphic/hwio
devices/hd44780/hd44780_i2c.go
expanderWrite
func (display *HD44780) expanderWrite(data byte) { display.device.WriteByte(data|display.backlight, 0) }
go
func (display *HD44780) expanderWrite(data byte) { display.device.WriteByte(data|display.backlight, 0) }
[ "func", "(", "display", "*", "HD44780", ")", "expanderWrite", "(", "data", "byte", ")", "{", "display", ".", "device", ".", "WriteByte", "(", "data", "|", "display", ".", "backlight", ",", "0", ")", "\n", "}" ]
// Write a byte to the port expander. The bits are already assumed to be in the right positions for // the device profile.
[ "Write", "a", "byte", "to", "the", "port", "expander", ".", "The", "bits", "are", "already", "assumed", "to", "be", "in", "the", "right", "positions", "for", "the", "device", "profile", "." ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/hd44780/hd44780_i2c.go#L333-L335
149,210
mrmorphic/hwio
devices/gy520/gy520.go
Wake
func (g *GY520) Wake() error { v, e := g.device.ReadByte(REG_PWR_MGMT_1) if e != nil { return e } v &= ^byte(PARAM_SLEEP) e = g.device.WriteByte(REG_PWR_MGMT_1, v) if e != nil { return e } return nil }
go
func (g *GY520) Wake() error { v, e := g.device.ReadByte(REG_PWR_MGMT_1) if e != nil { return e } v &= ^byte(PARAM_SLEEP) e = g.device.WriteByte(REG_PWR_MGMT_1, v) if e != nil { return e } return nil }
[ "func", "(", "g", "*", "GY520", ")", "Wake", "(", ")", "error", "{", "v", ",", "e", ":=", "g", ".", "device", ".", "ReadByte", "(", "REG_PWR_MGMT_1", ")", "\n", "if", "e", "!=", "nil", "{", "return", "e", "\n", "}", "\n\n", "v", "&=", "^", "b...
// Wake the device. By default on power on, the device is asleep.
[ "Wake", "the", "device", ".", "By", "default", "on", "power", "on", "the", "device", "is", "asleep", "." ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/gy520/gy520.go#L60-L74
149,211
mrmorphic/hwio
pin.go
Add
func (m HardwarePinMap) Add(pin Pin, names []string, modules []string) { m[pin] = &PinDef{pin, names, modules} }
go
func (m HardwarePinMap) Add(pin Pin, names []string, modules []string) { m[pin] = &PinDef{pin, names, modules} }
[ "func", "(", "m", "HardwarePinMap", ")", "Add", "(", "pin", "Pin", ",", "names", "[", "]", "string", ",", "modules", "[", "]", "string", ")", "{", "m", "[", "pin", "]", "=", "&", "PinDef", "{", "pin", ",", "names", ",", "modules", "}", "\n", "}...
// Add a pin to the map
[ "Add", "a", "pin", "to", "the", "map" ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/pin.go#L52-L54
149,212
mrmorphic/hwio
pin.go
String
func (pd *PinDef) String() string { s := pd.Names() + " modules:" + strings.Join(pd.modules, ",") return s }
go
func (pd *PinDef) String() string { s := pd.Names() + " modules:" + strings.Join(pd.modules, ",") return s }
[ "func", "(", "pd", "*", "PinDef", ")", "String", "(", ")", "string", "{", "s", ":=", "pd", ".", "Names", "(", ")", "+", "\"", "\"", "+", "strings", ".", "Join", "(", "pd", ".", "modules", ",", "\"", "\"", ")", "\n", "return", "s", "\n", "}" ]
// Provide a string representation of a logic pin and the capabilties it // supports.
[ "Provide", "a", "string", "representation", "of", "a", "logic", "pin", "and", "the", "capabilties", "it", "supports", "." ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/pin.go#L63-L66
149,213
mrmorphic/hwio
module_dtgpio.go
gpioUnexport
func (op *DTGPIOModuleOpenPin) gpioUnexport() error { s := strconv.FormatInt(int64(op.gpioLogical), 10) e := WriteStringToFile("/sys/class/gpio/unexport", s) if e != nil { return e } return nil }
go
func (op *DTGPIOModuleOpenPin) gpioUnexport() error { s := strconv.FormatInt(int64(op.gpioLogical), 10) e := WriteStringToFile("/sys/class/gpio/unexport", s) if e != nil { return e } return nil }
[ "func", "(", "op", "*", "DTGPIOModuleOpenPin", ")", "gpioUnexport", "(", ")", "error", "{", "s", ":=", "strconv", ".", "FormatInt", "(", "int64", "(", "op", ".", "gpioLogical", ")", ",", "10", ")", "\n", "e", ":=", "WriteStringToFile", "(", "\"", "\"",...
// Needs to be called to allocate the GPIO pin
[ "Needs", "to", "be", "called", "to", "allocate", "the", "GPIO", "pin" ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/module_dtgpio.go#L190-L198
149,214
mrmorphic/hwio
module_dtgpio.go
gpioDirection
func (op *DTGPIOModuleOpenPin) gpioDirection(dir string) error { if dir != "in" && dir != "out" { return errors.New("direction must be in or out") } f := op.gpioBaseName + "/direction" e := WriteStringToFile(f, dir) mode := os.O_WRONLY | os.O_TRUNC if dir == "in" { mode = os.O_RDONLY } // open the value f...
go
func (op *DTGPIOModuleOpenPin) gpioDirection(dir string) error { if dir != "in" && dir != "out" { return errors.New("direction must be in or out") } f := op.gpioBaseName + "/direction" e := WriteStringToFile(f, dir) mode := os.O_WRONLY | os.O_TRUNC if dir == "in" { mode = os.O_RDONLY } // open the value f...
[ "func", "(", "op", "*", "DTGPIOModuleOpenPin", ")", "gpioDirection", "(", "dir", "string", ")", "error", "{", "if", "dir", "!=", "\"", "\"", "&&", "dir", "!=", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", ...
// Once exported, the direction of a GPIO can be set
[ "Once", "exported", "the", "direction", "of", "a", "GPIO", "can", "be", "set" ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/module_dtgpio.go#L201-L220
149,215
mrmorphic/hwio
module_dtgpio.go
gpioGetValue
func (op *DTGPIOModuleOpenPin) gpioGetValue() (int, error) { var b []byte b = make([]byte, 1) n, e := op.valueFile.ReadAt(b, 0) value := 0 if n > 0 { if b[0] == '1' { value = HIGH } else { value = LOW } } return value, e }
go
func (op *DTGPIOModuleOpenPin) gpioGetValue() (int, error) { var b []byte b = make([]byte, 1) n, e := op.valueFile.ReadAt(b, 0) value := 0 if n > 0 { if b[0] == '1' { value = HIGH } else { value = LOW } } return value, e }
[ "func", "(", "op", "*", "DTGPIOModuleOpenPin", ")", "gpioGetValue", "(", ")", "(", "int", ",", "error", ")", "{", "var", "b", "[", "]", "byte", "\n", "b", "=", "make", "(", "[", "]", "byte", ",", "1", ")", "\n", "n", ",", "e", ":=", "op", "."...
// Get the value. Will return HIGH or LOW
[ "Get", "the", "value", ".", "Will", "return", "HIGH", "or", "LOW" ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/module_dtgpio.go#L223-L237
149,216
mrmorphic/hwio
module_dtgpio.go
gpioSetValue
func (op *DTGPIOModuleOpenPin) gpioSetValue(value int) error { if op.valueFile == nil { fmt.Printf("value file no set\n") return errors.New("value file is not defined") } // Seek the start of the value file before writing. This is sufficient for the driver to accept a new value. _, e := op.valueFile.Seek(0, 0)...
go
func (op *DTGPIOModuleOpenPin) gpioSetValue(value int) error { if op.valueFile == nil { fmt.Printf("value file no set\n") return errors.New("value file is not defined") } // Seek the start of the value file before writing. This is sufficient for the driver to accept a new value. _, e := op.valueFile.Seek(0, 0)...
[ "func", "(", "op", "*", "DTGPIOModuleOpenPin", ")", "gpioSetValue", "(", "value", "int", ")", "error", "{", "if", "op", ".", "valueFile", "==", "nil", "{", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ")", "\n", "return", "errors", ".", "New", "(", ...
// Set the value, Expects HIGH or LOW
[ "Set", "the", "value", "Expects", "HIGH", "or", "LOW" ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/module_dtgpio.go#L240-L263
149,217
mrmorphic/hwio
module_dtleds.go
GetLED
func (m *DTLEDModule) GetLED(led string) (LEDModuleLED, error) { led = strings.ToLower(led) if ol := m.leds[led]; ol != nil { return ol, nil } if pin := m.definedPins[led]; pin != "" { result := &DTLEDModuleLED{} result.path = pin result.currentTrigger = "" m.leds[led] = result return result, nil } e...
go
func (m *DTLEDModule) GetLED(led string) (LEDModuleLED, error) { led = strings.ToLower(led) if ol := m.leds[led]; ol != nil { return ol, nil } if pin := m.definedPins[led]; pin != "" { result := &DTLEDModuleLED{} result.path = pin result.currentTrigger = "" m.leds[led] = result return result, nil } e...
[ "func", "(", "m", "*", "DTLEDModule", ")", "GetLED", "(", "led", "string", ")", "(", "LEDModuleLED", ",", "error", ")", "{", "led", "=", "strings", ".", "ToLower", "(", "led", ")", "\n\n", "if", "ol", ":=", "m", ".", "leds", "[", "led", "]", ";",...
// Get a LED to manipulate. 'led' must be 0 to 3.
[ "Get", "a", "LED", "to", "manipulate", ".", "led", "must", "be", "0", "to", "3", "." ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/module_dtleds.go#L58-L74
149,218
mrmorphic/hwio
cpuinfo.go
CpuInfo
func CpuInfo(cpu int, property string) string { if cpuInfo == nil { loadCpuInfo() } return cpuInfo[fmt.Sprintf("%d:%s", cpu, property)] }
go
func CpuInfo(cpu int, property string) string { if cpuInfo == nil { loadCpuInfo() } return cpuInfo[fmt.Sprintf("%d:%s", cpu, property)] }
[ "func", "CpuInfo", "(", "cpu", "int", ",", "property", "string", ")", "string", "{", "if", "cpuInfo", "==", "nil", "{", "loadCpuInfo", "(", ")", "\n", "}", "\n\n", "return", "cpuInfo", "[", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "cpu", ",", "...
// Look up property for a CPU. CPU's start at 0.
[ "Look", "up", "property", "for", "a", "CPU", ".", "CPU", "s", "start", "at", "0", "." ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/cpuinfo.go#L18-L24
149,219
mrmorphic/hwio
devices/mcp23017/mcp23017.go
SetPortA
func (d *MCP23017) SetPortA(value byte) error { return d.device.WriteByte(REG_GPIOA, value) }
go
func (d *MCP23017) SetPortA(value byte) error { return d.device.WriteByte(REG_GPIOA, value) }
[ "func", "(", "d", "*", "MCP23017", ")", "SetPortA", "(", "value", "byte", ")", "error", "{", "return", "d", ".", "device", ".", "WriteByte", "(", "REG_GPIOA", ",", "value", ")", "\n", "}" ]
// Write to port A
[ "Write", "to", "port", "A" ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/mcp23017/mcp23017.go#L87-L89
149,220
mrmorphic/hwio
devices/mcp23017/mcp23017.go
SetPortB
func (d *MCP23017) SetPortB(value byte) error { return d.device.WriteByte(REG_GPIOB, value) }
go
func (d *MCP23017) SetPortB(value byte) error { return d.device.WriteByte(REG_GPIOB, value) }
[ "func", "(", "d", "*", "MCP23017", ")", "SetPortB", "(", "value", "byte", ")", "error", "{", "return", "d", ".", "device", ".", "WriteByte", "(", "REG_GPIOB", ",", "value", ")", "\n", "}" ]
// Write to port B
[ "Write", "to", "port", "B" ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/mcp23017/mcp23017.go#L92-L94
149,221
mrmorphic/hwio
devices/mcp23017/mcp23017.go
SetPullupA
func (d *MCP23017) SetPullupA(value byte) error { return d.device.WriteByte(REG_GPPUA, value) }
go
func (d *MCP23017) SetPullupA(value byte) error { return d.device.WriteByte(REG_GPPUA, value) }
[ "func", "(", "d", "*", "MCP23017", ")", "SetPullupA", "(", "value", "byte", ")", "error", "{", "return", "d", ".", "device", ".", "WriteByte", "(", "REG_GPPUA", ",", "value", ")", "\n", "}" ]
// Set pull-up configuration for port A. If a bit is 1 and the corresponding pin is // an input, a pull-up resistor of about 100K is enabled. A zero bit indicates no pull-up.
[ "Set", "pull", "-", "up", "configuration", "for", "port", "A", ".", "If", "a", "bit", "is", "1", "and", "the", "corresponding", "pin", "is", "an", "input", "a", "pull", "-", "up", "resistor", "of", "about", "100K", "is", "enabled", ".", "A", "zero", ...
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/mcp23017/mcp23017.go#L98-L100
149,222
mrmorphic/hwio
devices/mcp23017/mcp23017.go
SetPullupB
func (d *MCP23017) SetPullupB(value byte) error { return d.device.WriteByte(REG_GPPUB, value) }
go
func (d *MCP23017) SetPullupB(value byte) error { return d.device.WriteByte(REG_GPPUB, value) }
[ "func", "(", "d", "*", "MCP23017", ")", "SetPullupB", "(", "value", "byte", ")", "error", "{", "return", "d", ".", "device", ".", "WriteByte", "(", "REG_GPPUB", ",", "value", ")", "\n", "}" ]
// Set pull-up configuration for port B. If a bit is 1 and the corresponding pin is // an input, a pull-up resistor of about 100K is enabled. A zero bit indicates no pull-up.
[ "Set", "pull", "-", "up", "configuration", "for", "port", "B", ".", "If", "a", "bit", "is", "1", "and", "the", "corresponding", "pin", "is", "an", "input", "a", "pull", "-", "up", "resistor", "of", "about", "100K", "is", "enabled", ".", "A", "zero", ...
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/mcp23017/mcp23017.go#L104-L106
149,223
mrmorphic/hwio
devices/nunchuck/nunchuck.go
ReadSensors
func (n *Nunchuck) ReadSensors() error { // Get bytes from the sensor, packed into 6 bytes. bytes, e := n.device.Read(0, 6) if e != nil { return e } if len(bytes) < 6 { return fmt.Errorf("Error getting nunchuck data, expected 6 bytes but got %d", len(bytes)) } // Split out the packet into the n.last* varia...
go
func (n *Nunchuck) ReadSensors() error { // Get bytes from the sensor, packed into 6 bytes. bytes, e := n.device.Read(0, 6) if e != nil { return e } if len(bytes) < 6 { return fmt.Errorf("Error getting nunchuck data, expected 6 bytes but got %d", len(bytes)) } // Split out the packet into the n.last* varia...
[ "func", "(", "n", "*", "Nunchuck", ")", "ReadSensors", "(", ")", "error", "{", "// Get bytes from the sensor, packed into 6 bytes.", "bytes", ",", "e", ":=", "n", ".", "device", ".", "Read", "(", "0", ",", "6", ")", "\n", "if", "e", "!=", "nil", "{", "...
// Read all sensor values from the nunchuck and reads them into the internal state of the nunchuck instance. // Use Get methods to retrieve sensor values since last call of ReadSensors.
[ "Read", "all", "sensor", "values", "from", "the", "nunchuck", "and", "reads", "them", "into", "the", "internal", "state", "of", "the", "nunchuck", "instance", ".", "Use", "Get", "methods", "to", "retrieve", "sensor", "values", "since", "last", "call", "of", ...
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/nunchuck/nunchuck.go#L72-L109
149,224
mrmorphic/hwio
devices/nunchuck/nunchuck.go
SetJoystickZero
func (n *Nunchuck) SetJoystickZero(x int, y int) { n.zeroJoyX = x n.zeroJoyY = y }
go
func (n *Nunchuck) SetJoystickZero(x int, y int) { n.zeroJoyX = x n.zeroJoyY = y }
[ "func", "(", "n", "*", "Nunchuck", ")", "SetJoystickZero", "(", "x", "int", ",", "y", "int", ")", "{", "n", ".", "zeroJoyX", "=", "x", "\n", "n", ".", "zeroJoyY", "=", "y", "\n", "}" ]
// Calibrate the joystick to explicit values.
[ "Calibrate", "the", "joystick", "to", "explicit", "values", "." ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/nunchuck/nunchuck.go#L117-L120
149,225
mrmorphic/hwio
devices/nunchuck/nunchuck.go
GetRoll
func (n *Nunchuck) GetRoll() float32 { return float32(math.Atan2(float64(n.lastAccelX), float64(n.lastAccelZ)) / math.Pi * 180.0) }
go
func (n *Nunchuck) GetRoll() float32 { return float32(math.Atan2(float64(n.lastAccelX), float64(n.lastAccelZ)) / math.Pi * 180.0) }
[ "func", "(", "n", "*", "Nunchuck", ")", "GetRoll", "(", ")", "float32", "{", "return", "float32", "(", "math", ".", "Atan2", "(", "float64", "(", "n", ".", "lastAccelX", ")", ",", "float64", "(", "n", ".", "lastAccelZ", ")", ")", "/", "math", ".", ...
// Read roll in degrees, computed from accelerometer
[ "Read", "roll", "in", "degrees", "computed", "from", "accelerometer" ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/nunchuck/nunchuck.go#L145-L147
149,226
mrmorphic/hwio
devices/nunchuck/nunchuck.go
GetPitch
func (n *Nunchuck) GetPitch() float32 { return float32(math.Acos(float64(n.lastAccelY)/RADIUS) / math.Pi * 180.0) }
go
func (n *Nunchuck) GetPitch() float32 { return float32(math.Acos(float64(n.lastAccelY)/RADIUS) / math.Pi * 180.0) }
[ "func", "(", "n", "*", "Nunchuck", ")", "GetPitch", "(", ")", "float32", "{", "return", "float32", "(", "math", ".", "Acos", "(", "float64", "(", "n", ".", "lastAccelY", ")", "/", "RADIUS", ")", "/", "math", ".", "Pi", "*", "180.0", ")", "\n", "}...
// Read pitch in degrees, computed from accelerometer
[ "Read", "pitch", "in", "degrees", "computed", "from", "accelerometer" ]
11ea3f481a1404aa1de932554dd25858ee509163
https://github.com/mrmorphic/hwio/blob/11ea3f481a1404aa1de932554dd25858ee509163/devices/nunchuck/nunchuck.go#L150-L152
149,227
eternnoir/gncp
pool.go
Get
func (p *GncpPool) Get() (net.Conn, error) { if p.isClosed() == true { return nil, errPoolIsClose } go func() { conn, err := p.createConn() if err != nil { return } p.conns <- conn }() select { case conn := <-p.conns: return p.packConn(conn), nil } }
go
func (p *GncpPool) Get() (net.Conn, error) { if p.isClosed() == true { return nil, errPoolIsClose } go func() { conn, err := p.createConn() if err != nil { return } p.conns <- conn }() select { case conn := <-p.conns: return p.packConn(conn), nil } }
[ "func", "(", "p", "*", "GncpPool", ")", "Get", "(", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "if", "p", ".", "isClosed", "(", ")", "==", "true", "{", "return", "nil", ",", "errPoolIsClose", "\n", "}", "\n", "go", "func", "(", ")", ...
// Get get connection from connection pool. If connection poll is empty and alreay created connection number less than Max number of connection // it will create new one. Otherwise it wil wait someone put connection back.
[ "Get", "get", "connection", "from", "connection", "pool", ".", "If", "connection", "poll", "is", "empty", "and", "alreay", "created", "connection", "number", "less", "than", "Max", "number", "of", "connection", "it", "will", "create", "new", "one", ".", "Oth...
c70df2d0cd68bfc27074d632653aed73cdb2b078
https://github.com/eternnoir/gncp/blob/c70df2d0cd68bfc27074d632653aed73cdb2b078/pool.go#L73-L88
149,228
eternnoir/gncp
pool.go
GetWithTimeout
func (p *GncpPool) GetWithTimeout(timeout time.Duration) (net.Conn, error) { if p.isClosed() == true { return nil, errPoolIsClose } go func() { conn, err := p.createConn() if err != nil { return } p.conns <- conn }() select { case conn := <-p.conns: return p.packConn(conn), nil case <-time.After(t...
go
func (p *GncpPool) GetWithTimeout(timeout time.Duration) (net.Conn, error) { if p.isClosed() == true { return nil, errPoolIsClose } go func() { conn, err := p.createConn() if err != nil { return } p.conns <- conn }() select { case conn := <-p.conns: return p.packConn(conn), nil case <-time.After(t...
[ "func", "(", "p", "*", "GncpPool", ")", "GetWithTimeout", "(", "timeout", "time", ".", "Duration", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "if", "p", ".", "isClosed", "(", ")", "==", "true", "{", "return", "nil", ",", "errPoolIsClose", ...
// GetWithTimeout can let you get connection wait for a time duration. If cannot get connection in this time. // It will return TimeOutError.
[ "GetWithTimeout", "can", "let", "you", "get", "connection", "wait", "for", "a", "time", "duration", ".", "If", "cannot", "get", "connection", "in", "this", "time", ".", "It", "will", "return", "TimeOutError", "." ]
c70df2d0cd68bfc27074d632653aed73cdb2b078
https://github.com/eternnoir/gncp/blob/c70df2d0cd68bfc27074d632653aed73cdb2b078/pool.go#L92-L109
149,229
eternnoir/gncp
pool.go
Close
func (p *GncpPool) Close() error { if p.isClosed() == true { return errPoolIsClose } p.lock.Lock() defer p.lock.Unlock() p.closed = true close(p.conns) for conn := range p.conns { conn.Close() } return nil }
go
func (p *GncpPool) Close() error { if p.isClosed() == true { return errPoolIsClose } p.lock.Lock() defer p.lock.Unlock() p.closed = true close(p.conns) for conn := range p.conns { conn.Close() } return nil }
[ "func", "(", "p", "*", "GncpPool", ")", "Close", "(", ")", "error", "{", "if", "p", ".", "isClosed", "(", ")", "==", "true", "{", "return", "errPoolIsClose", "\n", "}", "\n", "p", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "lo...
// Close close the connection pool. When close the connection pool it also close all connection already in connection pool. // If connection not put back in connection it will not close. But it will close when it put back.
[ "Close", "close", "the", "connection", "pool", ".", "When", "close", "the", "connection", "pool", "it", "also", "close", "all", "connection", "already", "in", "connection", "pool", ".", "If", "connection", "not", "put", "back", "in", "connection", "it", "wil...
c70df2d0cd68bfc27074d632653aed73cdb2b078
https://github.com/eternnoir/gncp/blob/c70df2d0cd68bfc27074d632653aed73cdb2b078/pool.go#L132-L144
149,230
eternnoir/gncp
pool.go
Put
func (p *GncpPool) Put(conn net.Conn) error { if p.isClosed() == true { return errPoolIsClose } if conn == nil { p.lock.Lock() p.totalConnNum = p.totalConnNum - 1 p.lock.Unlock() return errors.New("Cannot put nil to connection pool.") } select { case p.conns <- conn: return nil default: return con...
go
func (p *GncpPool) Put(conn net.Conn) error { if p.isClosed() == true { return errPoolIsClose } if conn == nil { p.lock.Lock() p.totalConnNum = p.totalConnNum - 1 p.lock.Unlock() return errors.New("Cannot put nil to connection pool.") } select { case p.conns <- conn: return nil default: return con...
[ "func", "(", "p", "*", "GncpPool", ")", "Put", "(", "conn", "net", ".", "Conn", ")", "error", "{", "if", "p", ".", "isClosed", "(", ")", "==", "true", "{", "return", "errPoolIsClose", "\n", "}", "\n", "if", "conn", "==", "nil", "{", "p", ".", "...
// Put can put connection back in connection pool. If connection has been closed, the conneciton will be close too.
[ "Put", "can", "put", "connection", "back", "in", "connection", "pool", ".", "If", "connection", "has", "been", "closed", "the", "conneciton", "will", "be", "close", "too", "." ]
c70df2d0cd68bfc27074d632653aed73cdb2b078
https://github.com/eternnoir/gncp/blob/c70df2d0cd68bfc27074d632653aed73cdb2b078/pool.go#L147-L164
149,231
eternnoir/gncp
pool.go
Remove
func (p *GncpPool) Remove(conn net.Conn) error { if p.isClosed() == true { return errPoolIsClose } p.lock.Lock() p.totalConnNum = p.totalConnNum - 1 p.lock.Unlock() switch conn.(type) { case *CpConn: return conn.(*CpConn).Destroy() default: return conn.Close() } return nil }
go
func (p *GncpPool) Remove(conn net.Conn) error { if p.isClosed() == true { return errPoolIsClose } p.lock.Lock() p.totalConnNum = p.totalConnNum - 1 p.lock.Unlock() switch conn.(type) { case *CpConn: return conn.(*CpConn).Destroy() default: return conn.Close() } return nil }
[ "func", "(", "p", "*", "GncpPool", ")", "Remove", "(", "conn", "net", ".", "Conn", ")", "error", "{", "if", "p", ".", "isClosed", "(", ")", "==", "true", "{", "return", "errPoolIsClose", "\n", "}", "\n\n", "p", ".", "lock", ".", "Lock", "(", ")",...
// RemoveConn let connection not belong connection pool.And it will close connection.
[ "RemoveConn", "let", "connection", "not", "belong", "connection", "pool", ".", "And", "it", "will", "close", "connection", "." ]
c70df2d0cd68bfc27074d632653aed73cdb2b078
https://github.com/eternnoir/gncp/blob/c70df2d0cd68bfc27074d632653aed73cdb2b078/pool.go#L174-L189
149,232
eternnoir/gncp
pool.go
createConn
func (p *GncpPool) createConn() (net.Conn, error) { p.lock.Lock() defer p.lock.Unlock() if p.totalConnNum >= p.maxConnNum { return nil, fmt.Errorf("Connot Create new connection. Now has %d.Max is %d", p.totalConnNum, p.maxConnNum) } conn, err := p.connCreator() if err != nil { return nil, fmt.Errorf("Cannot c...
go
func (p *GncpPool) createConn() (net.Conn, error) { p.lock.Lock() defer p.lock.Unlock() if p.totalConnNum >= p.maxConnNum { return nil, fmt.Errorf("Connot Create new connection. Now has %d.Max is %d", p.totalConnNum, p.maxConnNum) } conn, err := p.connCreator() if err != nil { return nil, fmt.Errorf("Cannot c...
[ "func", "(", "p", "*", "GncpPool", ")", "createConn", "(", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "p", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "lock", ".", "Unlock", "(", ")", "\n", "if", "p", ".", "totalCo...
// createConn will create one connection from connCreator. And increase connection counter.
[ "createConn", "will", "create", "one", "connection", "from", "connCreator", ".", "And", "increase", "connection", "counter", "." ]
c70df2d0cd68bfc27074d632653aed73cdb2b078
https://github.com/eternnoir/gncp/blob/c70df2d0cd68bfc27074d632653aed73cdb2b078/pool.go#L192-L204
149,233
eternnoir/gncp
connection.go
Destroy
func (conn *CpConn) Destroy() error { if conn.pool == nil { return errors.New("Connection not belong any connection pool.") } err := conn.pool.Remove(conn.Conn) if err != nil { return err } conn.pool = nil return nil }
go
func (conn *CpConn) Destroy() error { if conn.pool == nil { return errors.New("Connection not belong any connection pool.") } err := conn.pool.Remove(conn.Conn) if err != nil { return err } conn.pool = nil return nil }
[ "func", "(", "conn", "*", "CpConn", ")", "Destroy", "(", ")", "error", "{", "if", "conn", ".", "pool", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "err", ":=", "conn", ".", "pool", ".", "Remove", "("...
// Destroy will close connection and release connection from connection pool.
[ "Destroy", "will", "close", "connection", "and", "release", "connection", "from", "connection", "pool", "." ]
c70df2d0cd68bfc27074d632653aed73cdb2b078
https://github.com/eternnoir/gncp/blob/c70df2d0cd68bfc27074d632653aed73cdb2b078/connection.go#L14-L24
149,234
eternnoir/gncp
connection.go
Close
func (conn *CpConn) Close() error { if conn.pool == nil { return errors.New("Connection not belong any connection pool.") } return conn.pool.Put(conn.Conn) }
go
func (conn *CpConn) Close() error { if conn.pool == nil { return errors.New("Connection not belong any connection pool.") } return conn.pool.Put(conn.Conn) }
[ "func", "(", "conn", "*", "CpConn", ")", "Close", "(", ")", "error", "{", "if", "conn", ".", "pool", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "conn", ".", "pool", ".", "Put", "(", "conn"...
// Close will push connection back to connection pool. It will not close the real connection.
[ "Close", "will", "push", "connection", "back", "to", "connection", "pool", ".", "It", "will", "not", "close", "the", "real", "connection", "." ]
c70df2d0cd68bfc27074d632653aed73cdb2b078
https://github.com/eternnoir/gncp/blob/c70df2d0cd68bfc27074d632653aed73cdb2b078/connection.go#L27-L32
149,235
marcacohen/gcslock
mutex.go
ContextLock
func (m *mutex) ContextLock(ctx context.Context) error { q := url.Values{ "name": {m.object}, "uploadType": {"media"}, "ifGenerationMatch": {"0"}, } url := fmt.Sprintf("%s/b/%s/o?%s", storageLockURL, m.bucket, q.Encode()) // NOTE: ctx deadline/timeout and backoff are independent. The forme...
go
func (m *mutex) ContextLock(ctx context.Context) error { q := url.Values{ "name": {m.object}, "uploadType": {"media"}, "ifGenerationMatch": {"0"}, } url := fmt.Sprintf("%s/b/%s/o?%s", storageLockURL, m.bucket, q.Encode()) // NOTE: ctx deadline/timeout and backoff are independent. The forme...
[ "func", "(", "m", "*", "mutex", ")", "ContextLock", "(", "ctx", "context", ".", "Context", ")", "error", "{", "q", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "m", ".", "object", "}", ",", "\"", "\"", ":", "{", "\"", "\"", "}", ","...
// ContextLock waits indefinitely to acquire a mutex with timeout // governed by passed context.
[ "ContextLock", "waits", "indefinitely", "to", "acquire", "a", "mutex", "with", "timeout", "governed", "by", "passed", "context", "." ]
5782a95db7e207c634ebf85ca8fcd970b7a27ac5
https://github.com/marcacohen/gcslock/blob/5782a95db7e207c634ebf85ca8fcd970b7a27ac5/mutex.go#L65-L98
149,236
marcacohen/gcslock
mutex.go
ContextUnlock
func (m *mutex) ContextUnlock(ctx context.Context) error { url := fmt.Sprintf("%s/b/%s/o/%s?", storageUnlockURL, m.bucket, m.object) // NOTE: ctx deadline/timeout and backoff are independent. The former is // an aggregate timeout and the latter is a per loop iteration delay. backoff := 10 * time.Millisecond for { ...
go
func (m *mutex) ContextUnlock(ctx context.Context) error { url := fmt.Sprintf("%s/b/%s/o/%s?", storageUnlockURL, m.bucket, m.object) // NOTE: ctx deadline/timeout and backoff are independent. The former is // an aggregate timeout and the latter is a per loop iteration delay. backoff := 10 * time.Millisecond for { ...
[ "func", "(", "m", "*", "mutex", ")", "ContextUnlock", "(", "ctx", "context", ".", "Context", ")", "error", "{", "url", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "storageUnlockURL", ",", "m", ".", "bucket", ",", "m", ".", "object", ")", "\n...
// ContextUnlock waits indefinitely to release a mutex with timeout // governed by passed context.
[ "ContextUnlock", "waits", "indefinitely", "to", "release", "a", "mutex", "with", "timeout", "governed", "by", "passed", "context", "." ]
5782a95db7e207c634ebf85ca8fcd970b7a27ac5
https://github.com/marcacohen/gcslock/blob/5782a95db7e207c634ebf85ca8fcd970b7a27ac5/mutex.go#L107-L134
149,237
sdboyer/gps
cmd.go
run
func (c *monitoredCmd) run(ctx context.Context) error { // Check for cancellation before even starting if ctx.Err() != nil { return ctx.Err() } ticker := time.NewTicker(c.timeout) done := make(chan error, 1) defer ticker.Stop() err := c.cmd.Start() if err != nil { return err } go func() { done <- c.c...
go
func (c *monitoredCmd) run(ctx context.Context) error { // Check for cancellation before even starting if ctx.Err() != nil { return ctx.Err() } ticker := time.NewTicker(c.timeout) done := make(chan error, 1) defer ticker.Stop() err := c.cmd.Start() if err != nil { return err } go func() { done <- c.c...
[ "func", "(", "c", "*", "monitoredCmd", ")", "run", "(", "ctx", "context", ".", "Context", ")", "error", "{", "// Check for cancellation before even starting", "if", "ctx", ".", "Err", "(", ")", "!=", "nil", "{", "return", "ctx", ".", "Err", "(", ")", "\n...
// run will wait for the command to finish and return the error, if any. If the // command does not show any activity for more than the specified timeout the // process will be killed.
[ "run", "will", "wait", "for", "the", "command", "to", "finish", "and", "return", "the", "error", "if", "any", ".", "If", "the", "command", "does", "not", "show", "any", "activity", "for", "more", "than", "the", "specified", "timeout", "the", "process", "...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/cmd.go#L38-L76
149,238
sdboyer/gps
lockdiff.go
DiffProjects
func DiffProjects(lp1 LockedProject, lp2 LockedProject) *LockedProjectDiff { diff := LockedProjectDiff{Name: lp1.pi.ProjectRoot} s1 := lp1.pi.Source s2 := lp2.pi.Source if s1 != s2 { diff.Source = &StringDiff{Previous: s1, Current: s2} } r1, b1, v1 := VersionComponentStrings(lp1.Version()) r2, b2, v2 := Vers...
go
func DiffProjects(lp1 LockedProject, lp2 LockedProject) *LockedProjectDiff { diff := LockedProjectDiff{Name: lp1.pi.ProjectRoot} s1 := lp1.pi.Source s2 := lp2.pi.Source if s1 != s2 { diff.Source = &StringDiff{Previous: s1, Current: s2} } r1, b1, v1 := VersionComponentStrings(lp1.Version()) r2, b2, v2 := Vers...
[ "func", "DiffProjects", "(", "lp1", "LockedProject", ",", "lp2", "LockedProject", ")", "*", "LockedProjectDiff", "{", "diff", ":=", "LockedProjectDiff", "{", "Name", ":", "lp1", ".", "pi", ".", "ProjectRoot", "}", "\n\n", "s1", ":=", "lp1", ".", "pi", ".",...
// DiffProjects compares two projects and identifies the differences between them. // Returns nil if there are no differences
[ "DiffProjects", "compares", "two", "projects", "and", "identifies", "the", "differences", "between", "them", ".", "Returns", "nil", "if", "there", "are", "no", "differences" ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/lockdiff.go#L179-L253
149,239
sdboyer/gps
selection.go
popSelection
func (s *selection) popSelection() (atomWithPackages, bool) { var sel selected sel, s.projects = s.projects[len(s.projects)-1], s.projects[:len(s.projects)-1] return sel.a, sel.first }
go
func (s *selection) popSelection() (atomWithPackages, bool) { var sel selected sel, s.projects = s.projects[len(s.projects)-1], s.projects[:len(s.projects)-1] return sel.a, sel.first }
[ "func", "(", "s", "*", "selection", ")", "popSelection", "(", ")", "(", "atomWithPackages", ",", "bool", ")", "{", "var", "sel", "selected", "\n", "sel", ",", "s", ".", "projects", "=", "s", ".", "projects", "[", "len", "(", "s", ".", "projects", "...
// popSelection removes and returns the last atomWithPackages from the selection // stack, along with an indication of whether that element was the first from // that project - that is, if it represented an addition of both a project and // one or more packages to the overall selection.
[ "popSelection", "removes", "and", "returns", "the", "last", "atomWithPackages", "from", "the", "selection", "stack", "along", "with", "an", "indication", "of", "whether", "that", "element", "was", "the", "first", "from", "that", "project", "-", "that", "is", "...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/selection.go#L52-L56
149,240
sdboyer/gps
selection.go
getRequiredPackagesIn
func (s *selection) getRequiredPackagesIn(id ProjectIdentifier) map[string]int { // TODO(sdboyer) this is horribly inefficient to do on the fly; we need a method to // precompute it on pushing a new dep, and preferably with an immut // structure so that we can pop with zero cost. uniq := make(map[string]int) for _...
go
func (s *selection) getRequiredPackagesIn(id ProjectIdentifier) map[string]int { // TODO(sdboyer) this is horribly inefficient to do on the fly; we need a method to // precompute it on pushing a new dep, and preferably with an immut // structure so that we can pop with zero cost. uniq := make(map[string]int) for _...
[ "func", "(", "s", "*", "selection", ")", "getRequiredPackagesIn", "(", "id", "ProjectIdentifier", ")", "map", "[", "string", "]", "int", "{", "// TODO(sdboyer) this is horribly inefficient to do on the fly; we need a method to", "// precompute it on pushing a new dep, and prefera...
// Compute a list of the unique packages within the given ProjectIdentifier that // have dependers, and the number of dependers they have.
[ "Compute", "a", "list", "of", "the", "unique", "packages", "within", "the", "given", "ProjectIdentifier", "that", "have", "dependers", "and", "the", "number", "of", "dependers", "they", "have", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/selection.go#L78-L90
149,241
sdboyer/gps
selection.go
getSelectedPackagesIn
func (s *selection) getSelectedPackagesIn(id ProjectIdentifier) map[string]int { // TODO(sdboyer) this is horribly inefficient to do on the fly; we need a method to // precompute it on pushing a new dep, and preferably with an immut // structure so that we can pop with zero cost. uniq := make(map[string]int) for _...
go
func (s *selection) getSelectedPackagesIn(id ProjectIdentifier) map[string]int { // TODO(sdboyer) this is horribly inefficient to do on the fly; we need a method to // precompute it on pushing a new dep, and preferably with an immut // structure so that we can pop with zero cost. uniq := make(map[string]int) for _...
[ "func", "(", "s", "*", "selection", ")", "getSelectedPackagesIn", "(", "id", "ProjectIdentifier", ")", "map", "[", "string", "]", "int", "{", "// TODO(sdboyer) this is horribly inefficient to do on the fly; we need a method to", "// precompute it on pushing a new dep, and prefera...
// Compute a list of the unique packages within the given ProjectIdentifier that // are currently selected, and the number of times each package has been // independently selected.
[ "Compute", "a", "list", "of", "the", "unique", "packages", "within", "the", "given", "ProjectIdentifier", "that", "are", "currently", "selected", "and", "the", "number", "of", "times", "each", "package", "has", "been", "independently", "selected", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/selection.go#L95-L109
149,242
sdboyer/gps
selection.go
selected
func (s *selection) selected(id ProjectIdentifier) (atomWithPackages, bool) { for _, p := range s.projects { if p.a.a.id.ProjectRoot == id.ProjectRoot { return p.a, true } } return atomWithPackages{a: nilpa}, false }
go
func (s *selection) selected(id ProjectIdentifier) (atomWithPackages, bool) { for _, p := range s.projects { if p.a.a.id.ProjectRoot == id.ProjectRoot { return p.a, true } } return atomWithPackages{a: nilpa}, false }
[ "func", "(", "s", "*", "selection", ")", "selected", "(", "id", "ProjectIdentifier", ")", "(", "atomWithPackages", ",", "bool", ")", "{", "for", "_", ",", "p", ":=", "range", "s", ".", "projects", "{", "if", "p", ".", "a", ".", "a", ".", "id", "....
// selected checks to see if the given ProjectIdentifier has been selected, and // if so, returns the corresponding atomWithPackages. // // It walks the projects selection list from front to back and returns the first // match it finds, which means it will always and only return the base selection // of the project, wi...
[ "selected", "checks", "to", "see", "if", "the", "given", "ProjectIdentifier", "has", "been", "selected", "and", "if", "so", "returns", "the", "corresponding", "atomWithPackages", ".", "It", "walks", "the", "projects", "selection", "list", "from", "front", "to", ...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/selection.go#L140-L148
149,243
sdboyer/gps
source_manager.go
UseDefaultSignalHandling
func (sm *SourceMgr) UseDefaultSignalHandling() { sigch := make(chan os.Signal, 1) signal.Notify(sigch, os.Interrupt) sm.HandleSignals(sigch) }
go
func (sm *SourceMgr) UseDefaultSignalHandling() { sigch := make(chan os.Signal, 1) signal.Notify(sigch, os.Interrupt) sm.HandleSignals(sigch) }
[ "func", "(", "sm", "*", "SourceMgr", ")", "UseDefaultSignalHandling", "(", ")", "{", "sigch", ":=", "make", "(", "chan", "os", ".", "Signal", ",", "1", ")", "\n", "signal", ".", "Notify", "(", "sigch", ",", "os", ".", "Interrupt", ")", "\n", "sm", ...
// UseDefaultSignalHandling sets up typical os.Interrupt signal handling for a // SourceMgr.
[ "UseDefaultSignalHandling", "sets", "up", "typical", "os", ".", "Interrupt", "signal", "handling", "for", "a", "SourceMgr", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/source_manager.go#L165-L169
149,244
sdboyer/gps
source_manager.go
Release
func (sm *SourceMgr) Release() { // Set sm.releasing before entering the Once func to guarantee that no // _more_ method calls will stack up if/while waiting. atomic.CompareAndSwapInt32(&sm.releasing, 0, 1) // Whether 'releasing' is set or not, we don't want this function to return // until after the doRelease pr...
go
func (sm *SourceMgr) Release() { // Set sm.releasing before entering the Once func to guarantee that no // _more_ method calls will stack up if/while waiting. atomic.CompareAndSwapInt32(&sm.releasing, 0, 1) // Whether 'releasing' is set or not, we don't want this function to return // until after the doRelease pr...
[ "func", "(", "sm", "*", "SourceMgr", ")", "Release", "(", ")", "{", "// Set sm.releasing before entering the Once func to guarantee that no", "// _more_ method calls will stack up if/while waiting.", "atomic", ".", "CompareAndSwapInt32", "(", "&", "sm", ".", "releasing", ",",...
// Release lets go of any locks held by the SourceManager. Once called, it is no // longer safe to call methods against it; all method calls will immediately // result in errors.
[ "Release", "lets", "go", "of", "any", "locks", "held", "by", "the", "SourceManager", ".", "Once", "called", "it", "is", "no", "longer", "safe", "to", "call", "methods", "against", "it", ";", "all", "method", "calls", "will", "immediately", "result", "in", ...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/source_manager.go#L268-L278
149,245
sdboyer/gps
source_manager.go
ListPackages
func (sm *SourceMgr) ListPackages(id ProjectIdentifier, v Version) (pkgtree.PackageTree, error) { if atomic.CompareAndSwapInt32(&sm.releasing, 1, 1) { return pkgtree.PackageTree{}, smIsReleased{} } srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id) if err != nil { return pkgtree.PackageTree{}, er...
go
func (sm *SourceMgr) ListPackages(id ProjectIdentifier, v Version) (pkgtree.PackageTree, error) { if atomic.CompareAndSwapInt32(&sm.releasing, 1, 1) { return pkgtree.PackageTree{}, smIsReleased{} } srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id) if err != nil { return pkgtree.PackageTree{}, er...
[ "func", "(", "sm", "*", "SourceMgr", ")", "ListPackages", "(", "id", "ProjectIdentifier", ",", "v", "Version", ")", "(", "pkgtree", ".", "PackageTree", ",", "error", ")", "{", "if", "atomic", ".", "CompareAndSwapInt32", "(", "&", "sm", ".", "releasing", ...
// ListPackages parses the tree of the Go packages at and below the ProjectRoot // of the given ProjectIdentifier, at the given version.
[ "ListPackages", "parses", "the", "tree", "of", "the", "Go", "packages", "at", "and", "below", "the", "ProjectRoot", "of", "the", "given", "ProjectIdentifier", "at", "the", "given", "version", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/source_manager.go#L319-L330
149,246
sdboyer/gps
source_manager.go
RevisionPresentIn
func (sm *SourceMgr) RevisionPresentIn(id ProjectIdentifier, r Revision) (bool, error) { if atomic.CompareAndSwapInt32(&sm.releasing, 1, 1) { return false, smIsReleased{} } srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id) if err != nil { // TODO(sdboyer) More-er proper-er errors return false,...
go
func (sm *SourceMgr) RevisionPresentIn(id ProjectIdentifier, r Revision) (bool, error) { if atomic.CompareAndSwapInt32(&sm.releasing, 1, 1) { return false, smIsReleased{} } srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id) if err != nil { // TODO(sdboyer) More-er proper-er errors return false,...
[ "func", "(", "sm", "*", "SourceMgr", ")", "RevisionPresentIn", "(", "id", "ProjectIdentifier", ",", "r", "Revision", ")", "(", "bool", ",", "error", ")", "{", "if", "atomic", ".", "CompareAndSwapInt32", "(", "&", "sm", ".", "releasing", ",", "1", ",", ...
// RevisionPresentIn indicates whether the provided Revision is present in the given // repository.
[ "RevisionPresentIn", "indicates", "whether", "the", "provided", "Revision", "is", "present", "in", "the", "given", "repository", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/source_manager.go#L360-L372
149,247
sdboyer/gps
source_manager.go
SourceExists
func (sm *SourceMgr) SourceExists(id ProjectIdentifier) (bool, error) { if atomic.CompareAndSwapInt32(&sm.releasing, 1, 1) { return false, smIsReleased{} } srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id) if err != nil { return false, err } ctx := context.TODO() return srcg.existsInCache(ct...
go
func (sm *SourceMgr) SourceExists(id ProjectIdentifier) (bool, error) { if atomic.CompareAndSwapInt32(&sm.releasing, 1, 1) { return false, smIsReleased{} } srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id) if err != nil { return false, err } ctx := context.TODO() return srcg.existsInCache(ct...
[ "func", "(", "sm", "*", "SourceMgr", ")", "SourceExists", "(", "id", "ProjectIdentifier", ")", "(", "bool", ",", "error", ")", "{", "if", "atomic", ".", "CompareAndSwapInt32", "(", "&", "sm", ".", "releasing", ",", "1", ",", "1", ")", "{", "return", ...
// SourceExists checks if a repository exists, either upstream or in the cache, // for the provided ProjectIdentifier.
[ "SourceExists", "checks", "if", "a", "repository", "exists", "either", "upstream", "or", "in", "the", "cache", "for", "the", "provided", "ProjectIdentifier", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/source_manager.go#L376-L388
149,248
sdboyer/gps
source_manager.go
SyncSourceFor
func (sm *SourceMgr) SyncSourceFor(id ProjectIdentifier) error { if atomic.CompareAndSwapInt32(&sm.releasing, 1, 1) { return smIsReleased{} } srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id) if err != nil { return err } return srcg.syncLocal(context.TODO()) }
go
func (sm *SourceMgr) SyncSourceFor(id ProjectIdentifier) error { if atomic.CompareAndSwapInt32(&sm.releasing, 1, 1) { return smIsReleased{} } srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id) if err != nil { return err } return srcg.syncLocal(context.TODO()) }
[ "func", "(", "sm", "*", "SourceMgr", ")", "SyncSourceFor", "(", "id", "ProjectIdentifier", ")", "error", "{", "if", "atomic", ".", "CompareAndSwapInt32", "(", "&", "sm", ".", "releasing", ",", "1", ",", "1", ")", "{", "return", "smIsReleased", "{", "}", ...
// SyncSourceFor will ensure that all local caches and information about a // source are up to date with any network-acccesible information. // // The primary use case for this is prefetching.
[ "SyncSourceFor", "will", "ensure", "that", "all", "local", "caches", "and", "information", "about", "a", "source", "are", "up", "to", "date", "with", "any", "network", "-", "acccesible", "information", ".", "The", "primary", "use", "case", "for", "this", "is...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/source_manager.go#L394-L405
149,249
sdboyer/gps
source_manager.go
ExportProject
func (sm *SourceMgr) ExportProject(id ProjectIdentifier, v Version, to string) error { if atomic.CompareAndSwapInt32(&sm.releasing, 1, 1) { return smIsReleased{} } srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id) if err != nil { return err } return srcg.exportVersionTo(context.TODO(), v, to)...
go
func (sm *SourceMgr) ExportProject(id ProjectIdentifier, v Version, to string) error { if atomic.CompareAndSwapInt32(&sm.releasing, 1, 1) { return smIsReleased{} } srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id) if err != nil { return err } return srcg.exportVersionTo(context.TODO(), v, to)...
[ "func", "(", "sm", "*", "SourceMgr", ")", "ExportProject", "(", "id", "ProjectIdentifier", ",", "v", "Version", ",", "to", "string", ")", "error", "{", "if", "atomic", ".", "CompareAndSwapInt32", "(", "&", "sm", ".", "releasing", ",", "1", ",", "1", ")...
// ExportProject writes out the tree of the provided ProjectIdentifier's // ProjectRoot, at the provided version, to the provided directory.
[ "ExportProject", "writes", "out", "the", "tree", "of", "the", "provided", "ProjectIdentifier", "s", "ProjectRoot", "at", "the", "provided", "version", "to", "the", "provided", "directory", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/source_manager.go#L409-L420
149,250
sdboyer/gps
source_manager.go
wait
func (sup *supervisor) wait() { sup.cond.L.Lock() for len(sup.running) > 0 { sup.cond.Wait() } sup.cond.L.Unlock() }
go
func (sup *supervisor) wait() { sup.cond.L.Lock() for len(sup.running) > 0 { sup.cond.Wait() } sup.cond.L.Unlock() }
[ "func", "(", "sup", "*", "supervisor", ")", "wait", "(", ")", "{", "sup", ".", "cond", ".", "L", ".", "Lock", "(", ")", "\n", "for", "len", "(", "sup", ".", "running", ")", ">", "0", "{", "sup", ".", "cond", ".", "Wait", "(", ")", "\n", "}"...
// wait until all active calls have terminated. // // Assumes something else has already canceled the supervisor via its context.
[ "wait", "until", "all", "active", "calls", "have", "terminated", ".", "Assumes", "something", "else", "has", "already", "canceled", "the", "supervisor", "via", "its", "context", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/source_manager.go#L554-L560
149,251
sdboyer/gps
source.go
setUpSourceGateway
func (sc *sourceCoordinator) setUpSourceGateway(ctx context.Context, normalizedName string, rc srcReturnChans) { sc.psrcmut.Lock() if chans, has := sc.protoSrcs[normalizedName]; has { // Another goroutine is already working on this normalizedName. Fold // in with that work by attaching our return channels to the ...
go
func (sc *sourceCoordinator) setUpSourceGateway(ctx context.Context, normalizedName string, rc srcReturnChans) { sc.psrcmut.Lock() if chans, has := sc.protoSrcs[normalizedName]; has { // Another goroutine is already working on this normalizedName. Fold // in with that work by attaching our return channels to the ...
[ "func", "(", "sc", "*", "sourceCoordinator", ")", "setUpSourceGateway", "(", "ctx", "context", ".", "Context", ",", "normalizedName", "string", ",", "rc", "srcReturnChans", ")", "{", "sc", ".", "psrcmut", ".", "Lock", "(", ")", "\n", "if", "chans", ",", ...
// Not intended to be called externally - call getSourceGatewayFor instead.
[ "Not", "intended", "to", "be", "called", "externally", "-", "call", "getSourceGatewayFor", "instead", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/source.go#L93-L182
149,252
sdboyer/gps
source.go
listPackages
func (sg *sourceGateway) listPackages(ctx context.Context, pr ProjectRoot, v Version) (pkgtree.PackageTree, error) { sg.mu.Lock() defer sg.mu.Unlock() r, err := sg.convertToRevision(ctx, v) if err != nil { return pkgtree.PackageTree{}, err } ptree, has := sg.cache.getPackageTree(r) if has { return ptree, n...
go
func (sg *sourceGateway) listPackages(ctx context.Context, pr ProjectRoot, v Version) (pkgtree.PackageTree, error) { sg.mu.Lock() defer sg.mu.Unlock() r, err := sg.convertToRevision(ctx, v) if err != nil { return pkgtree.PackageTree{}, err } ptree, has := sg.cache.getPackageTree(r) if has { return ptree, n...
[ "func", "(", "sg", "*", "sourceGateway", ")", "listPackages", "(", "ctx", "context", ".", "Context", ",", "pr", "ProjectRoot", ",", "v", "Version", ")", "(", "pkgtree", ".", "PackageTree", ",", "error", ")", "{", "sg", ".", "mu", ".", "Lock", "(", ")...
// FIXME ProjectRoot input either needs to parameterize the cache, or be // incorporated on the fly on egress...?
[ "FIXME", "ProjectRoot", "input", "either", "needs", "to", "parameterize", "the", "cache", "or", "be", "incorporated", "on", "the", "fly", "on", "egress", "...", "?" ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/source.go#L293-L323
149,253
sdboyer/gps
rootdata.go
externalImportList
func (rd rootdata) externalImportList() []string { rm, _ := rd.rpt.ToReachMap(true, true, false, rd.ig) all := rm.Flatten(false) reach := make([]string, 0, len(all)) for _, r := range all { if !internal.IsStdLib(r) { reach = append(reach, r) } } // If there are any requires, slide them into the reach list...
go
func (rd rootdata) externalImportList() []string { rm, _ := rd.rpt.ToReachMap(true, true, false, rd.ig) all := rm.Flatten(false) reach := make([]string, 0, len(all)) for _, r := range all { if !internal.IsStdLib(r) { reach = append(reach, r) } } // If there are any requires, slide them into the reach list...
[ "func", "(", "rd", "rootdata", ")", "externalImportList", "(", ")", "[", "]", "string", "{", "rm", ",", "_", ":=", "rd", ".", "rpt", ".", "ToReachMap", "(", "true", ",", "true", ",", "false", ",", "rd", ".", "ig", ")", "\n", "all", ":=", "rm", ...
// externalImportList returns a list of the unique imports from the root data. // Ignores and requires are taken into consideration, stdlib is excluded, and // errors within the local set of package are not backpropagated.
[ "externalImportList", "returns", "a", "list", "of", "the", "unique", "imports", "from", "the", "root", "data", ".", "Ignores", "and", "requires", "are", "taken", "into", "consideration", "stdlib", "is", "excluded", "and", "errors", "within", "the", "local", "s...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/rootdata.go#L53-L83
149,254
sdboyer/gps
rootdata.go
rootAtom
func (rd rootdata) rootAtom() atomWithPackages { a := atom{ id: ProjectIdentifier{ ProjectRoot: ProjectRoot(rd.rpt.ImportRoot), }, // This is a hack so that the root project doesn't have a nil version. // It's sort of OK because the root never makes it out into the results. // We may need a more elegant s...
go
func (rd rootdata) rootAtom() atomWithPackages { a := atom{ id: ProjectIdentifier{ ProjectRoot: ProjectRoot(rd.rpt.ImportRoot), }, // This is a hack so that the root project doesn't have a nil version. // It's sort of OK because the root never makes it out into the results. // We may need a more elegant s...
[ "func", "(", "rd", "rootdata", ")", "rootAtom", "(", ")", "atomWithPackages", "{", "a", ":=", "atom", "{", "id", ":", "ProjectIdentifier", "{", "ProjectRoot", ":", "ProjectRoot", "(", "rd", ".", "rpt", ".", "ImportRoot", ")", ",", "}", ",", "// This is a...
// rootAtom creates an atomWithPackages that represents the root project.
[ "rootAtom", "creates", "an", "atomWithPackages", "that", "represents", "the", "root", "project", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/rootdata.go#L184-L208
149,255
sdboyer/gps
version.go
Matches
func (r Revision) Matches(v Version) bool { switch tv := v.(type) { case versionTypeUnion: return tv.Matches(r) case Revision: return r == tv case versionPair: return r == tv.r } return false }
go
func (r Revision) Matches(v Version) bool { switch tv := v.(type) { case versionTypeUnion: return tv.Matches(r) case Revision: return r == tv case versionPair: return r == tv.r } return false }
[ "func", "(", "r", "Revision", ")", "Matches", "(", "v", "Version", ")", "bool", "{", "switch", "tv", ":=", "v", ".", "(", "type", ")", "{", "case", "versionTypeUnion", ":", "return", "tv", ".", "Matches", "(", "r", ")", "\n", "case", "Revision", ":...
// Matches is the Revision acting as a constraint; it checks to see if the provided // version is the same Revision as itself.
[ "Matches", "is", "the", "Revision", "acting", "as", "a", "constraint", ";", "it", "checks", "to", "see", "if", "the", "provided", "version", "is", "the", "same", "Revision", "as", "itself", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/version.go#L129-L140
149,256
sdboyer/gps
version.go
MatchesAny
func (r Revision) MatchesAny(c Constraint) bool { switch tc := c.(type) { case anyConstraint: return true case noneConstraint: return false case versionTypeUnion: return tc.MatchesAny(r) case Revision: return r == tc case versionPair: return r == tc.r } return false }
go
func (r Revision) MatchesAny(c Constraint) bool { switch tc := c.(type) { case anyConstraint: return true case noneConstraint: return false case versionTypeUnion: return tc.MatchesAny(r) case Revision: return r == tc case versionPair: return r == tc.r } return false }
[ "func", "(", "r", "Revision", ")", "MatchesAny", "(", "c", "Constraint", ")", "bool", "{", "switch", "tc", ":=", "c", ".", "(", "type", ")", "{", "case", "anyConstraint", ":", "return", "true", "\n", "case", "noneConstraint", ":", "return", "false", "\...
// MatchesAny is the Revision acting as a constraint; it checks to see if the provided // version is the same Revision as itself.
[ "MatchesAny", "is", "the", "Revision", "acting", "as", "a", "constraint", ";", "it", "checks", "to", "see", "if", "the", "provided", "version", "is", "the", "same", "Revision", "as", "itself", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/version.go#L144-L159
149,257
sdboyer/gps
version.go
Intersect
func (r Revision) Intersect(c Constraint) Constraint { switch tc := c.(type) { case anyConstraint: return r case noneConstraint: return none case versionTypeUnion: return tc.Intersect(r) case Revision: if r == tc { return r } case versionPair: if r == tc.r { return r } } return none }
go
func (r Revision) Intersect(c Constraint) Constraint { switch tc := c.(type) { case anyConstraint: return r case noneConstraint: return none case versionTypeUnion: return tc.Intersect(r) case Revision: if r == tc { return r } case versionPair: if r == tc.r { return r } } return none }
[ "func", "(", "r", "Revision", ")", "Intersect", "(", "c", "Constraint", ")", "Constraint", "{", "switch", "tc", ":=", "c", ".", "(", "type", ")", "{", "case", "anyConstraint", ":", "return", "r", "\n", "case", "noneConstraint", ":", "return", "none", "...
// Intersect computes the intersection of the Constraint with the provided // Constraint. For Revisions, this can only be another, exactly equal // Revision, or a PairedVersion whose underlying Revision is exactly equal.
[ "Intersect", "computes", "the", "intersection", "of", "the", "Constraint", "with", "the", "provided", "Constraint", ".", "For", "Revisions", "this", "can", "only", "be", "another", "exactly", "equal", "Revision", "or", "a", "PairedVersion", "whose", "underlying", ...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/version.go#L164-L183
149,258
sdboyer/gps
version.go
VersionComponentStrings
func VersionComponentStrings(v Version) (revision string, branch string, version string) { switch tv := v.(type) { case UnpairedVersion: case Revision: revision = tv.String() case PairedVersion: revision = tv.Underlying().String() } switch v.Type() { case IsBranch: branch = v.String() case IsSemver, IsVe...
go
func VersionComponentStrings(v Version) (revision string, branch string, version string) { switch tv := v.(type) { case UnpairedVersion: case Revision: revision = tv.String() case PairedVersion: revision = tv.Underlying().String() } switch v.Type() { case IsBranch: branch = v.String() case IsSemver, IsVe...
[ "func", "VersionComponentStrings", "(", "v", "Version", ")", "(", "revision", "string", ",", "branch", "string", ",", "version", "string", ")", "{", "switch", "tv", ":=", "v", ".", "(", "type", ")", "{", "case", "UnpairedVersion", ":", "case", "Revision", ...
// VersionComponentStrings decomposes a Version into the underlying number, branch and revision
[ "VersionComponentStrings", "decomposes", "a", "Version", "into", "the", "underlying", "number", "branch", "and", "revision" ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/version.go#L759-L776
149,259
sdboyer/gps
vcs_repo.go
defendAgainstSubmodules
func (r *gitRepo) defendAgainstSubmodules(ctx context.Context) error { // First, update them to whatever they should be, if there should happen to be any. out, err := runFromRepoDir(ctx, r, "git", "submodule", "update", "--init", "--recursive") if err != nil { return newVcsLocalErrorOr("unexpected error while defe...
go
func (r *gitRepo) defendAgainstSubmodules(ctx context.Context) error { // First, update them to whatever they should be, if there should happen to be any. out, err := runFromRepoDir(ctx, r, "git", "submodule", "update", "--init", "--recursive") if err != nil { return newVcsLocalErrorOr("unexpected error while defe...
[ "func", "(", "r", "*", "gitRepo", ")", "defendAgainstSubmodules", "(", "ctx", "context", ".", "Context", ")", "error", "{", "// First, update them to whatever they should be, if there should happen to be any.", "out", ",", "err", ":=", "runFromRepoDir", "(", "ctx", ",",...
// defendAgainstSubmodules tries to keep repo state sane in the event of // submodules. Or nested submodules. What a great idea, submodules.
[ "defendAgainstSubmodules", "tries", "to", "keep", "repo", "state", "sane", "in", "the", "event", "of", "submodules", ".", "Or", "nested", "submodules", ".", "What", "a", "great", "idea", "submodules", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/vcs_repo.go#L73-L94
149,260
sdboyer/gps
remove_go16.go
removeAll
func removeAll(path string) error { // Only need special handling for windows if runtime.GOOS != "windows" { return os.RemoveAll(path) } // Simple case: if Remove works, we're done. err := os.Remove(path) if err == nil || os.IsNotExist(err) { return nil } // make sure all files are writable so we can dele...
go
func removeAll(path string) error { // Only need special handling for windows if runtime.GOOS != "windows" { return os.RemoveAll(path) } // Simple case: if Remove works, we're done. err := os.Remove(path) if err == nil || os.IsNotExist(err) { return nil } // make sure all files are writable so we can dele...
[ "func", "removeAll", "(", "path", "string", ")", "error", "{", "// Only need special handling for windows", "if", "runtime", ".", "GOOS", "!=", "\"", "\"", "{", "return", "os", ".", "RemoveAll", "(", "path", ")", "\n", "}", "\n\n", "// Simple case: if Remove wor...
// removeAll removes path and any children it contains. It deals correctly with // removal on Windows where, prior to Go 1.7, there were issues when files were // set to read-only.
[ "removeAll", "removes", "path", "and", "any", "children", "it", "contains", ".", "It", "deals", "correctly", "with", "removal", "on", "Windows", "where", "prior", "to", "Go", "1", ".", "7", "there", "were", "issues", "when", "files", "were", "set", "to", ...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/remove_go16.go#L14-L44
149,261
sdboyer/gps
bridge.go
ListPackages
func (b *bridge) ListPackages(id ProjectIdentifier, v Version) (pkgtree.PackageTree, error) { if b.s.rd.isRoot(id.ProjectRoot) { return b.s.rd.rpt, nil } b.s.mtr.push("b-list-pkgs") pt, err := b.sm.ListPackages(id, v) b.s.mtr.pop() return pt, err }
go
func (b *bridge) ListPackages(id ProjectIdentifier, v Version) (pkgtree.PackageTree, error) { if b.s.rd.isRoot(id.ProjectRoot) { return b.s.rd.rpt, nil } b.s.mtr.push("b-list-pkgs") pt, err := b.sm.ListPackages(id, v) b.s.mtr.pop() return pt, err }
[ "func", "(", "b", "*", "bridge", ")", "ListPackages", "(", "id", "ProjectIdentifier", ",", "v", "Version", ")", "(", "pkgtree", ".", "PackageTree", ",", "error", ")", "{", "if", "b", ".", "s", ".", "rd", ".", "isRoot", "(", "id", ".", "ProjectRoot", ...
// listPackages lists all the packages contained within the given project at a // particular version. // // The root project is handled separately, as the source manager isn't // responsible for that code.
[ "listPackages", "lists", "all", "the", "packages", "contained", "within", "the", "given", "project", "at", "a", "particular", "version", ".", "The", "root", "project", "is", "handled", "separately", "as", "the", "source", "manager", "isn", "t", "responsible", ...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/bridge.go#L150-L159
149,262
sdboyer/gps
bridge.go
verifyRootDir
func (b *bridge) verifyRootDir(path string) error { if fi, err := os.Stat(path); err != nil { return badOptsFailure(fmt.Sprintf("could not read project root (%s): %s", path, err)) } else if !fi.IsDir() { return badOptsFailure(fmt.Sprintf("project root (%s) is a file, not a directory", path)) } return nil }
go
func (b *bridge) verifyRootDir(path string) error { if fi, err := os.Stat(path); err != nil { return badOptsFailure(fmt.Sprintf("could not read project root (%s): %s", path, err)) } else if !fi.IsDir() { return badOptsFailure(fmt.Sprintf("project root (%s) is a file, not a directory", path)) } return nil }
[ "func", "(", "b", "*", "bridge", ")", "verifyRootDir", "(", "path", "string", ")", "error", "{", "if", "fi", ",", "err", ":=", "os", ".", "Stat", "(", "path", ")", ";", "err", "!=", "nil", "{", "return", "badOptsFailure", "(", "fmt", ".", "Sprintf"...
// verifyRoot ensures that the provided path to the project root is in good // working condition. This check is made only once, at the beginning of a solve // run.
[ "verifyRoot", "ensures", "that", "the", "provided", "path", "to", "the", "project", "root", "is", "in", "good", "working", "condition", ".", "This", "check", "is", "made", "only", "once", "at", "the", "beginning", "of", "a", "solve", "run", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/bridge.go#L168-L176
149,263
sdboyer/gps
lock.go
Eq
func (lp LockedProject) Eq(lp2 LockedProject) bool { if lp.pi != lp2.pi { return false } if lp.r != lp2.r { return false } if len(lp.pkgs) != len(lp2.pkgs) { return false } for k, v := range lp.pkgs { if lp2.pkgs[k] != v { return false } } v1n := lp.v == nil v2n := lp2.v == nil if v1n != v2...
go
func (lp LockedProject) Eq(lp2 LockedProject) bool { if lp.pi != lp2.pi { return false } if lp.r != lp2.r { return false } if len(lp.pkgs) != len(lp2.pkgs) { return false } for k, v := range lp.pkgs { if lp2.pkgs[k] != v { return false } } v1n := lp.v == nil v2n := lp2.v == nil if v1n != v2...
[ "func", "(", "lp", "LockedProject", ")", "Eq", "(", "lp2", "LockedProject", ")", "bool", "{", "if", "lp", ".", "pi", "!=", "lp2", ".", "pi", "{", "return", "false", "\n", "}", "\n\n", "if", "lp", ".", "r", "!=", "lp2", ".", "r", "{", "return", ...
// Eq checks if two LockedProject instances are equal.
[ "Eq", "checks", "if", "two", "LockedProject", "instances", "are", "equal", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/lock.go#L151-L182
149,264
sdboyer/gps
lock.go
prepLock
func prepLock(l Lock) safeLock { pl := l.Projects() rl := safeLock{ h: l.InputHash(), p: make([]LockedProject, len(pl)), } copy(rl.p, pl) return rl }
go
func prepLock(l Lock) safeLock { pl := l.Projects() rl := safeLock{ h: l.InputHash(), p: make([]LockedProject, len(pl)), } copy(rl.p, pl) return rl }
[ "func", "prepLock", "(", "l", "Lock", ")", "safeLock", "{", "pl", ":=", "l", ".", "Projects", "(", ")", "\n\n", "rl", ":=", "safeLock", "{", "h", ":", "l", ".", "InputHash", "(", ")", ",", "p", ":", "make", "(", "[", "]", "LockedProject", ",", ...
// prepLock ensures a lock is prepared and safe for use by the solver. This is // mostly about defensively ensuring that no outside routine can modify the lock // while the solver is in-flight. // // This is achieved by copying the lock's data into a new safeLock.
[ "prepLock", "ensures", "a", "lock", "is", "prepared", "and", "safe", "for", "use", "by", "the", "solver", ".", "This", "is", "mostly", "about", "defensively", "ensuring", "that", "no", "outside", "routine", "can", "modify", "the", "lock", "while", "the", "...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/lock.go#L215-L225
149,265
sdboyer/gps
pkgtree/reachmap.go
FlattenAll
func (rm ReachMap) FlattenAll(stdlib bool) []string { return rm.flatten(func(pkg string) bool { return true }, stdlib) }
go
func (rm ReachMap) FlattenAll(stdlib bool) []string { return rm.flatten(func(pkg string) bool { return true }, stdlib) }
[ "func", "(", "rm", "ReachMap", ")", "FlattenAll", "(", "stdlib", "bool", ")", "[", "]", "string", "{", "return", "rm", ".", "flatten", "(", "func", "(", "pkg", "string", ")", "bool", "{", "return", "true", "}", ",", "stdlib", ")", "\n", "}" ]
// FlattenAll flattens a reachmap into a sorted, deduplicated list of all the // external imports named by its contained packages. // // If stdlib is false, then stdlib imports are excluded from the result.
[ "FlattenAll", "flattens", "a", "reachmap", "into", "a", "sorted", "deduplicated", "list", "of", "all", "the", "external", "imports", "named", "by", "its", "contained", "packages", ".", "If", "stdlib", "is", "false", "then", "stdlib", "imports", "are", "exclude...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/pkgtree/reachmap.go#L23-L25
149,266
sdboyer/gps
pkgtree/pkgtree.go
fillPackage
func fillPackage(p *build.Package) error { var buildPrefix = "// +build " var buildFieldSplit = func(r rune) bool { return unicode.IsSpace(r) || r == ',' } gofiles, err := filepath.Glob(filepath.Join(p.Dir, "*.go")) if err != nil { return err } if len(gofiles) == 0 { return &build.NoGoError{Dir: p.Dir} ...
go
func fillPackage(p *build.Package) error { var buildPrefix = "// +build " var buildFieldSplit = func(r rune) bool { return unicode.IsSpace(r) || r == ',' } gofiles, err := filepath.Glob(filepath.Join(p.Dir, "*.go")) if err != nil { return err } if len(gofiles) == 0 { return &build.NoGoError{Dir: p.Dir} ...
[ "func", "fillPackage", "(", "p", "*", "build", ".", "Package", ")", "error", "{", "var", "buildPrefix", "=", "\"", "\"", "\n", "var", "buildFieldSplit", "=", "func", "(", "r", "rune", ")", "bool", "{", "return", "unicode", ".", "IsSpace", "(", "r", "...
// fillPackage full of info. Assumes p.Dir is set at a minimum
[ "fillPackage", "full", "of", "info", ".", "Assumes", "p", ".", "Dir", "is", "set", "at", "a", "minimum" ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/pkgtree/pkgtree.go#L180-L268
149,267
sdboyer/gps
pkgtree/pkgtree.go
Error
func (e *ProblemImportError) Error() string { switch len(e.Cause) { case 0: return fmt.Sprintf("%q contains malformed code: %s", e.ImportPath, e.Err.Error()) case 1: return fmt.Sprintf("%q imports %q, which contains malformed code: %s", e.ImportPath, e.Cause[0], e.Err.Error()) default: return fmt.Sprintf("%q ...
go
func (e *ProblemImportError) Error() string { switch len(e.Cause) { case 0: return fmt.Sprintf("%q contains malformed code: %s", e.ImportPath, e.Err.Error()) case 1: return fmt.Sprintf("%q imports %q, which contains malformed code: %s", e.ImportPath, e.Cause[0], e.Err.Error()) default: return fmt.Sprintf("%q ...
[ "func", "(", "e", "*", "ProblemImportError", ")", "Error", "(", ")", "string", "{", "switch", "len", "(", "e", ".", "Cause", ")", "{", "case", "0", ":", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "ImportPath", ",", "e", ".",...
// Error formats the ProblemImportError as a string, reflecting whether the // error represents a direct or transitive problem.
[ "Error", "formats", "the", "ProblemImportError", "as", "a", "string", "reflecting", "whether", "the", "error", "represents", "a", "direct", "or", "transitive", "problem", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/pkgtree/pkgtree.go#L322-L331
149,268
sdboyer/gps
pkgtree/pkgtree.go
Copy
func (t PackageTree) Copy() PackageTree { t2 := PackageTree{ ImportRoot: t.ImportRoot, Packages: map[string]PackageOrErr{}, } for path, poe := range t.Packages { poe2 := PackageOrErr{ Err: poe.Err, P: poe.P, } if len(poe.P.Imports) > 0 { poe2.P.Imports = make([]string, len(poe.P.Imports)) ...
go
func (t PackageTree) Copy() PackageTree { t2 := PackageTree{ ImportRoot: t.ImportRoot, Packages: map[string]PackageOrErr{}, } for path, poe := range t.Packages { poe2 := PackageOrErr{ Err: poe.Err, P: poe.P, } if len(poe.P.Imports) > 0 { poe2.P.Imports = make([]string, len(poe.P.Imports)) ...
[ "func", "(", "t", "PackageTree", ")", "Copy", "(", ")", "PackageTree", "{", "t2", ":=", "PackageTree", "{", "ImportRoot", ":", "t", ".", "ImportRoot", ",", "Packages", ":", "map", "[", "string", "]", "PackageOrErr", "{", "}", ",", "}", "\n\n", "for", ...
// Copy copies the PackageTree. // // This is really only useful as a defensive measure to prevent external state // mutations.
[ "Copy", "copies", "the", "PackageTree", ".", "This", "is", "really", "only", "useful", "as", "a", "defensive", "measure", "to", "prevent", "external", "state", "mutations", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/pkgtree/pkgtree.go#L483-L507
149,269
sdboyer/gps
pkgtree/pkgtree.go
dedupeStrings
func dedupeStrings(s1, s2 []string) (r []string) { dedupe := make(map[string]bool) if len(s1) > 0 && len(s2) > 0 { for _, i := range s1 { dedupe[i] = true } for _, i := range s2 { dedupe[i] = true } for i := range dedupe { r = append(r, i) } // And then re-sort them sort.Strings(r) } else ...
go
func dedupeStrings(s1, s2 []string) (r []string) { dedupe := make(map[string]bool) if len(s1) > 0 && len(s2) > 0 { for _, i := range s1 { dedupe[i] = true } for _, i := range s2 { dedupe[i] = true } for i := range dedupe { r = append(r, i) } // And then re-sort them sort.Strings(r) } else ...
[ "func", "dedupeStrings", "(", "s1", ",", "s2", "[", "]", "string", ")", "(", "r", "[", "]", "string", ")", "{", "dedupe", ":=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n\n", "if", "len", "(", "s1", ")", ">", "0", "&&", "len", "...
// helper func to merge, dedupe, and sort strings
[ "helper", "func", "to", "merge", "dedupe", "and", "sort", "strings" ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/pkgtree/pkgtree.go#L848-L871
149,270
sdboyer/gps
trace.go
traceStartBacktrack
func (s *solver) traceStartBacktrack(bmi bimodalIdentifier, err error, pkgonly bool) { if s.tl == nil { return } var msg string if pkgonly { msg = fmt.Sprintf("%s%s could not add %v pkgs to %s; begin backtrack", innerIndent, backChar, len(bmi.pl), bmi.id.errString()) } else { msg = fmt.Sprintf("%s%s no more...
go
func (s *solver) traceStartBacktrack(bmi bimodalIdentifier, err error, pkgonly bool) { if s.tl == nil { return } var msg string if pkgonly { msg = fmt.Sprintf("%s%s could not add %v pkgs to %s; begin backtrack", innerIndent, backChar, len(bmi.pl), bmi.id.errString()) } else { msg = fmt.Sprintf("%s%s no more...
[ "func", "(", "s", "*", "solver", ")", "traceStartBacktrack", "(", "bmi", "bimodalIdentifier", ",", "err", "error", ",", "pkgonly", "bool", ")", "{", "if", "s", ".", "tl", "==", "nil", "{", "return", "\n", "}", "\n\n", "var", "msg", "string", "\n", "i...
// traceStartBacktrack is called with the bmi that first failed, thus initiating // backtracking
[ "traceStartBacktrack", "is", "called", "with", "the", "bmi", "that", "first", "failed", "thus", "initiating", "backtracking" ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/trace.go#L57-L71
149,271
sdboyer/gps
trace.go
traceFinish
func (s *solver) traceFinish(sol solution, err error) { if s.tl == nil { return } if err == nil { var pkgcount int for _, lp := range sol.Projects() { pkgcount += len(lp.pkgs) } s.tl.Printf("%s%s found solution with %v packages from %v projects", innerIndent, successChar, pkgcount, len(sol.Projects()))...
go
func (s *solver) traceFinish(sol solution, err error) { if s.tl == nil { return } if err == nil { var pkgcount int for _, lp := range sol.Projects() { pkgcount += len(lp.pkgs) } s.tl.Printf("%s%s found solution with %v packages from %v projects", innerIndent, successChar, pkgcount, len(sol.Projects()))...
[ "func", "(", "s", "*", "solver", ")", "traceFinish", "(", "sol", "solution", ",", "err", "error", ")", "{", "if", "s", ".", "tl", "==", "nil", "{", "return", "\n", "}", "\n\n", "if", "err", "==", "nil", "{", "var", "pkgcount", "int", "\n", "for",...
// Called just once after solving has finished, whether success or not
[ "Called", "just", "once", "after", "solving", "has", "finished", "whether", "success", "or", "not" ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/trace.go#L92-L106
149,272
sdboyer/gps
trace.go
traceSelectRoot
func (s *solver) traceSelectRoot(ptree pkgtree.PackageTree, cdeps []completeDep) { if s.tl == nil { return } // This duplicates work a bit, but we're in trace mode and it's only once, // so who cares rm, _ := ptree.ToReachMap(true, true, false, s.rd.ig) s.tl.Printf("Root project is %q", s.rd.rpt.ImportRoot) ...
go
func (s *solver) traceSelectRoot(ptree pkgtree.PackageTree, cdeps []completeDep) { if s.tl == nil { return } // This duplicates work a bit, but we're in trace mode and it's only once, // so who cares rm, _ := ptree.ToReachMap(true, true, false, s.rd.ig) s.tl.Printf("Root project is %q", s.rd.rpt.ImportRoot) ...
[ "func", "(", "s", "*", "solver", ")", "traceSelectRoot", "(", "ptree", "pkgtree", ".", "PackageTree", ",", "cdeps", "[", "]", "completeDep", ")", "{", "if", "s", ".", "tl", "==", "nil", "{", "return", "\n", "}", "\n\n", "// This duplicates work a bit, but ...
// traceSelectRoot is called just once, when the root project is selected
[ "traceSelectRoot", "is", "called", "just", "once", "when", "the", "root", "project", "is", "selected" ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/trace.go#L109-L129
149,273
sdboyer/gps
trace.go
traceSelect
func (s *solver) traceSelect(awp atomWithPackages, pkgonly bool) { if s.tl == nil { return } var msg string if pkgonly { msg = fmt.Sprintf("%s%s include %v more pkgs from %s", innerIndent, successChar, len(awp.pl), a2vs(awp.a)) } else { msg = fmt.Sprintf("%s select %s w/%v pkgs", successChar, a2vs(awp.a), l...
go
func (s *solver) traceSelect(awp atomWithPackages, pkgonly bool) { if s.tl == nil { return } var msg string if pkgonly { msg = fmt.Sprintf("%s%s include %v more pkgs from %s", innerIndent, successChar, len(awp.pl), a2vs(awp.a)) } else { msg = fmt.Sprintf("%s select %s w/%v pkgs", successChar, a2vs(awp.a), l...
[ "func", "(", "s", "*", "solver", ")", "traceSelect", "(", "awp", "atomWithPackages", ",", "pkgonly", "bool", ")", "{", "if", "s", ".", "tl", "==", "nil", "{", "return", "\n", "}", "\n\n", "var", "msg", "string", "\n", "if", "pkgonly", "{", "msg", "...
// traceSelect is called when an atom is successfully selected
[ "traceSelect", "is", "called", "when", "an", "atom", "is", "successfully", "selected" ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/trace.go#L132-L146
149,274
sdboyer/gps
satisfy.go
check
func (s *solver) check(a atomWithPackages, pkgonly bool) error { s.mtr.push("satisfy") pa := a.a if nilpa == pa { // This shouldn't be able to happen, but if it does, it unequivocally // indicates a logical bug somewhere, so blowing up is preferable panic("canary - checking version of empty ProjectAtom") } ...
go
func (s *solver) check(a atomWithPackages, pkgonly bool) error { s.mtr.push("satisfy") pa := a.a if nilpa == pa { // This shouldn't be able to happen, but if it does, it unequivocally // indicates a logical bug somewhere, so blowing up is preferable panic("canary - checking version of empty ProjectAtom") } ...
[ "func", "(", "s", "*", "solver", ")", "check", "(", "a", "atomWithPackages", ",", "pkgonly", "bool", ")", "error", "{", "s", ".", "mtr", ".", "push", "(", "\"", "\"", ")", "\n", "pa", ":=", "a", ".", "a", "\n", "if", "nilpa", "==", "pa", "{", ...
// check performs constraint checks on the provided atom. The set of checks // differ slightly depending on whether the atom is pkgonly, or if it's the // entire project being added for the first time. // // The goal is to determine whether selecting the atom would result in a state // where all the solver requirements...
[ "check", "performs", "constraint", "checks", "on", "the", "provided", "atom", ".", "The", "set", "of", "checks", "differ", "slightly", "depending", "on", "whether", "the", "atom", "is", "pkgonly", "or", "if", "it", "s", "the", "entire", "project", "being", ...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/satisfy.go#L9-L77
149,275
sdboyer/gps
satisfy.go
checkAtomAllowable
func (s *solver) checkAtomAllowable(pa atom) error { constraint := s.sel.getConstraint(pa.id) if s.vUnify.matches(pa.id, constraint, pa.v) { return nil } // TODO(sdboyer) collect constraint failure reason (wait...aren't we, below?) deps := s.sel.getDependenciesOn(pa.id) var failparent []dependency for _, dep ...
go
func (s *solver) checkAtomAllowable(pa atom) error { constraint := s.sel.getConstraint(pa.id) if s.vUnify.matches(pa.id, constraint, pa.v) { return nil } // TODO(sdboyer) collect constraint failure reason (wait...aren't we, below?) deps := s.sel.getDependenciesOn(pa.id) var failparent []dependency for _, dep ...
[ "func", "(", "s", "*", "solver", ")", "checkAtomAllowable", "(", "pa", "atom", ")", "error", "{", "constraint", ":=", "s", ".", "sel", ".", "getConstraint", "(", "pa", ".", "id", ")", "\n", "if", "s", ".", "vUnify", ".", "matches", "(", "pa", ".", ...
// checkAtomAllowable ensures that an atom itself is acceptable with respect to // the constraints established by the current solution.
[ "checkAtomAllowable", "ensures", "that", "an", "atom", "itself", "is", "acceptable", "with", "respect", "to", "the", "constraints", "established", "by", "the", "current", "solution", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/satisfy.go#L81-L104
149,276
sdboyer/gps
satisfy.go
checkRequiredPackagesExist
func (s *solver) checkRequiredPackagesExist(a atomWithPackages) error { ptree, err := s.b.ListPackages(a.a.id, a.a.v) if err != nil { // TODO(sdboyer) handle this more gracefully return err } deps := s.sel.getDependenciesOn(a.a.id) fp := make(map[string]errDeppers) // We inspect these in a bit of a roundabou...
go
func (s *solver) checkRequiredPackagesExist(a atomWithPackages) error { ptree, err := s.b.ListPackages(a.a.id, a.a.v) if err != nil { // TODO(sdboyer) handle this more gracefully return err } deps := s.sel.getDependenciesOn(a.a.id) fp := make(map[string]errDeppers) // We inspect these in a bit of a roundabou...
[ "func", "(", "s", "*", "solver", ")", "checkRequiredPackagesExist", "(", "a", "atomWithPackages", ")", "error", "{", "ptree", ",", "err", ":=", "s", ".", "b", ".", "ListPackages", "(", "a", ".", "a", ".", "id", ",", "a", ".", "a", ".", "v", ")", ...
// checkRequiredPackagesExist ensures that all required packages enumerated by // existing dependencies on this atom are actually present in the atom.
[ "checkRequiredPackagesExist", "ensures", "that", "all", "required", "packages", "enumerated", "by", "existing", "dependencies", "on", "this", "atom", "are", "actually", "present", "in", "the", "atom", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/satisfy.go#L108-L144
149,277
sdboyer/gps
satisfy.go
checkDepsConstraintsAllowable
func (s *solver) checkDepsConstraintsAllowable(a atomWithPackages, cdep completeDep) error { dep := cdep.workingConstraint constraint := s.sel.getConstraint(dep.Ident) // Ensure the constraint expressed by the dep has at least some possible // intersection with the intersection of existing constraints. if s.vUnify...
go
func (s *solver) checkDepsConstraintsAllowable(a atomWithPackages, cdep completeDep) error { dep := cdep.workingConstraint constraint := s.sel.getConstraint(dep.Ident) // Ensure the constraint expressed by the dep has at least some possible // intersection with the intersection of existing constraints. if s.vUnify...
[ "func", "(", "s", "*", "solver", ")", "checkDepsConstraintsAllowable", "(", "a", "atomWithPackages", ",", "cdep", "completeDep", ")", "error", "{", "dep", ":=", "cdep", ".", "workingConstraint", "\n", "constraint", ":=", "s", ".", "sel", ".", "getConstraint", ...
// checkDepsConstraintsAllowable checks that the constraints of an atom on a // given dep are valid with respect to existing constraints.
[ "checkDepsConstraintsAllowable", "checks", "that", "the", "constraints", "of", "an", "atom", "on", "a", "given", "dep", "are", "valid", "with", "respect", "to", "existing", "constraints", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/satisfy.go#L148-L176
149,278
sdboyer/gps
satisfy.go
checkDepsDisallowsSelected
func (s *solver) checkDepsDisallowsSelected(a atomWithPackages, cdep completeDep) error { dep := cdep.workingConstraint selected, exists := s.sel.selected(dep.Ident) if exists && !s.vUnify.matches(dep.Ident, dep.Constraint, selected.a.v) { s.fail(dep.Ident) return &constraintNotAllowedFailure{ goal: dependen...
go
func (s *solver) checkDepsDisallowsSelected(a atomWithPackages, cdep completeDep) error { dep := cdep.workingConstraint selected, exists := s.sel.selected(dep.Ident) if exists && !s.vUnify.matches(dep.Ident, dep.Constraint, selected.a.v) { s.fail(dep.Ident) return &constraintNotAllowedFailure{ goal: dependen...
[ "func", "(", "s", "*", "solver", ")", "checkDepsDisallowsSelected", "(", "a", "atomWithPackages", ",", "cdep", "completeDep", ")", "error", "{", "dep", ":=", "cdep", ".", "workingConstraint", "\n", "selected", ",", "exists", ":=", "s", ".", "sel", ".", "se...
// checkDepsDisallowsSelected ensures that an atom's constraints on a particular // dep are not incompatible with the version of that dep that's already been // selected.
[ "checkDepsDisallowsSelected", "ensures", "that", "an", "atom", "s", "constraints", "on", "a", "particular", "dep", "are", "not", "incompatible", "with", "the", "version", "of", "that", "dep", "that", "s", "already", "been", "selected", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/satisfy.go#L181-L193
149,279
sdboyer/gps
satisfy.go
checkPackageImportsFromDepExist
func (s *solver) checkPackageImportsFromDepExist(a atomWithPackages, cdep completeDep) error { sel, is := s.sel.selected(cdep.workingConstraint.Ident) if !is { // dep is not already selected; nothing to do return nil } ptree, err := s.b.ListPackages(sel.a.id, sel.a.v) if err != nil { // TODO(sdboyer) handle...
go
func (s *solver) checkPackageImportsFromDepExist(a atomWithPackages, cdep completeDep) error { sel, is := s.sel.selected(cdep.workingConstraint.Ident) if !is { // dep is not already selected; nothing to do return nil } ptree, err := s.b.ListPackages(sel.a.id, sel.a.v) if err != nil { // TODO(sdboyer) handle...
[ "func", "(", "s", "*", "solver", ")", "checkPackageImportsFromDepExist", "(", "a", "atomWithPackages", ",", "cdep", "completeDep", ")", "error", "{", "sel", ",", "is", ":=", "s", ".", "sel", ".", "selected", "(", "cdep", ".", "workingConstraint", ".", "Ide...
// checkPackageImportsFromDepExist ensures that, if the dep is already selected, // the newly-required set of packages being placed on it exist and are valid.
[ "checkPackageImportsFromDepExist", "ensures", "that", "if", "the", "dep", "is", "already", "selected", "the", "newly", "-", "required", "set", "of", "packages", "being", "placed", "on", "it", "exist", "and", "are", "valid", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/satisfy.go#L226-L263
149,280
sdboyer/gps
satisfy.go
checkRevisionExists
func (s *solver) checkRevisionExists(a atomWithPackages, cdep completeDep) error { r, isrev := cdep.Constraint.(Revision) if !isrev { // Constraint is not a revision; nothing to do return nil } present, _ := s.b.RevisionPresentIn(cdep.Ident, r) if present { return nil } return &nonexistentRevisionFailure...
go
func (s *solver) checkRevisionExists(a atomWithPackages, cdep completeDep) error { r, isrev := cdep.Constraint.(Revision) if !isrev { // Constraint is not a revision; nothing to do return nil } present, _ := s.b.RevisionPresentIn(cdep.Ident, r) if present { return nil } return &nonexistentRevisionFailure...
[ "func", "(", "s", "*", "solver", ")", "checkRevisionExists", "(", "a", "atomWithPackages", ",", "cdep", "completeDep", ")", "error", "{", "r", ",", "isrev", ":=", "cdep", ".", "Constraint", ".", "(", "Revision", ")", "\n", "if", "!", "isrev", "{", "// ...
// checkRevisionExists ensures that if a dependency is constrained by a // revision, that that revision actually exists.
[ "checkRevisionExists", "ensures", "that", "if", "a", "dependency", "is", "constrained", "by", "a", "revision", "that", "that", "revision", "actually", "exists", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/satisfy.go#L267-L286
149,281
sdboyer/gps
manifest.go
prepManifest
func prepManifest(m Manifest) SimpleManifest { if m == nil { return SimpleManifest{} } deps := m.DependencyConstraints() ddeps := m.TestDependencyConstraints() rm := SimpleManifest{ Deps: make(ProjectConstraints, len(deps)), TestDeps: make(ProjectConstraints, len(ddeps)), } for k, d := range deps { ...
go
func prepManifest(m Manifest) SimpleManifest { if m == nil { return SimpleManifest{} } deps := m.DependencyConstraints() ddeps := m.TestDependencyConstraints() rm := SimpleManifest{ Deps: make(ProjectConstraints, len(deps)), TestDeps: make(ProjectConstraints, len(ddeps)), } for k, d := range deps { ...
[ "func", "prepManifest", "(", "m", "Manifest", ")", "SimpleManifest", "{", "if", "m", "==", "nil", "{", "return", "SimpleManifest", "{", "}", "\n", "}", "\n\n", "deps", ":=", "m", ".", "DependencyConstraints", "(", ")", "\n", "ddeps", ":=", "m", ".", "T...
// prepManifest ensures a manifest is prepared and safe for use by the solver. // This is mostly about ensuring that no outside routine can modify the manifest // while the solver is in-flight, but it also filters out any empty // ProjectProperties. // // This is achieved by copying the manifest's data into a new Simpl...
[ "prepManifest", "ensures", "a", "manifest", "is", "prepared", "and", "safe", "for", "use", "by", "the", "solver", ".", "This", "is", "mostly", "about", "ensuring", "that", "no", "outside", "routine", "can", "modify", "the", "manifest", "while", "the", "solve...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/manifest.go#L142-L182
149,282
sdboyer/gps
internal/fs/fs.go
RenameWithFallback
func RenameWithFallback(src, dest string) error { fi, err := os.Stat(src) if err != nil { return err } err = os.Rename(src, dest) if err == nil { return nil } terr, ok := err.(*os.LinkError) if !ok { return err } // Rename may fail if src and dest are on different devices; fall back to // copy if we...
go
func RenameWithFallback(src, dest string) error { fi, err := os.Stat(src) if err != nil { return err } err = os.Rename(src, dest) if err == nil { return nil } terr, ok := err.(*os.LinkError) if !ok { return err } // Rename may fail if src and dest are on different devices; fall back to // copy if we...
[ "func", "RenameWithFallback", "(", "src", ",", "dest", "string", ")", "error", "{", "fi", ",", "err", ":=", "os", ".", "Stat", "(", "src", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "err", "=", "os", ".", "Renam...
// RenameWithFallback attempts to rename a file or directory, but falls back to // copying in the event of a cross-link device error. If the fallback copy // succeeds, src is still removed, emulating normal rename behavior.
[ "RenameWithFallback", "attempts", "to", "rename", "a", "file", "or", "directory", "but", "falls", "back", "to", "copying", "in", "the", "event", "of", "a", "cross", "-", "link", "device", "error", ".", "If", "the", "fallback", "copy", "succeeds", "src", "i...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/internal/fs/fs.go#L16-L66
149,283
sdboyer/gps
constraints.go
NewSemverConstraint
func NewSemverConstraint(body string) (Constraint, error) { c, err := semver.NewConstraint(body) if err != nil { return nil, err } // If we got a simple semver.Version, simplify by returning our // corresponding type if sv, ok := c.(*semver.Version); ok { return semVersion{sv: sv}, nil } return semverConstr...
go
func NewSemverConstraint(body string) (Constraint, error) { c, err := semver.NewConstraint(body) if err != nil { return nil, err } // If we got a simple semver.Version, simplify by returning our // corresponding type if sv, ok := c.(*semver.Version); ok { return semVersion{sv: sv}, nil } return semverConstr...
[ "func", "NewSemverConstraint", "(", "body", "string", ")", "(", "Constraint", ",", "error", ")", "{", "c", ",", "err", ":=", "semver", ".", "NewConstraint", "(", "body", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}"...
// NewSemverConstraint attempts to construct a semver Constraint object from the // input string. // // If the input string cannot be made into a valid semver Constraint, an error // is returned.
[ "NewSemverConstraint", "attempts", "to", "construct", "a", "semver", "Constraint", "object", "from", "the", "input", "string", ".", "If", "the", "input", "string", "cannot", "be", "made", "into", "a", "valid", "semver", "Constraint", "an", "error", "is", "retu...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/constraints.go#L50-L61
149,284
sdboyer/gps
constraints.go
overrideAll
func (m ProjectConstraints) overrideAll(pcm ProjectConstraints) (out []workingConstraint) { out = make([]workingConstraint, len(pcm)) k := 0 for pr, pp := range pcm { out[k] = m.override(pr, pp) k++ } sort.Stable(sortedWC(out)) return }
go
func (m ProjectConstraints) overrideAll(pcm ProjectConstraints) (out []workingConstraint) { out = make([]workingConstraint, len(pcm)) k := 0 for pr, pp := range pcm { out[k] = m.override(pr, pp) k++ } sort.Stable(sortedWC(out)) return }
[ "func", "(", "m", "ProjectConstraints", ")", "overrideAll", "(", "pcm", "ProjectConstraints", ")", "(", "out", "[", "]", "workingConstraint", ")", "{", "out", "=", "make", "(", "[", "]", "workingConstraint", ",", "len", "(", "pcm", ")", ")", "\n", "k", ...
// overrideAll treats the receiver ProjectConstraints map as a set of override // instructions, and applies overridden values to the ProjectConstraints. // // A slice of workingConstraint is returned, allowing differentiation between // values that were or were not overridden.
[ "overrideAll", "treats", "the", "receiver", "ProjectConstraints", "map", "as", "a", "set", "of", "override", "instructions", "and", "applies", "overridden", "values", "to", "the", "ProjectConstraints", ".", "A", "slice", "of", "workingConstraint", "is", "returned", ...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/constraints.go#L299-L309
149,285
sdboyer/gps
constraints.go
override
func (m ProjectConstraints) override(pr ProjectRoot, pp ProjectProperties) workingConstraint { wc := workingConstraint{ Ident: ProjectIdentifier{ ProjectRoot: pr, Source: pp.Source, }, Constraint: pp.Constraint, } if opp, has := m[pr]; has { // The rule for overrides is that *any* non-zero value ...
go
func (m ProjectConstraints) override(pr ProjectRoot, pp ProjectProperties) workingConstraint { wc := workingConstraint{ Ident: ProjectIdentifier{ ProjectRoot: pr, Source: pp.Source, }, Constraint: pp.Constraint, } if opp, has := m[pr]; has { // The rule for overrides is that *any* non-zero value ...
[ "func", "(", "m", "ProjectConstraints", ")", "override", "(", "pr", "ProjectRoot", ",", "pp", "ProjectProperties", ")", "workingConstraint", "{", "wc", ":=", "workingConstraint", "{", "Ident", ":", "ProjectIdentifier", "{", "ProjectRoot", ":", "pr", ",", "Source...
// override replaces a single ProjectConstraint with a workingConstraint, // overriding its values if a corresponding entry exists in the // ProjectConstraints map.
[ "override", "replaces", "a", "single", "ProjectConstraint", "with", "a", "workingConstraint", "overriding", "its", "values", "if", "a", "corresponding", "entry", "exists", "in", "the", "ProjectConstraints", "map", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/constraints.go#L314-L347
149,286
sdboyer/gps
deduce.go
fetchMetadata
func fetchMetadata(ctx context.Context, path, scheme string) (rc io.ReadCloser, err error) { defer func() { if err != nil { err = fmt.Errorf("unable to determine remote metadata protocol: %s", err) } }() if scheme == "http" { rc, err = doFetchMetadata(ctx, "http", path) return } rc, err = doFetchMetad...
go
func fetchMetadata(ctx context.Context, path, scheme string) (rc io.ReadCloser, err error) { defer func() { if err != nil { err = fmt.Errorf("unable to determine remote metadata protocol: %s", err) } }() if scheme == "http" { rc, err = doFetchMetadata(ctx, "http", path) return } rc, err = doFetchMetad...
[ "func", "fetchMetadata", "(", "ctx", "context", ".", "Context", ",", "path", ",", "scheme", "string", ")", "(", "rc", "io", ".", "ReadCloser", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "err", "=",...
// fetchMetadata fetches the remote metadata for path.
[ "fetchMetadata", "fetches", "the", "remote", "metadata", "for", "path", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/deduce.go#L800-L819
149,287
sdboyer/gps
typed_radix.go
Insert
func (t *deducerTrie) Insert(s string, d pathDeducer) (pathDeducer, bool) { t.Lock() defer t.Unlock() if d2, had := t.t.Insert(s, d); had { return d2.(pathDeducer), had } return nil, false }
go
func (t *deducerTrie) Insert(s string, d pathDeducer) (pathDeducer, bool) { t.Lock() defer t.Unlock() if d2, had := t.t.Insert(s, d); had { return d2.(pathDeducer), had } return nil, false }
[ "func", "(", "t", "*", "deducerTrie", ")", "Insert", "(", "s", "string", ",", "d", "pathDeducer", ")", "(", "pathDeducer", ",", "bool", ")", "{", "t", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "Unlock", "(", ")", "\n", "if", "d2", ",", "h...
// Insert is used to add a newentry or update an existing entry. Returns if updated.
[ "Insert", "is", "used", "to", "add", "a", "newentry", "or", "update", "an", "existing", "entry", ".", "Returns", "if", "updated", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/typed_radix.go#L50-L57
149,288
sdboyer/gps
typed_radix.go
Len
func (t *deducerTrie) Len() int { t.RLock() defer t.RUnlock() return t.t.Len() }
go
func (t *deducerTrie) Len() int { t.RLock() defer t.RUnlock() return t.t.Len() }
[ "func", "(", "t", "*", "deducerTrie", ")", "Len", "(", ")", "int", "{", "t", ".", "RLock", "(", ")", "\n", "defer", "t", ".", "RUnlock", "(", ")", "\n", "return", "t", ".", "t", ".", "Len", "(", ")", "\n", "}" ]
// Len is used to return the number of elements in the tree
[ "Len", "is", "used", "to", "return", "the", "number", "of", "elements", "in", "the", "tree" ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/typed_radix.go#L60-L64
149,289
sdboyer/gps
typed_radix.go
ToMap
func (t *deducerTrie) ToMap() map[string]pathDeducer { m := make(map[string]pathDeducer) t.RLock() t.t.Walk(func(s string, d interface{}) bool { m[s] = d.(pathDeducer) return false }) t.RUnlock() return m }
go
func (t *deducerTrie) ToMap() map[string]pathDeducer { m := make(map[string]pathDeducer) t.RLock() t.t.Walk(func(s string, d interface{}) bool { m[s] = d.(pathDeducer) return false }) t.RUnlock() return m }
[ "func", "(", "t", "*", "deducerTrie", ")", "ToMap", "(", ")", "map", "[", "string", "]", "pathDeducer", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "pathDeducer", ")", "\n", "t", ".", "RLock", "(", ")", "\n", "t", ".", "t", ".", "Wa...
// ToMap is used to walk the tree and convert it to a map.
[ "ToMap", "is", "used", "to", "walk", "the", "tree", "and", "convert", "it", "to", "a", "map", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/typed_radix.go#L78-L88
149,290
sdboyer/gps
solver.go
Prepare
func Prepare(params SolveParameters, sm SourceManager) (Solver, error) { if sm == nil { return nil, badOptsFailure("must provide non-nil SourceManager") } if params.Trace && params.TraceLogger == nil { return nil, badOptsFailure("trace requested, but no logger provided") } rd, err := params.toRootdata() if e...
go
func Prepare(params SolveParameters, sm SourceManager) (Solver, error) { if sm == nil { return nil, badOptsFailure("must provide non-nil SourceManager") } if params.Trace && params.TraceLogger == nil { return nil, badOptsFailure("trace requested, but no logger provided") } rd, err := params.toRootdata() if e...
[ "func", "Prepare", "(", "params", "SolveParameters", ",", "sm", "SourceManager", ")", "(", "Solver", ",", "error", ")", "{", "if", "sm", "==", "nil", "{", "return", "nil", ",", "badOptsFailure", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "params", ...
// Prepare readies a Solver for use. // // This function reads and validates the provided SolveParameters. If a problem // with the inputs is detected, an error is returned. Otherwise, a Solver is // returned, ready to hash and check inputs or perform a solving run.
[ "Prepare", "readies", "a", "Solver", "for", "use", ".", "This", "function", "reads", "and", "validates", "the", "provided", "SolveParameters", ".", "If", "a", "problem", "with", "the", "inputs", "is", "detected", "an", "error", "is", "returned", ".", "Otherw...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/solver.go#L276-L317
149,291
sdboyer/gps
solver.go
Solve
func (s *solver) Solve() (Solution, error) { // Set up a metrics object s.mtr = newMetrics() s.vUnify.mtr = s.mtr // Prime the queues with the root project err := s.selectRoot() if err != nil { return nil, err } all, err := s.solve() s.mtr.pop() var soln solution if err == nil { soln = solution{ at...
go
func (s *solver) Solve() (Solution, error) { // Set up a metrics object s.mtr = newMetrics() s.vUnify.mtr = s.mtr // Prime the queues with the root project err := s.selectRoot() if err != nil { return nil, err } all, err := s.solve() s.mtr.pop() var soln solution if err == nil { soln = solution{ at...
[ "func", "(", "s", "*", "solver", ")", "Solve", "(", ")", "(", "Solution", ",", "error", ")", "{", "// Set up a metrics object", "s", ".", "mtr", "=", "newMetrics", "(", ")", "\n", "s", ".", "vUnify", ".", "mtr", "=", "s", ".", "mtr", "\n\n", "// Pr...
// Solve attempts to find a dependency solution for the given project, as // represented by the SolveParameters with which this Solver was created. // // This is the entry point to the main gps workhorse.
[ "Solve", "attempts", "to", "find", "a", "dependency", "solution", "for", "the", "given", "project", "as", "represented", "by", "the", "SolveParameters", "with", "which", "this", "Solver", "was", "created", ".", "This", "is", "the", "entry", "point", "to", "t...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/solver.go#L344-L380
149,292
sdboyer/gps
solver.go
solve
func (s *solver) solve() (map[atom]map[string]struct{}, error) { // Main solving loop for { bmi, has := s.nextUnselected() if !has { // no more packages to select - we're done. break } // This split is the heart of "bimodal solving": we follow different // satisfiability and selection paths dependin...
go
func (s *solver) solve() (map[atom]map[string]struct{}, error) { // Main solving loop for { bmi, has := s.nextUnselected() if !has { // no more packages to select - we're done. break } // This split is the heart of "bimodal solving": we follow different // satisfiability and selection paths dependin...
[ "func", "(", "s", "*", "solver", ")", "solve", "(", ")", "(", "map", "[", "atom", "]", "map", "[", "string", "]", "struct", "{", "}", ",", "error", ")", "{", "// Main solving loop", "for", "{", "bmi", ",", "has", ":=", "s", ".", "nextUnselected", ...
// solve is the top-level loop for the solving process.
[ "solve", "is", "the", "top", "-", "level", "loop", "for", "the", "solving", "process", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/solver.go#L383-L489
149,293
sdboyer/gps
solver.go
selectRoot
func (s *solver) selectRoot() error { s.mtr.push("select-root") // Push the root project onto the queue. awp := s.rd.rootAtom() s.sel.pushSelection(awp, true) // If we're looking for root's deps, get it from opts and local root // analysis, rather than having the sm do it deps, err := s.intersectConstraintsWith...
go
func (s *solver) selectRoot() error { s.mtr.push("select-root") // Push the root project onto the queue. awp := s.rd.rootAtom() s.sel.pushSelection(awp, true) // If we're looking for root's deps, get it from opts and local root // analysis, rather than having the sm do it deps, err := s.intersectConstraintsWith...
[ "func", "(", "s", "*", "solver", ")", "selectRoot", "(", ")", "error", "{", "s", ".", "mtr", ".", "push", "(", "\"", "\"", ")", "\n", "// Push the root project onto the queue.", "awp", ":=", "s", ".", "rd", ".", "rootAtom", "(", ")", "\n", "s", ".", ...
// selectRoot is a specialized selectAtom, used solely to initially // populate the queues at the beginning of a solve run.
[ "selectRoot", "is", "a", "specialized", "selectAtom", "used", "solely", "to", "initially", "populate", "the", "queues", "at", "the", "beginning", "of", "a", "solve", "run", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/solver.go#L493-L523
149,294
sdboyer/gps
solver.go
findValidVersion
func (s *solver) findValidVersion(q *versionQueue, pl []string) error { if nil == q.current() { // this case should not be reachable, but reflects improper solver state // if it is, so panic immediately panic("version queue is empty, should not happen") } faillen := len(q.fails) for { cur := q.current() ...
go
func (s *solver) findValidVersion(q *versionQueue, pl []string) error { if nil == q.current() { // this case should not be reachable, but reflects improper solver state // if it is, so panic immediately panic("version queue is empty, should not happen") } faillen := len(q.fails) for { cur := q.current() ...
[ "func", "(", "s", "*", "solver", ")", "findValidVersion", "(", "q", "*", "versionQueue", ",", "pl", "[", "]", "string", ")", "error", "{", "if", "nil", "==", "q", ".", "current", "(", ")", "{", "// this case should not be reachable, but reflects improper solve...
// findValidVersion walks through a versionQueue until it finds a version that // satisfies the constraints held in the current state of the solver. // // The satisfiability checks triggered from here are constrained to operate only // on those dependencies induced by the list of packages given in the second // paramet...
[ "findValidVersion", "walks", "through", "a", "versionQueue", "until", "it", "finds", "a", "version", "that", "satisfies", "the", "constraints", "held", "in", "the", "current", "state", "of", "the", "solver", ".", "The", "satisfiability", "checks", "triggered", "...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/solver.go#L796-L838
149,295
sdboyer/gps
solver.go
backtrack
func (s *solver) backtrack() bool { if len(s.vqs) == 0 { // nothing to backtrack to return false } s.mtr.push("backtrack") for { for { if len(s.vqs) == 0 { // no more versions, nowhere further to backtrack return false } if s.vqs[len(s.vqs)-1].failed { break } s.vqs, s.vqs[len(s.v...
go
func (s *solver) backtrack() bool { if len(s.vqs) == 0 { // nothing to backtrack to return false } s.mtr.push("backtrack") for { for { if len(s.vqs) == 0 { // no more versions, nowhere further to backtrack return false } if s.vqs[len(s.vqs)-1].failed { break } s.vqs, s.vqs[len(s.v...
[ "func", "(", "s", "*", "solver", ")", "backtrack", "(", ")", "bool", "{", "if", "len", "(", "s", ".", "vqs", ")", "==", "0", "{", "// nothing to backtrack to", "return", "false", "\n", "}", "\n\n", "s", ".", "mtr", ".", "push", "(", "\"", "\"", "...
// backtrack works backwards from the current failed solution to find the next // solution to try.
[ "backtrack", "works", "backwards", "from", "the", "current", "failed", "solution", "to", "find", "the", "next", "solution", "to", "try", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/solver.go#L919-L992
149,296
sdboyer/gps
solver.go
selectAtom
func (s *solver) selectAtom(a atomWithPackages, pkgonly bool) { s.mtr.push("select-atom") s.unsel.remove(bimodalIdentifier{ id: a.a.id, pl: a.pl, }) pl, deps, err := s.getImportsAndConstraintsOf(a) if err != nil { // This shouldn't be possible; other checks should have ensured all // packages and deps are...
go
func (s *solver) selectAtom(a atomWithPackages, pkgonly bool) { s.mtr.push("select-atom") s.unsel.remove(bimodalIdentifier{ id: a.a.id, pl: a.pl, }) pl, deps, err := s.getImportsAndConstraintsOf(a) if err != nil { // This shouldn't be possible; other checks should have ensured all // packages and deps are...
[ "func", "(", "s", "*", "solver", ")", "selectAtom", "(", "a", "atomWithPackages", ",", "pkgonly", "bool", ")", "{", "s", ".", "mtr", ".", "push", "(", "\"", "\"", ")", "\n", "s", ".", "unsel", ".", "remove", "(", "bimodalIdentifier", "{", "id", ":"...
// selectAtom pulls an atom into the selection stack, alongside some of // its contained packages. New resultant dependency requirements are added to // the unselected priority queue. // // Behavior is slightly diffferent if pkgonly is true.
[ "selectAtom", "pulls", "an", "atom", "into", "the", "selection", "stack", "alongside", "some", "of", "its", "contained", "packages", ".", "New", "resultant", "dependency", "requirements", "are", "added", "to", "the", "unselected", "priority", "queue", ".", "Beha...
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/solver.go#L1094-L1178
149,297
sdboyer/gps
version_queue.go
advance
func (vq *versionQueue) advance(fail error) error { // Nothing in the queue means...nothing in the queue, nicely enough if vq.adverr != nil || len(vq.pi) == 0 { // should be a redundant check, but just in case return vq.adverr } // Record the fail reason and pop the queue vq.fails = append(vq.fails, failedVersi...
go
func (vq *versionQueue) advance(fail error) error { // Nothing in the queue means...nothing in the queue, nicely enough if vq.adverr != nil || len(vq.pi) == 0 { // should be a redundant check, but just in case return vq.adverr } // Record the fail reason and pop the queue vq.fails = append(vq.fails, failedVersi...
[ "func", "(", "vq", "*", "versionQueue", ")", "advance", "(", "fail", "error", ")", "error", "{", "// Nothing in the queue means...nothing in the queue, nicely enough", "if", "vq", ".", "adverr", "!=", "nil", "||", "len", "(", "vq", ".", "pi", ")", "==", "0", ...
// advance moves the versionQueue forward to the next available version, // recording the failure that eliminated the current version.
[ "advance", "moves", "the", "versionQueue", "forward", "to", "the", "next", "available", "version", "recording", "the", "failure", "that", "eliminated", "the", "current", "version", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/version_queue.go#L67-L133
149,298
sdboyer/gps
maybe_source.go
getURL
func (mbs maybeSources) getURL() string { strslice := make([]string, 0, len(mbs)) for _, mb := range mbs { strslice = append(strslice, mb.getURL()) } return strings.Join(strslice, "\n") }
go
func (mbs maybeSources) getURL() string { strslice := make([]string, 0, len(mbs)) for _, mb := range mbs { strslice = append(strslice, mb.getURL()) } return strings.Join(strslice, "\n") }
[ "func", "(", "mbs", "maybeSources", ")", "getURL", "(", ")", "string", "{", "strslice", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "mbs", ")", ")", "\n", "for", "_", ",", "mb", ":=", "range", "mbs", "{", "strslice", "=", ...
// This really isn't generally intended to be used - the interface is for // maybeSources to be able to interrogate its members, not other things to // interrogate a maybeSources.
[ "This", "really", "isn", "t", "generally", "intended", "to", "be", "used", "-", "the", "interface", "is", "for", "maybeSources", "to", "be", "able", "to", "interrogate", "its", "members", "not", "other", "things", "to", "interrogate", "a", "maybeSources", "....
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/maybe_source.go#L46-L52
149,299
sdboyer/gps
version_unifier.go
pairVersion
func (vu versionUnifier) pairVersion(id ProjectIdentifier, v UnpairedVersion) PairedVersion { vl, err := vu.b.listVersions(id) if err != nil { return nil } vu.mtr.push("b-pair-version") // doing it like this is a bit sloppy for _, v2 := range vl { if p, ok := v2.(PairedVersion); ok { if p.Matches(v) { ...
go
func (vu versionUnifier) pairVersion(id ProjectIdentifier, v UnpairedVersion) PairedVersion { vl, err := vu.b.listVersions(id) if err != nil { return nil } vu.mtr.push("b-pair-version") // doing it like this is a bit sloppy for _, v2 := range vl { if p, ok := v2.(PairedVersion); ok { if p.Matches(v) { ...
[ "func", "(", "vu", "versionUnifier", ")", "pairVersion", "(", "id", "ProjectIdentifier", ",", "v", "UnpairedVersion", ")", "PairedVersion", "{", "vl", ",", "err", ":=", "vu", ".", "b", ".", "listVersions", "(", "id", ")", "\n", "if", "err", "!=", "nil", ...
// pairVersion takes an UnpairedVersion and attempts to pair it with an // underlying Revision in the context of the provided ProjectIdentifier by // consulting the canonical version list.
[ "pairVersion", "takes", "an", "UnpairedVersion", "and", "attempts", "to", "pair", "it", "with", "an", "underlying", "Revision", "in", "the", "context", "of", "the", "provided", "ProjectIdentifier", "by", "consulting", "the", "canonical", "version", "list", "." ]
c056fb513887b1335e534c91daca4df510d29b66
https://github.com/sdboyer/gps/blob/c056fb513887b1335e534c91daca4df510d29b66/version_unifier.go#L12-L31