id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
19,400
go-ole/go-ole
com.go
CreateDispTypeInfo
func CreateDispTypeInfo(idata *INTERFACEDATA) (pptinfo *IUnknown, err error) { hr, _, _ := procCreateDispTypeInfo.Call( uintptr(unsafe.Pointer(idata)), uintptr(GetUserDefaultLCID()), uintptr(unsafe.Pointer(&pptinfo))) if hr != 0 { err = NewError(hr) } return }
go
func CreateDispTypeInfo(idata *INTERFACEDATA) (pptinfo *IUnknown, err error) { hr, _, _ := procCreateDispTypeInfo.Call( uintptr(unsafe.Pointer(idata)), uintptr(GetUserDefaultLCID()), uintptr(unsafe.Pointer(&pptinfo))) if hr != 0 { err = NewError(hr) } return }
[ "func", "CreateDispTypeInfo", "(", "idata", "*", "INTERFACEDATA", ")", "(", "pptinfo", "*", "IUnknown", ",", "err", "error", ")", "{", "hr", ",", "_", ",", "_", ":=", "procCreateDispTypeInfo", ".", "Call", "(", "uintptr", "(", "unsafe", ".", "Pointer", "...
// CreateDispTypeInfo provides default ITypeInfo implementation for IDispatch. // // This will not handle the full implementation of the interface.
[ "CreateDispTypeInfo", "provides", "default", "ITypeInfo", "implementation", "for", "IDispatch", ".", "This", "will", "not", "handle", "the", "full", "implementation", "of", "the", "interface", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/com.go#L307-L316
19,401
go-ole/go-ole
com.go
copyMemory
func copyMemory(dest unsafe.Pointer, src unsafe.Pointer, length uint32) { procCopyMemory.Call(uintptr(dest), uintptr(src), uintptr(length)) }
go
func copyMemory(dest unsafe.Pointer, src unsafe.Pointer, length uint32) { procCopyMemory.Call(uintptr(dest), uintptr(src), uintptr(length)) }
[ "func", "copyMemory", "(", "dest", "unsafe", ".", "Pointer", ",", "src", "unsafe", ".", "Pointer", ",", "length", "uint32", ")", "{", "procCopyMemory", ".", "Call", "(", "uintptr", "(", "dest", ")", ",", "uintptr", "(", "src", ")", ",", "uintptr", "(",...
// copyMemory moves location of a block of memory.
[ "copyMemory", "moves", "location", "of", "a", "block", "of", "memory", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/com.go#L319-L321
19,402
go-ole/go-ole
com.go
GetUserDefaultLCID
func GetUserDefaultLCID() (lcid uint32) { ret, _, _ := procGetUserDefaultLCID.Call() lcid = uint32(ret) return }
go
func GetUserDefaultLCID() (lcid uint32) { ret, _, _ := procGetUserDefaultLCID.Call() lcid = uint32(ret) return }
[ "func", "GetUserDefaultLCID", "(", ")", "(", "lcid", "uint32", ")", "{", "ret", ",", "_", ",", "_", ":=", "procGetUserDefaultLCID", ".", "Call", "(", ")", "\n", "lcid", "=", "uint32", "(", "ret", ")", "\n", "return", "\n", "}" ]
// GetUserDefaultLCID retrieves current user default locale.
[ "GetUserDefaultLCID", "retrieves", "current", "user", "default", "locale", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/com.go#L324-L328
19,403
go-ole/go-ole
com.go
DispatchMessage
func DispatchMessage(msg *Msg) (ret int32) { r0, _, _ := procDispatchMessageW.Call(uintptr(unsafe.Pointer(msg))) ret = int32(r0) return }
go
func DispatchMessage(msg *Msg) (ret int32) { r0, _, _ := procDispatchMessageW.Call(uintptr(unsafe.Pointer(msg))) ret = int32(r0) return }
[ "func", "DispatchMessage", "(", "msg", "*", "Msg", ")", "(", "ret", "int32", ")", "{", "r0", ",", "_", ",", "_", ":=", "procDispatchMessageW", ".", "Call", "(", "uintptr", "(", "unsafe", ".", "Pointer", "(", "msg", ")", ")", ")", "\n", "ret", "=", ...
// DispatchMessage to window procedure.
[ "DispatchMessage", "to", "window", "procedure", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/com.go#L340-L344
19,404
go-ole/go-ole
variant_date_amd64.go
GetVariantDate
func GetVariantDate(value uint64) (time.Time, error) { var st syscall.Systemtime r, _, _ := procVariantTimeToSystemTime.Call(uintptr(value), uintptr(unsafe.Pointer(&st))) if r != 0 { return time.Date(int(st.Year), time.Month(st.Month), int(st.Day), int(st.Hour), int(st.Minute), int(st.Second), int(st.Milliseconds/...
go
func GetVariantDate(value uint64) (time.Time, error) { var st syscall.Systemtime r, _, _ := procVariantTimeToSystemTime.Call(uintptr(value), uintptr(unsafe.Pointer(&st))) if r != 0 { return time.Date(int(st.Year), time.Month(st.Month), int(st.Day), int(st.Hour), int(st.Minute), int(st.Second), int(st.Milliseconds/...
[ "func", "GetVariantDate", "(", "value", "uint64", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "var", "st", "syscall", ".", "Systemtime", "\n", "r", ",", "_", ",", "_", ":=", "procVariantTimeToSystemTime", ".", "Call", "(", "uintptr", "(", "v...
// GetVariantDate converts COM Variant Time value to Go time.Time.
[ "GetVariantDate", "converts", "COM", "Variant", "Time", "value", "to", "Go", "time", ".", "Time", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/variant_date_amd64.go#L13-L20
19,405
go-ole/go-ole
ole.go
String
func (e EXCEPINFO) String() string { var src, desc, hlp string if e.bstrSource == nil { src = "<nil>" } else { src = BstrToString(e.bstrSource) } if e.bstrDescription == nil { desc = "<nil>" } else { desc = BstrToString(e.bstrDescription) } if e.bstrHelpFile == nil { hlp = "<nil>" } else { hlp = ...
go
func (e EXCEPINFO) String() string { var src, desc, hlp string if e.bstrSource == nil { src = "<nil>" } else { src = BstrToString(e.bstrSource) } if e.bstrDescription == nil { desc = "<nil>" } else { desc = BstrToString(e.bstrDescription) } if e.bstrHelpFile == nil { hlp = "<nil>" } else { hlp = ...
[ "func", "(", "e", "EXCEPINFO", ")", "String", "(", ")", "string", "{", "var", "src", ",", "desc", ",", "hlp", "string", "\n", "if", "e", ".", "bstrSource", "==", "nil", "{", "src", "=", "\"", "\"", "\n", "}", "else", "{", "src", "=", "BstrToStrin...
// String convert EXCEPINFO to string.
[ "String", "convert", "EXCEPINFO", "to", "string", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/ole.go#L40-L64
19,406
go-ole/go-ole
ole.go
Error
func (e EXCEPINFO) Error() string { if e.bstrDescription != nil { return strings.TrimSpace(BstrToString(e.bstrDescription)) } src := "Unknown" if e.bstrSource != nil { src = BstrToString(e.bstrSource) } code := e.scode if e.wCode != 0 { code = uint32(e.wCode) } return fmt.Sprintf("%v: %#x", src, code)...
go
func (e EXCEPINFO) Error() string { if e.bstrDescription != nil { return strings.TrimSpace(BstrToString(e.bstrDescription)) } src := "Unknown" if e.bstrSource != nil { src = BstrToString(e.bstrSource) } code := e.scode if e.wCode != 0 { code = uint32(e.wCode) } return fmt.Sprintf("%v: %#x", src, code)...
[ "func", "(", "e", "EXCEPINFO", ")", "Error", "(", ")", "string", "{", "if", "e", ".", "bstrDescription", "!=", "nil", "{", "return", "strings", ".", "TrimSpace", "(", "BstrToString", "(", "e", ".", "bstrDescription", ")", ")", "\n", "}", "\n\n", "src",...
// Error implements error interface and returns error string.
[ "Error", "implements", "error", "interface", "and", "returns", "error", "string", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/ole.go#L67-L83
19,407
go-ole/go-ole
idispatch.go
GetSingleIDOfName
func (v *IDispatch) GetSingleIDOfName(name string) (displayID int32, err error) { var displayIDs []int32 displayIDs, err = v.GetIDsOfName([]string{name}) if err != nil { return } displayID = displayIDs[0] return }
go
func (v *IDispatch) GetSingleIDOfName(name string) (displayID int32, err error) { var displayIDs []int32 displayIDs, err = v.GetIDsOfName([]string{name}) if err != nil { return } displayID = displayIDs[0] return }
[ "func", "(", "v", "*", "IDispatch", ")", "GetSingleIDOfName", "(", "name", "string", ")", "(", "displayID", "int32", ",", "err", "error", ")", "{", "var", "displayIDs", "[", "]", "int32", "\n", "displayIDs", ",", "err", "=", "v", ".", "GetIDsOfName", "...
// GetSingleIDOfName is a helper that returns single display ID for IDispatch name. // // This replaces the common pattern of attempting to get a single name from the list of available // IDs. It gives the first ID, if it is available.
[ "GetSingleIDOfName", "is", "a", "helper", "that", "returns", "single", "display", "ID", "for", "IDispatch", "name", ".", "This", "replaces", "the", "common", "pattern", "of", "attempting", "to", "get", "a", "single", "name", "from", "the", "list", "of", "ava...
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/idispatch.go#L45-L53
19,408
go-ole/go-ole
idispatch.go
InvokeWithOptionalArgs
func (v *IDispatch) InvokeWithOptionalArgs(name string, dispatch int16, params []interface{}) (result *VARIANT, err error) { displayID, err := v.GetSingleIDOfName(name) if err != nil { return } if len(params) < 1 { result, err = v.Invoke(displayID, dispatch) } else { result, err = v.Invoke(displayID, dispat...
go
func (v *IDispatch) InvokeWithOptionalArgs(name string, dispatch int16, params []interface{}) (result *VARIANT, err error) { displayID, err := v.GetSingleIDOfName(name) if err != nil { return } if len(params) < 1 { result, err = v.Invoke(displayID, dispatch) } else { result, err = v.Invoke(displayID, dispat...
[ "func", "(", "v", "*", "IDispatch", ")", "InvokeWithOptionalArgs", "(", "name", "string", ",", "dispatch", "int16", ",", "params", "[", "]", "interface", "{", "}", ")", "(", "result", "*", "VARIANT", ",", "err", "error", ")", "{", "displayID", ",", "er...
// InvokeWithOptionalArgs accepts arguments as an array, works like Invoke. // // Accepts name and will attempt to retrieve Display ID to pass to Invoke. // // Passing params as an array is a workaround that could be fixed in later versions of Go that // prevent passing empty params. During testing it was discovered th...
[ "InvokeWithOptionalArgs", "accepts", "arguments", "as", "an", "array", "works", "like", "Invoke", ".", "Accepts", "name", "and", "will", "attempt", "to", "retrieve", "Display", "ID", "to", "pass", "to", "Invoke", ".", "Passing", "params", "as", "an", "array", ...
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/idispatch.go#L62-L75
19,409
go-ole/go-ole
idispatch.go
CallMethod
func (v *IDispatch) CallMethod(name string, params ...interface{}) (*VARIANT, error) { return v.InvokeWithOptionalArgs(name, DISPATCH_METHOD, params) }
go
func (v *IDispatch) CallMethod(name string, params ...interface{}) (*VARIANT, error) { return v.InvokeWithOptionalArgs(name, DISPATCH_METHOD, params) }
[ "func", "(", "v", "*", "IDispatch", ")", "CallMethod", "(", "name", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "*", "VARIANT", ",", "error", ")", "{", "return", "v", ".", "InvokeWithOptionalArgs", "(", "name", ",", "DISPATCH_METHOD"...
// CallMethod invokes named function with arguments on object.
[ "CallMethod", "invokes", "named", "function", "with", "arguments", "on", "object", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/idispatch.go#L78-L80
19,410
go-ole/go-ole
idispatch.go
GetProperty
func (v *IDispatch) GetProperty(name string, params ...interface{}) (*VARIANT, error) { return v.InvokeWithOptionalArgs(name, DISPATCH_PROPERTYGET, params) }
go
func (v *IDispatch) GetProperty(name string, params ...interface{}) (*VARIANT, error) { return v.InvokeWithOptionalArgs(name, DISPATCH_PROPERTYGET, params) }
[ "func", "(", "v", "*", "IDispatch", ")", "GetProperty", "(", "name", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "*", "VARIANT", ",", "error", ")", "{", "return", "v", ".", "InvokeWithOptionalArgs", "(", "name", ",", "DISPATCH_PROPER...
// GetProperty retrieves the property with the name with the ability to pass arguments. // // Most of the time you will not need to pass arguments as most objects do not allow for this // feature. Or at least, should not allow for this feature. Some servers don't follow best practices // and this is provided for those ...
[ "GetProperty", "retrieves", "the", "property", "with", "the", "name", "with", "the", "ability", "to", "pass", "arguments", ".", "Most", "of", "the", "time", "you", "will", "not", "need", "to", "pass", "arguments", "as", "most", "objects", "do", "not", "all...
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/idispatch.go#L87-L89
19,411
go-ole/go-ole
idispatch.go
PutProperty
func (v *IDispatch) PutProperty(name string, params ...interface{}) (*VARIANT, error) { return v.InvokeWithOptionalArgs(name, DISPATCH_PROPERTYPUT, params) }
go
func (v *IDispatch) PutProperty(name string, params ...interface{}) (*VARIANT, error) { return v.InvokeWithOptionalArgs(name, DISPATCH_PROPERTYPUT, params) }
[ "func", "(", "v", "*", "IDispatch", ")", "PutProperty", "(", "name", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "*", "VARIANT", ",", "error", ")", "{", "return", "v", ".", "InvokeWithOptionalArgs", "(", "name", ",", "DISPATCH_PROPER...
// PutProperty attempts to mutate a property in the object.
[ "PutProperty", "attempts", "to", "mutate", "a", "property", "in", "the", "object", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/idispatch.go#L92-L94
19,412
go-ole/go-ole
connect.go
Create
func (c *Connection) Create(progId string) (err error) { var clsid *GUID clsid, err = CLSIDFromProgID(progId) if err != nil { clsid, err = CLSIDFromString(progId) if err != nil { return } } unknown, err := CreateInstance(clsid, IID_IUnknown) if err != nil { return } c.Object = unknown return }
go
func (c *Connection) Create(progId string) (err error) { var clsid *GUID clsid, err = CLSIDFromProgID(progId) if err != nil { clsid, err = CLSIDFromString(progId) if err != nil { return } } unknown, err := CreateInstance(clsid, IID_IUnknown) if err != nil { return } c.Object = unknown return }
[ "func", "(", "c", "*", "Connection", ")", "Create", "(", "progId", "string", ")", "(", "err", "error", ")", "{", "var", "clsid", "*", "GUID", "\n", "clsid", ",", "err", "=", "CLSIDFromProgID", "(", "progId", ")", "\n", "if", "err", "!=", "nil", "{"...
// Create IUnknown object based first on ProgId and then from String.
[ "Create", "IUnknown", "object", "based", "first", "on", "ProgId", "and", "then", "from", "String", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/connect.go#L21-L38
19,413
go-ole/go-ole
connect.go
Load
func (c *Connection) Load(names ...string) (errors []error) { var tempErrors []error = make([]error, len(names)) var numErrors int = 0 for _, name := range names { err := c.Create(name) if err != nil { tempErrors = append(tempErrors, err) numErrors += 1 continue } break } copy(errors, tempErrors[...
go
func (c *Connection) Load(names ...string) (errors []error) { var tempErrors []error = make([]error, len(names)) var numErrors int = 0 for _, name := range names { err := c.Create(name) if err != nil { tempErrors = append(tempErrors, err) numErrors += 1 continue } break } copy(errors, tempErrors[...
[ "func", "(", "c", "*", "Connection", ")", "Load", "(", "names", "...", "string", ")", "(", "errors", "[", "]", "error", ")", "{", "var", "tempErrors", "[", "]", "error", "=", "make", "(", "[", "]", "error", ",", "len", "(", "names", ")", ")", "...
// Load COM object from list of programIDs or strings.
[ "Load", "COM", "object", "from", "list", "of", "programIDs", "or", "strings", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/connect.go#L46-L61
19,414
go-ole/go-ole
connect.go
Dispatch
func (c *Connection) Dispatch() (object *Dispatch, err error) { dispatch, err := c.Object.QueryInterface(IID_IDispatch) if err != nil { return } object = &Dispatch{dispatch} return }
go
func (c *Connection) Dispatch() (object *Dispatch, err error) { dispatch, err := c.Object.QueryInterface(IID_IDispatch) if err != nil { return } object = &Dispatch{dispatch} return }
[ "func", "(", "c", "*", "Connection", ")", "Dispatch", "(", ")", "(", "object", "*", "Dispatch", ",", "err", "error", ")", "{", "dispatch", ",", "err", ":=", "c", ".", "Object", ".", "QueryInterface", "(", "IID_IDispatch", ")", "\n", "if", "err", "!="...
// Dispatch returns Dispatch object.
[ "Dispatch", "returns", "Dispatch", "object", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/connect.go#L64-L71
19,415
go-ole/go-ole
connect.go
Call
func (d *Dispatch) Call(method string, params ...interface{}) (result *VARIANT, err error) { id, err := d.GetId(method) if err != nil { return } result, err = d.Invoke(id, DISPATCH_METHOD, params) return }
go
func (d *Dispatch) Call(method string, params ...interface{}) (result *VARIANT, err error) { id, err := d.GetId(method) if err != nil { return } result, err = d.Invoke(id, DISPATCH_METHOD, params) return }
[ "func", "(", "d", "*", "Dispatch", ")", "Call", "(", "method", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "result", "*", "VARIANT", ",", "err", "error", ")", "{", "id", ",", "err", ":=", "d", ".", "GetId", "(", "method", ")"...
// Call method on IDispatch with parameters.
[ "Call", "method", "on", "IDispatch", "with", "parameters", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/connect.go#L79-L87
19,416
go-ole/go-ole
connect.go
MustCall
func (d *Dispatch) MustCall(method string, params ...interface{}) (result *VARIANT) { id, err := d.GetId(method) if err != nil { panic(err) } result, err = d.Invoke(id, DISPATCH_METHOD, params) if err != nil { panic(err) } return }
go
func (d *Dispatch) MustCall(method string, params ...interface{}) (result *VARIANT) { id, err := d.GetId(method) if err != nil { panic(err) } result, err = d.Invoke(id, DISPATCH_METHOD, params) if err != nil { panic(err) } return }
[ "func", "(", "d", "*", "Dispatch", ")", "MustCall", "(", "method", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "result", "*", "VARIANT", ")", "{", "id", ",", "err", ":=", "d", ".", "GetId", "(", "method", ")", "\n", "if", "er...
// MustCall method on IDispatch with parameters.
[ "MustCall", "method", "on", "IDispatch", "with", "parameters", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/connect.go#L90-L102
19,417
go-ole/go-ole
connect.go
Get
func (d *Dispatch) Get(name string, params ...interface{}) (result *VARIANT, err error) { id, err := d.GetId(name) if err != nil { return } result, err = d.Invoke(id, DISPATCH_PROPERTYGET, params) return }
go
func (d *Dispatch) Get(name string, params ...interface{}) (result *VARIANT, err error) { id, err := d.GetId(name) if err != nil { return } result, err = d.Invoke(id, DISPATCH_PROPERTYGET, params) return }
[ "func", "(", "d", "*", "Dispatch", ")", "Get", "(", "name", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "result", "*", "VARIANT", ",", "err", "error", ")", "{", "id", ",", "err", ":=", "d", ".", "GetId", "(", "name", ")", "...
// Get property on IDispatch with parameters.
[ "Get", "property", "on", "IDispatch", "with", "parameters", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/connect.go#L105-L112
19,418
go-ole/go-ole
connect.go
MustGet
func (d *Dispatch) MustGet(name string, params ...interface{}) (result *VARIANT) { id, err := d.GetId(name) if err != nil { panic(err) } result, err = d.Invoke(id, DISPATCH_PROPERTYGET, params) if err != nil { panic(err) } return }
go
func (d *Dispatch) MustGet(name string, params ...interface{}) (result *VARIANT) { id, err := d.GetId(name) if err != nil { panic(err) } result, err = d.Invoke(id, DISPATCH_PROPERTYGET, params) if err != nil { panic(err) } return }
[ "func", "(", "d", "*", "Dispatch", ")", "MustGet", "(", "name", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "result", "*", "VARIANT", ")", "{", "id", ",", "err", ":=", "d", ".", "GetId", "(", "name", ")", "\n", "if", "err", ...
// MustGet property on IDispatch with parameters.
[ "MustGet", "property", "on", "IDispatch", "with", "parameters", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/connect.go#L115-L126
19,419
go-ole/go-ole
connect.go
Set
func (d *Dispatch) Set(name string, params ...interface{}) (result *VARIANT, err error) { id, err := d.GetId(name) if err != nil { return } result, err = d.Invoke(id, DISPATCH_PROPERTYPUT, params) return }
go
func (d *Dispatch) Set(name string, params ...interface{}) (result *VARIANT, err error) { id, err := d.GetId(name) if err != nil { return } result, err = d.Invoke(id, DISPATCH_PROPERTYPUT, params) return }
[ "func", "(", "d", "*", "Dispatch", ")", "Set", "(", "name", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "result", "*", "VARIANT", ",", "err", "error", ")", "{", "id", ",", "err", ":=", "d", ".", "GetId", "(", "name", ")", "...
// Set property on IDispatch with parameters.
[ "Set", "property", "on", "IDispatch", "with", "parameters", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/connect.go#L129-L136
19,420
go-ole/go-ole
connect.go
MustSet
func (d *Dispatch) MustSet(name string, params ...interface{}) (result *VARIANT) { id, err := d.GetId(name) if err != nil { panic(err) } result, err = d.Invoke(id, DISPATCH_PROPERTYPUT, params) if err != nil { panic(err) } return }
go
func (d *Dispatch) MustSet(name string, params ...interface{}) (result *VARIANT) { id, err := d.GetId(name) if err != nil { panic(err) } result, err = d.Invoke(id, DISPATCH_PROPERTYPUT, params) if err != nil { panic(err) } return }
[ "func", "(", "d", "*", "Dispatch", ")", "MustSet", "(", "name", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "result", "*", "VARIANT", ")", "{", "id", ",", "err", ":=", "d", ".", "GetId", "(", "name", ")", "\n", "if", "err", ...
// MustSet property on IDispatch with parameters.
[ "MustSet", "property", "on", "IDispatch", "with", "parameters", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/connect.go#L139-L150
19,421
go-ole/go-ole
connect.go
GetId
func (d *Dispatch) GetId(name string) (id int32, err error) { var dispid []int32 dispid, err = d.Object.GetIDsOfName([]string{name}) if err != nil { return } id = dispid[0] return }
go
func (d *Dispatch) GetId(name string) (id int32, err error) { var dispid []int32 dispid, err = d.Object.GetIDsOfName([]string{name}) if err != nil { return } id = dispid[0] return }
[ "func", "(", "d", "*", "Dispatch", ")", "GetId", "(", "name", "string", ")", "(", "id", "int32", ",", "err", "error", ")", "{", "var", "dispid", "[", "]", "int32", "\n", "dispid", ",", "err", "=", "d", ".", "Object", ".", "GetIDsOfName", "(", "["...
// GetId retrieves ID of name on IDispatch.
[ "GetId", "retrieves", "ID", "of", "name", "on", "IDispatch", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/connect.go#L153-L161
19,422
go-ole/go-ole
connect.go
GetIds
func (d *Dispatch) GetIds(names ...string) (dispid []int32, err error) { dispid, err = d.Object.GetIDsOfName(names) return }
go
func (d *Dispatch) GetIds(names ...string) (dispid []int32, err error) { dispid, err = d.Object.GetIDsOfName(names) return }
[ "func", "(", "d", "*", "Dispatch", ")", "GetIds", "(", "names", "...", "string", ")", "(", "dispid", "[", "]", "int32", ",", "err", "error", ")", "{", "dispid", ",", "err", "=", "d", ".", "Object", ".", "GetIDsOfName", "(", "names", ")", "\n", "r...
// GetIds retrieves all IDs of names on IDispatch.
[ "GetIds", "retrieves", "all", "IDs", "of", "names", "on", "IDispatch", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/connect.go#L164-L167
19,423
go-ole/go-ole
connect.go
Invoke
func (d *Dispatch) Invoke(id int32, dispatch int16, params []interface{}) (result *VARIANT, err error) { if len(params) < 1 { result, err = d.Object.Invoke(id, dispatch) } else { result, err = d.Object.Invoke(id, dispatch, params...) } return }
go
func (d *Dispatch) Invoke(id int32, dispatch int16, params []interface{}) (result *VARIANT, err error) { if len(params) < 1 { result, err = d.Object.Invoke(id, dispatch) } else { result, err = d.Object.Invoke(id, dispatch, params...) } return }
[ "func", "(", "d", "*", "Dispatch", ")", "Invoke", "(", "id", "int32", ",", "dispatch", "int16", ",", "params", "[", "]", "interface", "{", "}", ")", "(", "result", "*", "VARIANT", ",", "err", "error", ")", "{", "if", "len", "(", "params", ")", "<...
// Invoke IDispatch on DisplayID of dispatch type with parameters. // // There have been problems where if send cascading params..., it would error // out because the parameters would be empty.
[ "Invoke", "IDispatch", "on", "DisplayID", "of", "dispatch", "type", "with", "parameters", ".", "There", "have", "been", "problems", "where", "if", "send", "cascading", "params", "...", "it", "would", "error", "out", "because", "the", "parameters", "would", "be...
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/connect.go#L173-L180
19,424
go-ole/go-ole
connect.go
Connect
func Connect(names ...string) (connection *Connection) { connection.Initialize() connection.Load(names...) return }
go
func Connect(names ...string) (connection *Connection) { connection.Initialize() connection.Load(names...) return }
[ "func", "Connect", "(", "names", "...", "string", ")", "(", "connection", "*", "Connection", ")", "{", "connection", ".", "Initialize", "(", ")", "\n", "connection", ".", "Load", "(", "names", "...", ")", "\n", "return", "\n", "}" ]
// Connect initializes COM and attempts to load IUnknown based on given names.
[ "Connect", "initializes", "COM", "and", "attempts", "to", "load", "IUnknown", "based", "on", "given", "names", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/connect.go#L188-L192
19,425
go-ole/go-ole
safearray_windows.go
safeArrayGetElementString
func safeArrayGetElementString(safearray *SafeArray, index int32) (str string, err error) { var element *int16 err = convertHresultToError( procSafeArrayGetElement.Call( uintptr(unsafe.Pointer(safearray)), uintptr(unsafe.Pointer(&index)), uintptr(unsafe.Pointer(&element)))) str = BstrToString(*(**uint16)(...
go
func safeArrayGetElementString(safearray *SafeArray, index int32) (str string, err error) { var element *int16 err = convertHresultToError( procSafeArrayGetElement.Call( uintptr(unsafe.Pointer(safearray)), uintptr(unsafe.Pointer(&index)), uintptr(unsafe.Pointer(&element)))) str = BstrToString(*(**uint16)(...
[ "func", "safeArrayGetElementString", "(", "safearray", "*", "SafeArray", ",", "index", "int32", ")", "(", "str", "string", ",", "err", "error", ")", "{", "var", "element", "*", "int16", "\n", "err", "=", "convertHresultToError", "(", "procSafeArrayGetElement", ...
// safeArrayGetElementString retrieves element at given index and converts to string.
[ "safeArrayGetElementString", "retrieves", "element", "at", "given", "index", "and", "converts", "to", "string", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/safearray_windows.go#L217-L227
19,426
go-ole/go-ole
utility.go
ClassIDFrom
func ClassIDFrom(programID string) (classID *GUID, err error) { classID, err = CLSIDFromProgID(programID) if err != nil { classID, err = CLSIDFromString(programID) if err != nil { return } } return }
go
func ClassIDFrom(programID string) (classID *GUID, err error) { classID, err = CLSIDFromProgID(programID) if err != nil { classID, err = CLSIDFromString(programID) if err != nil { return } } return }
[ "func", "ClassIDFrom", "(", "programID", "string", ")", "(", "classID", "*", "GUID", ",", "err", "error", ")", "{", "classID", ",", "err", "=", "CLSIDFromProgID", "(", "programID", ")", "\n", "if", "err", "!=", "nil", "{", "classID", ",", "err", "=", ...
// ClassIDFrom retrieves class ID whether given is program ID or application string. // // Helper that provides check against both Class ID from Program ID and Class ID from string. It is // faster, if you know which you are using, to use the individual functions, but this will check // against available functions for ...
[ "ClassIDFrom", "retrieves", "class", "ID", "whether", "given", "is", "program", "ID", "or", "application", "string", ".", "Helper", "that", "provides", "check", "against", "both", "Class", "ID", "from", "Program", "ID", "and", "Class", "ID", "from", "string", ...
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/utility.go#L13-L22
19,427
go-ole/go-ole
utility.go
BytePtrToString
func BytePtrToString(p *byte) string { a := (*[10000]uint8)(unsafe.Pointer(p)) i := 0 for a[i] != 0 { i++ } return string(a[:i]) }
go
func BytePtrToString(p *byte) string { a := (*[10000]uint8)(unsafe.Pointer(p)) i := 0 for a[i] != 0 { i++ } return string(a[:i]) }
[ "func", "BytePtrToString", "(", "p", "*", "byte", ")", "string", "{", "a", ":=", "(", "*", "[", "10000", "]", "uint8", ")", "(", "unsafe", ".", "Pointer", "(", "p", ")", ")", "\n", "i", ":=", "0", "\n", "for", "a", "[", "i", "]", "!=", "0", ...
// BytePtrToString converts byte pointer to a Go string.
[ "BytePtrToString", "converts", "byte", "pointer", "to", "a", "Go", "string", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/utility.go#L25-L32
19,428
go-ole/go-ole
utility.go
LpOleStrToString
func LpOleStrToString(p *uint16) string { if p == nil { return "" } length := lpOleStrLen(p) a := make([]uint16, length) ptr := unsafe.Pointer(p) for i := 0; i < int(length); i++ { a[i] = *(*uint16)(ptr) ptr = unsafe.Pointer(uintptr(ptr) + 2) } return string(utf16.Decode(a)) }
go
func LpOleStrToString(p *uint16) string { if p == nil { return "" } length := lpOleStrLen(p) a := make([]uint16, length) ptr := unsafe.Pointer(p) for i := 0; i < int(length); i++ { a[i] = *(*uint16)(ptr) ptr = unsafe.Pointer(uintptr(ptr) + 2) } return string(utf16.Decode(a)) }
[ "func", "LpOleStrToString", "(", "p", "*", "uint16", ")", "string", "{", "if", "p", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n\n", "length", ":=", "lpOleStrLen", "(", "p", ")", "\n", "a", ":=", "make", "(", "[", "]", "uint16", ",", "l...
// LpOleStrToString converts COM Unicode to Go string.
[ "LpOleStrToString", "converts", "COM", "Unicode", "to", "Go", "string", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/utility.go#L42-L58
19,429
go-ole/go-ole
utility.go
BstrToString
func BstrToString(p *uint16) string { if p == nil { return "" } length := SysStringLen((*int16)(unsafe.Pointer(p))) a := make([]uint16, length) ptr := unsafe.Pointer(p) for i := 0; i < int(length); i++ { a[i] = *(*uint16)(ptr) ptr = unsafe.Pointer(uintptr(ptr) + 2) } return string(utf16.Decode(a)) }
go
func BstrToString(p *uint16) string { if p == nil { return "" } length := SysStringLen((*int16)(unsafe.Pointer(p))) a := make([]uint16, length) ptr := unsafe.Pointer(p) for i := 0; i < int(length); i++ { a[i] = *(*uint16)(ptr) ptr = unsafe.Pointer(uintptr(ptr) + 2) } return string(utf16.Decode(a)) }
[ "func", "BstrToString", "(", "p", "*", "uint16", ")", "string", "{", "if", "p", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "length", ":=", "SysStringLen", "(", "(", "*", "int16", ")", "(", "unsafe", ".", "Pointer", "(", "p", ")", ")...
// BstrToString converts COM binary string to Go string.
[ "BstrToString", "converts", "COM", "binary", "string", "to", "Go", "string", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/utility.go#L61-L75
19,430
go-ole/go-ole
utility.go
lpOleStrLen
func lpOleStrLen(p *uint16) (length int64) { if p == nil { return 0 } ptr := unsafe.Pointer(p) for i := 0; ; i++ { if 0 == *(*uint16)(ptr) { length = int64(i) break } ptr = unsafe.Pointer(uintptr(ptr) + 2) } return }
go
func lpOleStrLen(p *uint16) (length int64) { if p == nil { return 0 } ptr := unsafe.Pointer(p) for i := 0; ; i++ { if 0 == *(*uint16)(ptr) { length = int64(i) break } ptr = unsafe.Pointer(uintptr(ptr) + 2) } return }
[ "func", "lpOleStrLen", "(", "p", "*", "uint16", ")", "(", "length", "int64", ")", "{", "if", "p", "==", "nil", "{", "return", "0", "\n", "}", "\n\n", "ptr", ":=", "unsafe", ".", "Pointer", "(", "p", ")", "\n\n", "for", "i", ":=", "0", ";", ";",...
// lpOleStrLen returns the length of Unicode string.
[ "lpOleStrLen", "returns", "the", "length", "of", "Unicode", "string", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/utility.go#L78-L93
19,431
go-ole/go-ole
utility.go
convertHresultToError
func convertHresultToError(hr uintptr, r2 uintptr, ignore error) (err error) { if hr != 0 { err = NewError(hr) } return }
go
func convertHresultToError(hr uintptr, r2 uintptr, ignore error) (err error) { if hr != 0 { err = NewError(hr) } return }
[ "func", "convertHresultToError", "(", "hr", "uintptr", ",", "r2", "uintptr", ",", "ignore", "error", ")", "(", "err", "error", ")", "{", "if", "hr", "!=", "0", "{", "err", "=", "NewError", "(", "hr", ")", "\n", "}", "\n", "return", "\n", "}" ]
// convertHresultToError converts syscall to error, if call is unsuccessful.
[ "convertHresultToError", "converts", "syscall", "to", "error", "if", "call", "is", "unsuccessful", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/utility.go#L96-L101
19,432
go-ole/go-ole
error_windows.go
errstr
func errstr(errno int) string { // ask windows for the remaining errors var flags uint32 = syscall.FORMAT_MESSAGE_FROM_SYSTEM | syscall.FORMAT_MESSAGE_ARGUMENT_ARRAY | syscall.FORMAT_MESSAGE_IGNORE_INSERTS b := make([]uint16, 300) n, err := syscall.FormatMessage(flags, 0, uint32(errno), 0, b, nil) if err != nil { ...
go
func errstr(errno int) string { // ask windows for the remaining errors var flags uint32 = syscall.FORMAT_MESSAGE_FROM_SYSTEM | syscall.FORMAT_MESSAGE_ARGUMENT_ARRAY | syscall.FORMAT_MESSAGE_IGNORE_INSERTS b := make([]uint16, 300) n, err := syscall.FormatMessage(flags, 0, uint32(errno), 0, b, nil) if err != nil { ...
[ "func", "errstr", "(", "errno", "int", ")", "string", "{", "// ask windows for the remaining errors", "var", "flags", "uint32", "=", "syscall", ".", "FORMAT_MESSAGE_FROM_SYSTEM", "|", "syscall", ".", "FORMAT_MESSAGE_ARGUMENT_ARRAY", "|", "syscall", ".", "FORMAT_MESSAGE_...
// errstr converts error code to string.
[ "errstr", "converts", "error", "code", "to", "string", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/error_windows.go#L12-L24
19,433
go-ole/go-ole
_example/libreoffice/libreoffice.go
LOGetCellString
func LOGetCellString(cell *ole.IDispatch) (value string) { return oleutil.MustGetProperty(cell, "string").ToString() }
go
func LOGetCellString(cell *ole.IDispatch) (value string) { return oleutil.MustGetProperty(cell, "string").ToString() }
[ "func", "LOGetCellString", "(", "cell", "*", "ole", ".", "IDispatch", ")", "(", "value", "string", ")", "{", "return", "oleutil", ".", "MustGetProperty", "(", "cell", ",", "\"", "\"", ")", ".", "ToString", "(", ")", "\n", "}" ]
// LOGetCellString returns the displayed value
[ "LOGetCellString", "returns", "the", "displayed", "value" ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/_example/libreoffice/libreoffice.go#L63-L65
19,434
go-ole/go-ole
_example/libreoffice/libreoffice.go
LOSetCellString
func LOSetCellString(cell *ole.IDispatch, text string) { oleutil.MustPutProperty(cell, "string", text) }
go
func LOSetCellString(cell *ole.IDispatch, text string) { oleutil.MustPutProperty(cell, "string", text) }
[ "func", "LOSetCellString", "(", "cell", "*", "ole", ".", "IDispatch", ",", "text", "string", ")", "{", "oleutil", ".", "MustPutProperty", "(", "cell", ",", "\"", "\"", ",", "text", ")", "\n", "}" ]
// LOSetCellString sets the text value of a cell
[ "LOSetCellString", "sets", "the", "text", "value", "of", "a", "cell" ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/_example/libreoffice/libreoffice.go#L80-L82
19,435
go-ole/go-ole
_example/libreoffice/libreoffice.go
LOSetCellValue
func LOSetCellValue(cell *ole.IDispatch, value float64) { oleutil.MustPutProperty(cell, "value", value) }
go
func LOSetCellValue(cell *ole.IDispatch, value float64) { oleutil.MustPutProperty(cell, "value", value) }
[ "func", "LOSetCellValue", "(", "cell", "*", "ole", ".", "IDispatch", ",", "value", "float64", ")", "{", "oleutil", ".", "MustPutProperty", "(", "cell", ",", "\"", "\"", ",", "value", ")", "\n", "}" ]
// LOSetCellValue sets the numeric value of a cell
[ "LOSetCellValue", "sets", "the", "numeric", "value", "of", "a", "cell" ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/_example/libreoffice/libreoffice.go#L85-L87
19,436
go-ole/go-ole
_example/libreoffice/libreoffice.go
LONewSpreadsheet
func LONewSpreadsheet(desktop *ole.IDispatch) (document *ole.IDispatch) { var args = []string{} document = oleutil.MustCallMethod(desktop, "loadComponentFromURL", "private:factory/scalc", // alternative: private:factory/swriter "_blank", 0, args).ToIDispatch() return }
go
func LONewSpreadsheet(desktop *ole.IDispatch) (document *ole.IDispatch) { var args = []string{} document = oleutil.MustCallMethod(desktop, "loadComponentFromURL", "private:factory/scalc", // alternative: private:factory/swriter "_blank", 0, args).ToIDispatch() return }
[ "func", "LONewSpreadsheet", "(", "desktop", "*", "ole", ".", "IDispatch", ")", "(", "document", "*", "ole", ".", "IDispatch", ")", "{", "var", "args", "=", "[", "]", "string", "{", "}", "\n", "document", "=", "oleutil", ".", "MustCallMethod", "(", "des...
// LONewSpreadsheet creates a new spreadsheet in a new window and returns a document handle.
[ "LONewSpreadsheet", "creates", "a", "new", "spreadsheet", "in", "a", "new", "window", "and", "returns", "a", "document", "handle", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/_example/libreoffice/libreoffice.go#L100-L106
19,437
go-ole/go-ole
_example/libreoffice/libreoffice.go
main
func main() { ole.CoInitialize(0) unknown, errCreate := oleutil.CreateObject("com.sun.star.ServiceManager") checkError(errCreate, "Couldn't create a OLE connection to LibreOffice") ServiceManager, errSM := unknown.QueryInterface(ole.IID_IDispatch) checkError(errSM, "Couldn't start a LibreOffice instance") desktop...
go
func main() { ole.CoInitialize(0) unknown, errCreate := oleutil.CreateObject("com.sun.star.ServiceManager") checkError(errCreate, "Couldn't create a OLE connection to LibreOffice") ServiceManager, errSM := unknown.QueryInterface(ole.IID_IDispatch) checkError(errSM, "Couldn't start a LibreOffice instance") desktop...
[ "func", "main", "(", ")", "{", "ole", ".", "CoInitialize", "(", "0", ")", "\n", "unknown", ",", "errCreate", ":=", "oleutil", ".", "CreateObject", "(", "\"", "\"", ")", "\n", "checkError", "(", "errCreate", ",", "\"", "\"", ")", "\n", "ServiceManager",...
// This example creates a new spreadsheet, reads and modifies cell values and style.
[ "This", "example", "creates", "a", "new", "spreadsheet", "reads", "and", "modifies", "cell", "values", "and", "style", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/_example/libreoffice/libreoffice.go#L134-L162
19,438
go-ole/go-ole
error.go
NewErrorWithDescription
func NewErrorWithDescription(hr uintptr, description string) *OleError { return &OleError{hr: hr, description: description} }
go
func NewErrorWithDescription(hr uintptr, description string) *OleError { return &OleError{hr: hr, description: description} }
[ "func", "NewErrorWithDescription", "(", "hr", "uintptr", ",", "description", "string", ")", "*", "OleError", "{", "return", "&", "OleError", "{", "hr", ":", "hr", ",", "description", ":", "description", "}", "\n", "}" ]
// NewErrorWithDescription creates new COM error with HResult and description.
[ "NewErrorWithDescription", "creates", "new", "COM", "error", "with", "HResult", "and", "description", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/error.go#L16-L18
19,439
go-ole/go-ole
error.go
NewErrorWithSubError
func NewErrorWithSubError(hr uintptr, description string, err error) *OleError { return &OleError{hr: hr, description: description, subError: err} }
go
func NewErrorWithSubError(hr uintptr, description string, err error) *OleError { return &OleError{hr: hr, description: description, subError: err} }
[ "func", "NewErrorWithSubError", "(", "hr", "uintptr", ",", "description", "string", ",", "err", "error", ")", "*", "OleError", "{", "return", "&", "OleError", "{", "hr", ":", "hr", ",", "description", ":", "description", ",", "subError", ":", "err", "}", ...
// NewErrorWithSubError creates new COM error with parent error.
[ "NewErrorWithSubError", "creates", "new", "COM", "error", "with", "parent", "error", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/error.go#L21-L23
19,440
go-ole/go-ole
error.go
String
func (v *OleError) String() string { if v.description != "" { return errstr(int(v.hr)) + " (" + v.description + ")" } return errstr(int(v.hr)) }
go
func (v *OleError) String() string { if v.description != "" { return errstr(int(v.hr)) + " (" + v.description + ")" } return errstr(int(v.hr)) }
[ "func", "(", "v", "*", "OleError", ")", "String", "(", ")", "string", "{", "if", "v", ".", "description", "!=", "\"", "\"", "{", "return", "errstr", "(", "int", "(", "v", ".", "hr", ")", ")", "+", "\"", "\"", "+", "v", ".", "description", "+", ...
// String description, either manually set or format message with error code.
[ "String", "description", "either", "manually", "set", "or", "format", "message", "with", "error", "code", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/error.go#L31-L36
19,441
go-ole/go-ole
winrt.go
DeleteHString
func DeleteHString(hstring HString) (err error) { hr, _, _ := procWindowsDeleteString.Call(uintptr(hstring)) if hr != 0 { err = NewError(hr) } return }
go
func DeleteHString(hstring HString) (err error) { hr, _, _ := procWindowsDeleteString.Call(uintptr(hstring)) if hr != 0 { err = NewError(hr) } return }
[ "func", "DeleteHString", "(", "hstring", "HString", ")", "(", "err", "error", ")", "{", "hr", ",", "_", ",", "_", ":=", "procWindowsDeleteString", ".", "Call", "(", "uintptr", "(", "hstring", ")", ")", "\n", "if", "hr", "!=", "0", "{", "err", "=", ...
// DeleteHString deletes HString.
[ "DeleteHString", "deletes", "HString", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/winrt.go#L80-L86
19,442
go-ole/go-ole
winrt.go
String
func (h HString) String() string { var u16buf uintptr var u16len uint32 u16buf, _, _ = procWindowsGetStringRawBuffer.Call( uintptr(h), uintptr(unsafe.Pointer(&u16len))) u16hdr := reflect.SliceHeader{Data: u16buf, Len: int(u16len), Cap: int(u16len)} u16 := *(*[]uint16)(unsafe.Pointer(&u16hdr)) return syscall....
go
func (h HString) String() string { var u16buf uintptr var u16len uint32 u16buf, _, _ = procWindowsGetStringRawBuffer.Call( uintptr(h), uintptr(unsafe.Pointer(&u16len))) u16hdr := reflect.SliceHeader{Data: u16buf, Len: int(u16len), Cap: int(u16len)} u16 := *(*[]uint16)(unsafe.Pointer(&u16hdr)) return syscall....
[ "func", "(", "h", "HString", ")", "String", "(", ")", "string", "{", "var", "u16buf", "uintptr", "\n", "var", "u16len", "uint32", "\n", "u16buf", ",", "_", ",", "_", "=", "procWindowsGetStringRawBuffer", ".", "Call", "(", "uintptr", "(", "h", ")", ",",...
// String returns Go string value of HString.
[ "String", "returns", "Go", "string", "value", "of", "HString", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/winrt.go#L89-L99
19,443
go-ole/go-ole
oleutil/oleutil.go
ClassIDFrom
func ClassIDFrom(programID string) (classID *ole.GUID, err error) { return ole.ClassIDFrom(programID) }
go
func ClassIDFrom(programID string) (classID *ole.GUID, err error) { return ole.ClassIDFrom(programID) }
[ "func", "ClassIDFrom", "(", "programID", "string", ")", "(", "classID", "*", "ole", ".", "GUID", ",", "err", "error", ")", "{", "return", "ole", ".", "ClassIDFrom", "(", "programID", ")", "\n", "}" ]
// ClassIDFrom retrieves class ID whether given is program ID or application string.
[ "ClassIDFrom", "retrieves", "class", "ID", "whether", "given", "is", "program", "ID", "or", "application", "string", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/oleutil/oleutil.go#L6-L8
19,444
go-ole/go-ole
oleutil/oleutil.go
CreateObject
func CreateObject(programID string) (unknown *ole.IUnknown, err error) { classID, err := ole.ClassIDFrom(programID) if err != nil { return } unknown, err = ole.CreateInstance(classID, ole.IID_IUnknown) if err != nil { return } return }
go
func CreateObject(programID string) (unknown *ole.IUnknown, err error) { classID, err := ole.ClassIDFrom(programID) if err != nil { return } unknown, err = ole.CreateInstance(classID, ole.IID_IUnknown) if err != nil { return } return }
[ "func", "CreateObject", "(", "programID", "string", ")", "(", "unknown", "*", "ole", ".", "IUnknown", ",", "err", "error", ")", "{", "classID", ",", "err", ":=", "ole", ".", "ClassIDFrom", "(", "programID", ")", "\n", "if", "err", "!=", "nil", "{", "...
// CreateObject creates object from programID based on interface type. // // Only supports IUnknown. // // Program ID can be either program ID or application string.
[ "CreateObject", "creates", "object", "from", "programID", "based", "on", "interface", "type", ".", "Only", "supports", "IUnknown", ".", "Program", "ID", "can", "be", "either", "program", "ID", "or", "application", "string", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/oleutil/oleutil.go#L15-L27
19,445
go-ole/go-ole
oleutil/oleutil.go
GetActiveObject
func GetActiveObject(programID string) (unknown *ole.IUnknown, err error) { classID, err := ole.ClassIDFrom(programID) if err != nil { return } unknown, err = ole.GetActiveObject(classID, ole.IID_IUnknown) if err != nil { return } return }
go
func GetActiveObject(programID string) (unknown *ole.IUnknown, err error) { classID, err := ole.ClassIDFrom(programID) if err != nil { return } unknown, err = ole.GetActiveObject(classID, ole.IID_IUnknown) if err != nil { return } return }
[ "func", "GetActiveObject", "(", "programID", "string", ")", "(", "unknown", "*", "ole", ".", "IUnknown", ",", "err", "error", ")", "{", "classID", ",", "err", ":=", "ole", ".", "ClassIDFrom", "(", "programID", ")", "\n", "if", "err", "!=", "nil", "{", ...
// GetActiveObject retrieves active object for program ID and interface ID based // on interface type. // // Only supports IUnknown. // // Program ID can be either program ID or application string.
[ "GetActiveObject", "retrieves", "active", "object", "for", "program", "ID", "and", "interface", "ID", "based", "on", "interface", "type", ".", "Only", "supports", "IUnknown", ".", "Program", "ID", "can", "be", "either", "program", "ID", "or", "application", "s...
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/oleutil/oleutil.go#L35-L47
19,446
go-ole/go-ole
oleutil/oleutil.go
CallMethod
func CallMethod(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_METHOD, params) }
go
func CallMethod(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_METHOD, params) }
[ "func", "CallMethod", "(", "disp", "*", "ole", ".", "IDispatch", ",", "name", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "result", "*", "ole", ".", "VARIANT", ",", "err", "error", ")", "{", "return", "disp", ".", "InvokeWithOption...
// CallMethod calls method on IDispatch with parameters.
[ "CallMethod", "calls", "method", "on", "IDispatch", "with", "parameters", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/oleutil/oleutil.go#L50-L52
19,447
go-ole/go-ole
oleutil/oleutil.go
MustCallMethod
func MustCallMethod(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { r, err := CallMethod(disp, name, params...) if err != nil { panic(err.Error()) } return r }
go
func MustCallMethod(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { r, err := CallMethod(disp, name, params...) if err != nil { panic(err.Error()) } return r }
[ "func", "MustCallMethod", "(", "disp", "*", "ole", ".", "IDispatch", ",", "name", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "result", "*", "ole", ".", "VARIANT", ")", "{", "r", ",", "err", ":=", "CallMethod", "(", "disp", ",", ...
// MustCallMethod calls method on IDispatch with parameters or panics.
[ "MustCallMethod", "calls", "method", "on", "IDispatch", "with", "parameters", "or", "panics", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/oleutil/oleutil.go#L55-L61
19,448
go-ole/go-ole
oleutil/oleutil.go
GetProperty
func GetProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYGET, params) }
go
func GetProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYGET, params) }
[ "func", "GetProperty", "(", "disp", "*", "ole", ".", "IDispatch", ",", "name", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "result", "*", "ole", ".", "VARIANT", ",", "err", "error", ")", "{", "return", "disp", ".", "InvokeWithOptio...
// GetProperty retrieves property from IDispatch.
[ "GetProperty", "retrieves", "property", "from", "IDispatch", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/oleutil/oleutil.go#L64-L66
19,449
go-ole/go-ole
oleutil/oleutil.go
MustGetProperty
func MustGetProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { r, err := GetProperty(disp, name, params...) if err != nil { panic(err.Error()) } return r }
go
func MustGetProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { r, err := GetProperty(disp, name, params...) if err != nil { panic(err.Error()) } return r }
[ "func", "MustGetProperty", "(", "disp", "*", "ole", ".", "IDispatch", ",", "name", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "result", "*", "ole", ".", "VARIANT", ")", "{", "r", ",", "err", ":=", "GetProperty", "(", "disp", ","...
// MustGetProperty retrieves property from IDispatch or panics.
[ "MustGetProperty", "retrieves", "property", "from", "IDispatch", "or", "panics", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/oleutil/oleutil.go#L69-L75
19,450
go-ole/go-ole
oleutil/oleutil.go
PutProperty
func PutProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYPUT, params) }
go
func PutProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYPUT, params) }
[ "func", "PutProperty", "(", "disp", "*", "ole", ".", "IDispatch", ",", "name", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "result", "*", "ole", ".", "VARIANT", ",", "err", "error", ")", "{", "return", "disp", ".", "InvokeWithOptio...
// PutProperty mutates property.
[ "PutProperty", "mutates", "property", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/oleutil/oleutil.go#L78-L80
19,451
go-ole/go-ole
oleutil/oleutil.go
MustPutProperty
func MustPutProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { r, err := PutProperty(disp, name, params...) if err != nil { panic(err.Error()) } return r }
go
func MustPutProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { r, err := PutProperty(disp, name, params...) if err != nil { panic(err.Error()) } return r }
[ "func", "MustPutProperty", "(", "disp", "*", "ole", ".", "IDispatch", ",", "name", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "result", "*", "ole", ".", "VARIANT", ")", "{", "r", ",", "err", ":=", "PutProperty", "(", "disp", ","...
// MustPutProperty mutates property or panics.
[ "MustPutProperty", "mutates", "property", "or", "panics", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/oleutil/oleutil.go#L83-L89
19,452
go-ole/go-ole
oleutil/oleutil.go
PutPropertyRef
func PutPropertyRef(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYPUTREF, params) }
go
func PutPropertyRef(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYPUTREF, params) }
[ "func", "PutPropertyRef", "(", "disp", "*", "ole", ".", "IDispatch", ",", "name", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "result", "*", "ole", ".", "VARIANT", ",", "err", "error", ")", "{", "return", "disp", ".", "InvokeWithOp...
// PutPropertyRef mutates property reference.
[ "PutPropertyRef", "mutates", "property", "reference", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/oleutil/oleutil.go#L92-L94
19,453
go-ole/go-ole
oleutil/oleutil.go
MustPutPropertyRef
func MustPutPropertyRef(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { r, err := PutPropertyRef(disp, name, params...) if err != nil { panic(err.Error()) } return r }
go
func MustPutPropertyRef(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { r, err := PutPropertyRef(disp, name, params...) if err != nil { panic(err.Error()) } return r }
[ "func", "MustPutPropertyRef", "(", "disp", "*", "ole", ".", "IDispatch", ",", "name", "string", ",", "params", "...", "interface", "{", "}", ")", "(", "result", "*", "ole", ".", "VARIANT", ")", "{", "r", ",", "err", ":=", "PutPropertyRef", "(", "disp",...
// MustPutPropertyRef mutates property reference or panics.
[ "MustPutPropertyRef", "mutates", "property", "reference", "or", "panics", "." ]
97b6244175ae18ea6eef668034fd6565847501c9
https://github.com/go-ole/go-ole/blob/97b6244175ae18ea6eef668034fd6565847501c9/oleutil/oleutil.go#L97-L103
19,454
kevin-cantwell/dotmatrix
gif.go
drawOver
func (p *GIFPrinter) drawOver(target *image.Paletted, source image.Image) { bounds := source.Bounds() for y := bounds.Min.Y; y < bounds.Max.Y; y++ { for x := bounds.Min.X; x < bounds.Max.X; x++ { c := source.At(x, y) if c == color.Transparent { continue } target.Set(x, y, c) } } }
go
func (p *GIFPrinter) drawOver(target *image.Paletted, source image.Image) { bounds := source.Bounds() for y := bounds.Min.Y; y < bounds.Max.Y; y++ { for x := bounds.Min.X; x < bounds.Max.X; x++ { c := source.At(x, y) if c == color.Transparent { continue } target.Set(x, y, c) } } }
[ "func", "(", "p", "*", "GIFPrinter", ")", "drawOver", "(", "target", "*", "image", ".", "Paletted", ",", "source", "image", ".", "Image", ")", "{", "bounds", ":=", "source", ".", "Bounds", "(", ")", "\n", "for", "y", ":=", "bounds", ".", "Min", "."...
// Draws any non-transparent pixels into target
[ "Draws", "any", "non", "-", "transparent", "pixels", "into", "target" ]
d70fba7c1676bb77b7d5813b9a436c36562839ed
https://github.com/kevin-cantwell/dotmatrix/blob/d70fba7c1676bb77b7d5813b9a436c36562839ed/gif.go#L117-L128
19,455
kevin-cantwell/dotmatrix
gif.go
drawExact
func (p *GIFPrinter) drawExact(target *image.Paletted, source image.Image) { bounds := source.Bounds() for y := bounds.Min.Y; y < bounds.Max.Y; y++ { for x := bounds.Min.X; x < bounds.Max.X; x++ { target.Set(x, y, source.At(x, y)) } } }
go
func (p *GIFPrinter) drawExact(target *image.Paletted, source image.Image) { bounds := source.Bounds() for y := bounds.Min.Y; y < bounds.Max.Y; y++ { for x := bounds.Min.X; x < bounds.Max.X; x++ { target.Set(x, y, source.At(x, y)) } } }
[ "func", "(", "p", "*", "GIFPrinter", ")", "drawExact", "(", "target", "*", "image", ".", "Paletted", ",", "source", "image", ".", "Image", ")", "{", "bounds", ":=", "source", ".", "Bounds", "(", ")", "\n", "for", "y", ":=", "bounds", ".", "Min", "....
// Draws pixels into target, including transparent ones.
[ "Draws", "pixels", "into", "target", "including", "transparent", "ones", "." ]
d70fba7c1676bb77b7d5813b9a436c36562839ed
https://github.com/kevin-cantwell/dotmatrix/blob/d70fba7c1676bb77b7d5813b9a436c36562839ed/gif.go#L131-L138
19,456
kevin-cantwell/dotmatrix
gif.go
resetCursor
func resetCursor(w io.Writer, rows int) { w.Write([]byte(fmt.Sprintf("\033[999D\033[%dA", rows))) }
go
func resetCursor(w io.Writer, rows int) { w.Write([]byte(fmt.Sprintf("\033[999D\033[%dA", rows))) }
[ "func", "resetCursor", "(", "w", "io", ".", "Writer", ",", "rows", "int", ")", "{", "w", ".", "Write", "(", "[", "]", "byte", "(", "fmt", ".", "Sprintf", "(", "\"", "\\033", "\\033", "\"", ",", "rows", ")", ")", ")", "\n", "}" ]
// Move the cursor to the beginning of the line and up rows
[ "Move", "the", "cursor", "to", "the", "beginning", "of", "the", "line", "and", "up", "rows" ]
d70fba7c1676bb77b7d5813b9a436c36562839ed
https://github.com/kevin-cantwell/dotmatrix/blob/d70fba7c1676bb77b7d5813b9a436c36562839ed/gif.go#L141-L143
19,457
kevin-cantwell/dotmatrix
image.go
NewPrinter
func NewPrinter(w io.Writer, c *Config) *Printer { return &Printer{ w: w, c: mergeConfig(c), } }
go
func NewPrinter(w io.Writer, c *Config) *Printer { return &Printer{ w: w, c: mergeConfig(c), } }
[ "func", "NewPrinter", "(", "w", "io", ".", "Writer", ",", "c", "*", "Config", ")", "*", "Printer", "{", "return", "&", "Printer", "{", "w", ":", "w", ",", "c", ":", "mergeConfig", "(", "c", ")", ",", "}", "\n", "}" ]
// NewPrinter provides an Printer. If drawer is nil, draw.FloydSteinberg is used.
[ "NewPrinter", "provides", "an", "Printer", ".", "If", "drawer", "is", "nil", "draw", ".", "FloydSteinberg", "is", "used", "." ]
d70fba7c1676bb77b7d5813b9a436c36562839ed
https://github.com/kevin-cantwell/dotmatrix/blob/d70fba7c1676bb77b7d5813b9a436c36562839ed/image.go#L67-L72
19,458
chop-dbhi/sql-agent
encoder.go
EncodeJSON
func EncodeJSON(w io.Writer, i *Iterator) error { r := make(Record) // Open paren. if _, err := w.Write([]byte{'['}); err != nil { return err } var c int enc := json.NewEncoder(w) delim := []byte{',', '\n'} for i.Next() { if c > 0 { if _, err := w.Write(delim); err != nil { return err } } ...
go
func EncodeJSON(w io.Writer, i *Iterator) error { r := make(Record) // Open paren. if _, err := w.Write([]byte{'['}); err != nil { return err } var c int enc := json.NewEncoder(w) delim := []byte{',', '\n'} for i.Next() { if c > 0 { if _, err := w.Write(delim); err != nil { return err } } ...
[ "func", "EncodeJSON", "(", "w", "io", ".", "Writer", ",", "i", "*", "Iterator", ")", "error", "{", "r", ":=", "make", "(", "Record", ")", "\n\n", "// Open paren.", "if", "_", ",", "err", ":=", "w", ".", "Write", "(", "[", "]", "byte", "{", "'['",...
// EncodeJSON encodes the iterator as a JSON array of records.
[ "EncodeJSON", "encodes", "the", "iterator", "as", "a", "JSON", "array", "of", "records", "." ]
7978b5bdb56370bd17fed45aadc06f614570ced6
https://github.com/chop-dbhi/sql-agent/blob/7978b5bdb56370bd17fed45aadc06f614570ced6/encoder.go#L52-L89
19,459
chop-dbhi/sql-agent
encoder.go
EncodeLDJSON
func EncodeLDJSON(w io.Writer, i *Iterator) error { r := make(Record) enc := json.NewEncoder(w) for i.Next() { if err := i.Scan(r); err != nil { return err } if err := enc.Encode(r); err != nil { return err } } return nil }
go
func EncodeLDJSON(w io.Writer, i *Iterator) error { r := make(Record) enc := json.NewEncoder(w) for i.Next() { if err := i.Scan(r); err != nil { return err } if err := enc.Encode(r); err != nil { return err } } return nil }
[ "func", "EncodeLDJSON", "(", "w", "io", ".", "Writer", ",", "i", "*", "Iterator", ")", "error", "{", "r", ":=", "make", "(", "Record", ")", "\n\n", "enc", ":=", "json", ".", "NewEncoder", "(", "w", ")", "\n\n", "for", "i", ".", "Next", "(", ")", ...
// EncodeLDJSON encodes the iterator as a line delimited stream // of records.
[ "EncodeLDJSON", "encodes", "the", "iterator", "as", "a", "line", "delimited", "stream", "of", "records", "." ]
7978b5bdb56370bd17fed45aadc06f614570ced6
https://github.com/chop-dbhi/sql-agent/blob/7978b5bdb56370bd17fed45aadc06f614570ced6/encoder.go#L93-L109
19,460
chop-dbhi/sql-agent
driver.go
cleanParams
func cleanParams(p map[string]interface{}) map[string]interface{} { c := make(map[string]interface{}) for k, v := range p { switch x := v.(type) { case string: if x == "" { continue } } c[k] = v } return c }
go
func cleanParams(p map[string]interface{}) map[string]interface{} { c := make(map[string]interface{}) for k, v := range p { switch x := v.(type) { case string: if x == "" { continue } } c[k] = v } return c }
[ "func", "cleanParams", "(", "p", "map", "[", "string", "]", "interface", "{", "}", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "c", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n\n", "for", "k", ",",...
// cleanParams removes any key with empty string values.
[ "cleanParams", "removes", "any", "key", "with", "empty", "string", "values", "." ]
7978b5bdb56370bd17fed45aadc06f614570ced6
https://github.com/chop-dbhi/sql-agent/blob/7978b5bdb56370bd17fed45aadc06f614570ced6/driver.go#L17-L32
19,461
chop-dbhi/sql-agent
connect.go
Scan
func (i *Iterator) Scan(r Record) error { if err := i.rows.MapScan(r); err != nil { return err } mapBytesToString(r) return nil }
go
func (i *Iterator) Scan(r Record) error { if err := i.rows.MapScan(r); err != nil { return err } mapBytesToString(r) return nil }
[ "func", "(", "i", "*", "Iterator", ")", "Scan", "(", "r", "Record", ")", "error", "{", "if", "err", ":=", "i", ".", "rows", ".", "MapScan", "(", "r", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "mapBytesToString", "(", ...
// Scan takes a record and scans the values of a row into the record.
[ "Scan", "takes", "a", "record", "and", "scans", "the", "values", "of", "a", "row", "into", "the", "record", "." ]
7978b5bdb56370bd17fed45aadc06f614570ced6
https://github.com/chop-dbhi/sql-agent/blob/7978b5bdb56370bd17fed45aadc06f614570ced6/connect.go#L37-L45
19,462
chop-dbhi/sql-agent
connect.go
Connect
func Connect(driver string, params map[string]interface{}) (*sqlx.DB, error) { // Select the driver. driver, ok := Drivers[driver] if !ok { return nil, ErrUnknownDriver } // Connect to the database. connector := connectors[driver] params = cleanParams(params) dsn, ok := params["dsn"].(string) if !ok { ...
go
func Connect(driver string, params map[string]interface{}) (*sqlx.DB, error) { // Select the driver. driver, ok := Drivers[driver] if !ok { return nil, ErrUnknownDriver } // Connect to the database. connector := connectors[driver] params = cleanParams(params) dsn, ok := params["dsn"].(string) if !ok { ...
[ "func", "Connect", "(", "driver", "string", ",", "params", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "*", "sqlx", ".", "DB", ",", "error", ")", "{", "// Select the driver.", "driver", ",", "ok", ":=", "Drivers", "[", "driver", "]", ...
// Connect connects to a database given a driver name and set of connection parameters. // Each database supports a different set of connection parameters, however the few // that are common are standardized. // // - `host` - The database host. // - `port` - The database port. // - `user` - The username to authenticate...
[ "Connect", "connects", "to", "a", "database", "given", "a", "driver", "name", "and", "set", "of", "connection", "parameters", ".", "Each", "database", "supports", "a", "different", "set", "of", "connection", "parameters", "however", "the", "few", "that", "are"...
7978b5bdb56370bd17fed45aadc06f614570ced6
https://github.com/chop-dbhi/sql-agent/blob/7978b5bdb56370bd17fed45aadc06f614570ced6/connect.go#L62-L81
19,463
chop-dbhi/sql-agent
connect.go
Execute
func Execute(db *sqlx.DB, sql string, params map[string]interface{}) (*Iterator, error) { var ( err error rows *sqlx.Rows ) // Execute the query. if params != nil && len(params) > 0 { rows, err = db.NamedQuery(sql, params) } else { rows, err = db.Queryx(sql) } if err != nil { return nil, err } co...
go
func Execute(db *sqlx.DB, sql string, params map[string]interface{}) (*Iterator, error) { var ( err error rows *sqlx.Rows ) // Execute the query. if params != nil && len(params) > 0 { rows, err = db.NamedQuery(sql, params) } else { rows, err = db.Queryx(sql) } if err != nil { return nil, err } co...
[ "func", "Execute", "(", "db", "*", "sqlx", ".", "DB", ",", "sql", "string", ",", "params", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "*", "Iterator", ",", "error", ")", "{", "var", "(", "err", "error", "\n", "rows", "*", "sqlx",...
// Execute takes a database instance, SQL statement, and parameters and executes the query // returning the resulting rows.
[ "Execute", "takes", "a", "database", "instance", "SQL", "statement", "and", "parameters", "and", "executes", "the", "query", "returning", "the", "resulting", "rows", "." ]
7978b5bdb56370bd17fed45aadc06f614570ced6
https://github.com/chop-dbhi/sql-agent/blob/7978b5bdb56370bd17fed45aadc06f614570ced6/connect.go#L85-L111
19,464
chop-dbhi/sql-agent
connect.go
Shutdown
func Shutdown() { connMapMutex.Lock() for _, db := range connMap { db.Close() } connMapMutex.Unlock() }
go
func Shutdown() { connMapMutex.Lock() for _, db := range connMap { db.Close() } connMapMutex.Unlock() }
[ "func", "Shutdown", "(", ")", "{", "connMapMutex", ".", "Lock", "(", ")", "\n", "for", "_", ",", "db", ":=", "range", "connMap", "{", "db", ".", "Close", "(", ")", "\n", "}", "\n", "connMapMutex", ".", "Unlock", "(", ")", "\n", "}" ]
// Shutdown closes all persisted database connections.
[ "Shutdown", "closes", "all", "persisted", "database", "connections", "." ]
7978b5bdb56370bd17fed45aadc06f614570ced6
https://github.com/chop-dbhi/sql-agent/blob/7978b5bdb56370bd17fed45aadc06f614570ced6/connect.go#L147-L153
19,465
chop-dbhi/sql-agent
cmd/sql-agent/main.go
parseMimetype
func parseMimetype(mimetype string) string { mimetype, params, err := mime.ParseMediaType(mimetype) if err != nil { return "" } // No Accept header passed. if mimetype == "" { return defaultMimetype } switch mimetype { case "application/json": if params["boundary"] == "NL" { return "application/x-ld...
go
func parseMimetype(mimetype string) string { mimetype, params, err := mime.ParseMediaType(mimetype) if err != nil { return "" } // No Accept header passed. if mimetype == "" { return defaultMimetype } switch mimetype { case "application/json": if params["boundary"] == "NL" { return "application/x-ld...
[ "func", "parseMimetype", "(", "mimetype", "string", ")", "string", "{", "mimetype", ",", "params", ",", "err", ":=", "mime", ".", "ParseMediaType", "(", "mimetype", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n\n", "/...
// parseMimetype parses a mimetype from the Accept header.
[ "parseMimetype", "parses", "a", "mimetype", "from", "the", "Accept", "header", "." ]
7978b5bdb56370bd17fed45aadc06f614570ced6
https://github.com/chop-dbhi/sql-agent/blob/7978b5bdb56370bd17fed45aadc06f614570ced6/cmd/sql-agent/main.go#L65-L89
19,466
lithammer/fuzzysearch
fuzzy/fuzzy.go
MatchFold
func MatchFold(source, target string) bool { return match(source, target, unicode.ToLower) }
go
func MatchFold(source, target string) bool { return match(source, target, unicode.ToLower) }
[ "func", "MatchFold", "(", "source", ",", "target", "string", ")", "bool", "{", "return", "match", "(", "source", ",", "target", ",", "unicode", ".", "ToLower", ")", "\n", "}" ]
// MatchFold is a case-insensitive version of Match.
[ "MatchFold", "is", "a", "case", "-", "insensitive", "version", "of", "Match", "." ]
9704abcb5729ef17e4316e31439d7fcece8dac5f
https://github.com/lithammer/fuzzysearch/blob/9704abcb5729ef17e4316e31439d7fcece8dac5f/fuzzy/fuzzy.go#L22-L24
19,467
lithammer/fuzzysearch
fuzzy/fuzzy.go
Find
func Find(source string, targets []string) []string { return find(source, targets, noop) }
go
func Find(source string, targets []string) []string { return find(source, targets, noop) }
[ "func", "Find", "(", "source", "string", ",", "targets", "[", "]", "string", ")", "[", "]", "string", "{", "return", "find", "(", "source", ",", "targets", ",", "noop", ")", "\n", "}" ]
// Find will return a list of strings in targets that fuzzy matches source.
[ "Find", "will", "return", "a", "list", "of", "strings", "in", "targets", "that", "fuzzy", "matches", "source", "." ]
9704abcb5729ef17e4316e31439d7fcece8dac5f
https://github.com/lithammer/fuzzysearch/blob/9704abcb5729ef17e4316e31439d7fcece8dac5f/fuzzy/fuzzy.go#L52-L54
19,468
lithammer/fuzzysearch
fuzzy/fuzzy.go
FindFold
func FindFold(source string, targets []string) []string { return find(source, targets, unicode.ToLower) }
go
func FindFold(source string, targets []string) []string { return find(source, targets, unicode.ToLower) }
[ "func", "FindFold", "(", "source", "string", ",", "targets", "[", "]", "string", ")", "[", "]", "string", "{", "return", "find", "(", "source", ",", "targets", ",", "unicode", ".", "ToLower", ")", "\n", "}" ]
// FindFold is a case-insensitive version of Find.
[ "FindFold", "is", "a", "case", "-", "insensitive", "version", "of", "Find", "." ]
9704abcb5729ef17e4316e31439d7fcece8dac5f
https://github.com/lithammer/fuzzysearch/blob/9704abcb5729ef17e4316e31439d7fcece8dac5f/fuzzy/fuzzy.go#L57-L59
19,469
lithammer/fuzzysearch
fuzzy/fuzzy.go
RankMatchFold
func RankMatchFold(source, target string) int { return rank(source, target, unicode.ToLower) }
go
func RankMatchFold(source, target string) int { return rank(source, target, unicode.ToLower) }
[ "func", "RankMatchFold", "(", "source", ",", "target", "string", ")", "int", "{", "return", "rank", "(", "source", ",", "target", ",", "unicode", ".", "ToLower", ")", "\n", "}" ]
// RankMatchFold is a case-insensitive version of RankMatch.
[ "RankMatchFold", "is", "a", "case", "-", "insensitive", "version", "of", "RankMatch", "." ]
9704abcb5729ef17e4316e31439d7fcece8dac5f
https://github.com/lithammer/fuzzysearch/blob/9704abcb5729ef17e4316e31439d7fcece8dac5f/fuzzy/fuzzy.go#L84-L86
19,470
lithammer/fuzzysearch
fuzzy/fuzzy.go
RankFind
func RankFind(source string, targets []string) Ranks { var r Ranks for index, target := range targets { if match(source, target, noop) { distance := LevenshteinDistance(source, target) r = append(r, Rank{source, target, distance, index}) } } return r }
go
func RankFind(source string, targets []string) Ranks { var r Ranks for index, target := range targets { if match(source, target, noop) { distance := LevenshteinDistance(source, target) r = append(r, Rank{source, target, distance, index}) } } return r }
[ "func", "RankFind", "(", "source", "string", ",", "targets", "[", "]", "string", ")", "Ranks", "{", "var", "r", "Ranks", "\n\n", "for", "index", ",", "target", ":=", "range", "targets", "{", "if", "match", "(", "source", ",", "target", ",", "noop", "...
// RankFind is similar to Find, except it will also rank all matches using // Levenshtein distance.
[ "RankFind", "is", "similar", "to", "Find", "except", "it", "will", "also", "rank", "all", "matches", "using", "Levenshtein", "distance", "." ]
9704abcb5729ef17e4316e31439d7fcece8dac5f
https://github.com/lithammer/fuzzysearch/blob/9704abcb5729ef17e4316e31439d7fcece8dac5f/fuzzy/fuzzy.go#L122-L132
19,471
lithammer/fuzzysearch
fuzzy/fuzzy.go
RankFindFold
func RankFindFold(source string, targets []string) Ranks { var r Ranks for index, target := range targets { if match(source, target, unicode.ToLower) { distance := LevenshteinDistance(source, target) r = append(r, Rank{source, target, distance, index}) } } return r }
go
func RankFindFold(source string, targets []string) Ranks { var r Ranks for index, target := range targets { if match(source, target, unicode.ToLower) { distance := LevenshteinDistance(source, target) r = append(r, Rank{source, target, distance, index}) } } return r }
[ "func", "RankFindFold", "(", "source", "string", ",", "targets", "[", "]", "string", ")", "Ranks", "{", "var", "r", "Ranks", "\n\n", "for", "index", ",", "target", ":=", "range", "targets", "{", "if", "match", "(", "source", ",", "target", ",", "unicod...
// RankFindFold is a case-insensitive version of RankFind.
[ "RankFindFold", "is", "a", "case", "-", "insensitive", "version", "of", "RankFind", "." ]
9704abcb5729ef17e4316e31439d7fcece8dac5f
https://github.com/lithammer/fuzzysearch/blob/9704abcb5729ef17e4316e31439d7fcece8dac5f/fuzzy/fuzzy.go#L135-L145
19,472
huandu/xstrings
translate.go
TranslateRune
func (tr *Translator) TranslateRune(r rune) (result rune, translated bool) { switch { case tr.quickDict != nil: if r <= unicode.MaxASCII { result = tr.quickDict.Dict[r] if result != 0 { translated = true if tr.mappedRune >= 0 { result = tr.mappedRune } break } } fallthrough c...
go
func (tr *Translator) TranslateRune(r rune) (result rune, translated bool) { switch { case tr.quickDict != nil: if r <= unicode.MaxASCII { result = tr.quickDict.Dict[r] if result != 0 { translated = true if tr.mappedRune >= 0 { result = tr.mappedRune } break } } fallthrough c...
[ "func", "(", "tr", "*", "Translator", ")", "TranslateRune", "(", "r", "rune", ")", "(", "result", "rune", ",", "translated", "bool", ")", "{", "switch", "{", "case", "tr", ".", "quickDict", "!=", "nil", ":", "if", "r", "<=", "unicode", ".", "MaxASCII...
// TranslateRune return translated rune and true if r matches the from pattern. // If r doesn't match the pattern, original r is returned and translated is false.
[ "TranslateRune", "return", "translated", "rune", "and", "true", "if", "r", "matches", "the", "from", "pattern", ".", "If", "r", "doesn", "t", "match", "the", "pattern", "original", "r", "is", "returned", "and", "translated", "is", "false", "." ]
8bbcf2f9ccb55755e748b7644164cd4bdce94c1d
https://github.com/huandu/xstrings/blob/8bbcf2f9ccb55755e748b7644164cd4bdce94c1d/translate.go#L333-L409
19,473
huandu/xstrings
count.go
WordCount
func WordCount(str string) int { var r rune var size, n int inWord := false for len(str) > 0 { r, size = utf8.DecodeRuneInString(str) switch { case isAlphabet(r): if !inWord { inWord = true n++ } case inWord && (r == '\'' || r == '-'): // Still in word. default: inWord = false }...
go
func WordCount(str string) int { var r rune var size, n int inWord := false for len(str) > 0 { r, size = utf8.DecodeRuneInString(str) switch { case isAlphabet(r): if !inWord { inWord = true n++ } case inWord && (r == '\'' || r == '-'): // Still in word. default: inWord = false }...
[ "func", "WordCount", "(", "str", "string", ")", "int", "{", "var", "r", "rune", "\n", "var", "size", ",", "n", "int", "\n\n", "inWord", ":=", "false", "\n\n", "for", "len", "(", "str", ")", ">", "0", "{", "r", ",", "size", "=", "utf8", ".", "De...
// WordCount returns number of words in a string. // // Word is defined as a locale dependent string containing alphabetic characters, // which may also contain but not start with `'` and `-` characters.
[ "WordCount", "returns", "number", "of", "words", "in", "a", "string", ".", "Word", "is", "defined", "as", "a", "locale", "dependent", "string", "containing", "alphabetic", "characters", "which", "may", "also", "contain", "but", "not", "start", "with", "and", ...
8bbcf2f9ccb55755e748b7644164cd4bdce94c1d
https://github.com/huandu/xstrings/blob/8bbcf2f9ccb55755e748b7644164cd4bdce94c1d/count.go#L20-L47
19,474
huandu/xstrings
count.go
isAlphabet
func isAlphabet(r rune) bool { if !unicode.IsLetter(r) { return false } switch { // Quick check for non-CJK character. case r < minCJKCharacter: return true // Common CJK characters. case r >= '\u4E00' && r <= '\u9FCC': return false // Rare CJK characters. case r >= '\u3400' && r <= '\u4D85': return...
go
func isAlphabet(r rune) bool { if !unicode.IsLetter(r) { return false } switch { // Quick check for non-CJK character. case r < minCJKCharacter: return true // Common CJK characters. case r >= '\u4E00' && r <= '\u9FCC': return false // Rare CJK characters. case r >= '\u3400' && r <= '\u4D85': return...
[ "func", "isAlphabet", "(", "r", "rune", ")", "bool", "{", "if", "!", "unicode", ".", "IsLetter", "(", "r", ")", "{", "return", "false", "\n", "}", "\n\n", "switch", "{", "// Quick check for non-CJK character.", "case", "r", "<", "minCJKCharacter", ":", "re...
// Checks r is a letter but not CJK character.
[ "Checks", "r", "is", "a", "letter", "but", "not", "CJK", "character", "." ]
8bbcf2f9ccb55755e748b7644164cd4bdce94c1d
https://github.com/huandu/xstrings/blob/8bbcf2f9ccb55755e748b7644164cd4bdce94c1d/count.go#L52-L76
19,475
huandu/xstrings
convert.go
SwapCase
func SwapCase(str string) string { var r rune var size int buf := &bytes.Buffer{} for len(str) > 0 { r, size = utf8.DecodeRuneInString(str) switch { case unicode.IsUpper(r): buf.WriteRune(unicode.ToLower(r)) case unicode.IsLower(r): buf.WriteRune(unicode.ToUpper(r)) default: buf.WriteRune(r)...
go
func SwapCase(str string) string { var r rune var size int buf := &bytes.Buffer{} for len(str) > 0 { r, size = utf8.DecodeRuneInString(str) switch { case unicode.IsUpper(r): buf.WriteRune(unicode.ToLower(r)) case unicode.IsLower(r): buf.WriteRune(unicode.ToUpper(r)) default: buf.WriteRune(r)...
[ "func", "SwapCase", "(", "str", "string", ")", "string", "{", "var", "r", "rune", "\n", "var", "size", "int", "\n\n", "buf", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n\n", "for", "len", "(", "str", ")", ">", "0", "{", "r", ",", "size", "=...
// SwapCase will swap characters case from upper to lower or lower to upper.
[ "SwapCase", "will", "swap", "characters", "case", "from", "upper", "to", "lower", "or", "lower", "to", "upper", "." ]
8bbcf2f9ccb55755e748b7644164cd4bdce94c1d
https://github.com/huandu/xstrings/blob/8bbcf2f9ccb55755e748b7644164cd4bdce94c1d/convert.go#L209-L233
19,476
huandu/xstrings
convert.go
FirstRuneToUpper
func FirstRuneToUpper(str string) string { if str == "" { return str } r, size := utf8.DecodeRuneInString(str) if !unicode.IsLower(r) { return str } buf := &bytes.Buffer{} buf.WriteRune(unicode.ToUpper(r)) buf.WriteString(str[size:]) return buf.String() }
go
func FirstRuneToUpper(str string) string { if str == "" { return str } r, size := utf8.DecodeRuneInString(str) if !unicode.IsLower(r) { return str } buf := &bytes.Buffer{} buf.WriteRune(unicode.ToUpper(r)) buf.WriteString(str[size:]) return buf.String() }
[ "func", "FirstRuneToUpper", "(", "str", "string", ")", "string", "{", "if", "str", "==", "\"", "\"", "{", "return", "str", "\n", "}", "\n\n", "r", ",", "size", ":=", "utf8", ".", "DecodeRuneInString", "(", "str", ")", "\n\n", "if", "!", "unicode", "....
// FirstRuneToUpper converts first rune to upper case if necessary.
[ "FirstRuneToUpper", "converts", "first", "rune", "to", "upper", "case", "if", "necessary", "." ]
8bbcf2f9ccb55755e748b7644164cd4bdce94c1d
https://github.com/huandu/xstrings/blob/8bbcf2f9ccb55755e748b7644164cd4bdce94c1d/convert.go#L236-L251
19,477
huandu/xstrings
convert.go
FirstRuneToLower
func FirstRuneToLower(str string) string { if str == "" { return str } r, size := utf8.DecodeRuneInString(str) if !unicode.IsUpper(r) { return str } buf := &bytes.Buffer{} buf.WriteRune(unicode.ToLower(r)) buf.WriteString(str[size:]) return buf.String() }
go
func FirstRuneToLower(str string) string { if str == "" { return str } r, size := utf8.DecodeRuneInString(str) if !unicode.IsUpper(r) { return str } buf := &bytes.Buffer{} buf.WriteRune(unicode.ToLower(r)) buf.WriteString(str[size:]) return buf.String() }
[ "func", "FirstRuneToLower", "(", "str", "string", ")", "string", "{", "if", "str", "==", "\"", "\"", "{", "return", "str", "\n", "}", "\n\n", "r", ",", "size", ":=", "utf8", ".", "DecodeRuneInString", "(", "str", ")", "\n\n", "if", "!", "unicode", "....
// FirstRuneToLower converts first rune to lower case if necessary.
[ "FirstRuneToLower", "converts", "first", "rune", "to", "lower", "case", "if", "necessary", "." ]
8bbcf2f9ccb55755e748b7644164cd4bdce94c1d
https://github.com/huandu/xstrings/blob/8bbcf2f9ccb55755e748b7644164cd4bdce94c1d/convert.go#L254-L269
19,478
huandu/xstrings
convert.go
ShuffleSource
func ShuffleSource(str string, src rand.Source) string { if str == "" { return str } runes := []rune(str) index := 0 r := rand.New(src) for i := len(runes) - 1; i > 0; i-- { index = r.Intn(i + 1) if i != index { runes[i], runes[index] = runes[index], runes[i] } } return string(runes) }
go
func ShuffleSource(str string, src rand.Source) string { if str == "" { return str } runes := []rune(str) index := 0 r := rand.New(src) for i := len(runes) - 1; i > 0; i-- { index = r.Intn(i + 1) if i != index { runes[i], runes[index] = runes[index], runes[i] } } return string(runes) }
[ "func", "ShuffleSource", "(", "str", "string", ",", "src", "rand", ".", "Source", ")", "string", "{", "if", "str", "==", "\"", "\"", "{", "return", "str", "\n", "}", "\n\n", "runes", ":=", "[", "]", "rune", "(", "str", ")", "\n", "index", ":=", "...
// ShuffleSource randomizes runes in a string with given random source.
[ "ShuffleSource", "randomizes", "runes", "in", "a", "string", "with", "given", "random", "source", "." ]
8bbcf2f9ccb55755e748b7644164cd4bdce94c1d
https://github.com/huandu/xstrings/blob/8bbcf2f9ccb55755e748b7644164cd4bdce94c1d/convert.go#L293-L311
19,479
huandu/xstrings
manipulate.go
Reverse
func Reverse(str string) string { var size int tail := len(str) buf := make([]byte, tail) s := buf for len(str) > 0 { _, size = utf8.DecodeRuneInString(str) tail -= size s = append(s[:tail], []byte(str[:size])...) str = str[size:] } return string(buf) }
go
func Reverse(str string) string { var size int tail := len(str) buf := make([]byte, tail) s := buf for len(str) > 0 { _, size = utf8.DecodeRuneInString(str) tail -= size s = append(s[:tail], []byte(str[:size])...) str = str[size:] } return string(buf) }
[ "func", "Reverse", "(", "str", "string", ")", "string", "{", "var", "size", "int", "\n\n", "tail", ":=", "len", "(", "str", ")", "\n", "buf", ":=", "make", "(", "[", "]", "byte", ",", "tail", ")", "\n", "s", ":=", "buf", "\n\n", "for", "len", "...
// Reverse a utf8 encoded string.
[ "Reverse", "a", "utf8", "encoded", "string", "." ]
8bbcf2f9ccb55755e748b7644164cd4bdce94c1d
https://github.com/huandu/xstrings/blob/8bbcf2f9ccb55755e748b7644164cd4bdce94c1d/manipulate.go#L13-L28
19,480
huandu/xstrings
manipulate.go
Partition
func Partition(str, sep string) (head, match, tail string) { index := strings.Index(str, sep) if index == -1 { head = str return } head = str[:index] match = str[index : index+len(sep)] tail = str[index+len(sep):] return }
go
func Partition(str, sep string) (head, match, tail string) { index := strings.Index(str, sep) if index == -1 { head = str return } head = str[:index] match = str[index : index+len(sep)] tail = str[index+len(sep):] return }
[ "func", "Partition", "(", "str", ",", "sep", "string", ")", "(", "head", ",", "match", ",", "tail", "string", ")", "{", "index", ":=", "strings", ".", "Index", "(", "str", ",", "sep", ")", "\n\n", "if", "index", "==", "-", "1", "{", "head", "=", ...
// Partition splits a string by sep into three parts. // The return value is a slice of strings with head, match and tail. // // If str contains sep, for example "hello" and "l", Partition returns // "he", "l", "lo" // // If str doesn't contain sep, for example "hello" and "x", Partition returns // "hello", "",...
[ "Partition", "splits", "a", "string", "by", "sep", "into", "three", "parts", ".", "The", "return", "value", "is", "a", "slice", "of", "strings", "with", "head", "match", "and", "tail", ".", "If", "str", "contains", "sep", "for", "example", "hello", "and"...
8bbcf2f9ccb55755e748b7644164cd4bdce94c1d
https://github.com/huandu/xstrings/blob/8bbcf2f9ccb55755e748b7644164cd4bdce94c1d/manipulate.go#L87-L99
19,481
huandu/xstrings
manipulate.go
LastPartition
func LastPartition(str, sep string) (head, match, tail string) { index := strings.LastIndex(str, sep) if index == -1 { tail = str return } head = str[:index] match = str[index : index+len(sep)] tail = str[index+len(sep):] return }
go
func LastPartition(str, sep string) (head, match, tail string) { index := strings.LastIndex(str, sep) if index == -1 { tail = str return } head = str[:index] match = str[index : index+len(sep)] tail = str[index+len(sep):] return }
[ "func", "LastPartition", "(", "str", ",", "sep", "string", ")", "(", "head", ",", "match", ",", "tail", "string", ")", "{", "index", ":=", "strings", ".", "LastIndex", "(", "str", ",", "sep", ")", "\n\n", "if", "index", "==", "-", "1", "{", "tail",...
// LastPartition splits a string by last instance of sep into three parts. // The return value is a slice of strings with head, match and tail. // // If str contains sep, for example "hello" and "l", LastPartition returns // "hel", "l", "o" // // If str doesn't contain sep, for example "hello" and "x", LastPartitio...
[ "LastPartition", "splits", "a", "string", "by", "last", "instance", "of", "sep", "into", "three", "parts", ".", "The", "return", "value", "is", "a", "slice", "of", "strings", "with", "head", "match", "and", "tail", ".", "If", "str", "contains", "sep", "f...
8bbcf2f9ccb55755e748b7644164cd4bdce94c1d
https://github.com/huandu/xstrings/blob/8bbcf2f9ccb55755e748b7644164cd4bdce94c1d/manipulate.go#L109-L121
19,482
huandu/xstrings
manipulate.go
Insert
func Insert(dst, src string, index int) string { return Slice(dst, 0, index) + src + Slice(dst, index, -1) }
go
func Insert(dst, src string, index int) string { return Slice(dst, 0, index) + src + Slice(dst, index, -1) }
[ "func", "Insert", "(", "dst", ",", "src", "string", ",", "index", "int", ")", "string", "{", "return", "Slice", "(", "dst", ",", "0", ",", "index", ")", "+", "src", "+", "Slice", "(", "dst", ",", "index", ",", "-", "1", ")", "\n", "}" ]
// Insert src into dst at given rune index. // Index is counted by runes instead of bytes. // // If index is out of range of dst, panic with out of range.
[ "Insert", "src", "into", "dst", "at", "given", "rune", "index", ".", "Index", "is", "counted", "by", "runes", "instead", "of", "bytes", ".", "If", "index", "is", "out", "of", "range", "of", "dst", "panic", "with", "out", "of", "range", "." ]
8bbcf2f9ccb55755e748b7644164cd4bdce94c1d
https://github.com/huandu/xstrings/blob/8bbcf2f9ccb55755e748b7644164cd4bdce94c1d/manipulate.go#L127-L129
19,483
huandu/xstrings
manipulate.go
Scrub
func Scrub(str, repl string) string { var buf *bytes.Buffer var r rune var size, pos int var hasError bool origin := str for len(str) > 0 { r, size = utf8.DecodeRuneInString(str) if r == utf8.RuneError { if !hasError { if buf == nil { buf = &bytes.Buffer{} } buf.WriteString(origin[:pos...
go
func Scrub(str, repl string) string { var buf *bytes.Buffer var r rune var size, pos int var hasError bool origin := str for len(str) > 0 { r, size = utf8.DecodeRuneInString(str) if r == utf8.RuneError { if !hasError { if buf == nil { buf = &bytes.Buffer{} } buf.WriteString(origin[:pos...
[ "func", "Scrub", "(", "str", ",", "repl", "string", ")", "string", "{", "var", "buf", "*", "bytes", ".", "Buffer", "\n", "var", "r", "rune", "\n", "var", "size", ",", "pos", "int", "\n", "var", "hasError", "bool", "\n\n", "origin", ":=", "str", "\n...
// Scrub scrubs invalid utf8 bytes with repl string. // Adjacent invalid bytes are replaced only once.
[ "Scrub", "scrubs", "invalid", "utf8", "bytes", "with", "repl", "string", ".", "Adjacent", "invalid", "bytes", "are", "replaced", "only", "once", "." ]
8bbcf2f9ccb55755e748b7644164cd4bdce94c1d
https://github.com/huandu/xstrings/blob/8bbcf2f9ccb55755e748b7644164cd4bdce94c1d/manipulate.go#L133-L172
19,484
huandu/xstrings
manipulate.go
WordSplit
func WordSplit(str string) []string { var word string var words []string var r rune var size, pos int inWord := false for len(str) > 0 { r, size = utf8.DecodeRuneInString(str) switch { case isAlphabet(r): if !inWord { inWord = true word = str pos = 0 } case inWord && (r == '\'' || r ...
go
func WordSplit(str string) []string { var word string var words []string var r rune var size, pos int inWord := false for len(str) > 0 { r, size = utf8.DecodeRuneInString(str) switch { case isAlphabet(r): if !inWord { inWord = true word = str pos = 0 } case inWord && (r == '\'' || r ...
[ "func", "WordSplit", "(", "str", "string", ")", "[", "]", "string", "{", "var", "word", "string", "\n", "var", "words", "[", "]", "string", "\n", "var", "r", "rune", "\n", "var", "size", ",", "pos", "int", "\n\n", "inWord", ":=", "false", "\n\n", "...
// WordSplit splits a string into words. Returns a slice of words. // If there is no word in a string, return nil. // // Word is defined as a locale dependent string containing alphabetic characters, // which may also contain but not start with `'` and `-` characters.
[ "WordSplit", "splits", "a", "string", "into", "words", ".", "Returns", "a", "slice", "of", "words", ".", "If", "there", "is", "no", "word", "in", "a", "string", "return", "nil", ".", "Word", "is", "defined", "as", "a", "locale", "dependent", "string", ...
8bbcf2f9ccb55755e748b7644164cd4bdce94c1d
https://github.com/huandu/xstrings/blob/8bbcf2f9ccb55755e748b7644164cd4bdce94c1d/manipulate.go#L179-L217
19,485
huandu/xstrings
common.go
allocBuffer
func allocBuffer(orig, cur string) *bytes.Buffer { output := &bytes.Buffer{} maxSize := len(orig) * 4 // Avoid to reserve too much memory at once. if maxSize > bufferMaxInitGrowSize { maxSize = bufferMaxInitGrowSize } output.Grow(maxSize) output.WriteString(orig[:len(orig)-len(cur)]) return output }
go
func allocBuffer(orig, cur string) *bytes.Buffer { output := &bytes.Buffer{} maxSize := len(orig) * 4 // Avoid to reserve too much memory at once. if maxSize > bufferMaxInitGrowSize { maxSize = bufferMaxInitGrowSize } output.Grow(maxSize) output.WriteString(orig[:len(orig)-len(cur)]) return output }
[ "func", "allocBuffer", "(", "orig", ",", "cur", "string", ")", "*", "bytes", ".", "Buffer", "{", "output", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "maxSize", ":=", "len", "(", "orig", ")", "*", "4", "\n\n", "// Avoid to reserve too much memory...
// Lazy initialize a buffer.
[ "Lazy", "initialize", "a", "buffer", "." ]
8bbcf2f9ccb55755e748b7644164cd4bdce94c1d
https://github.com/huandu/xstrings/blob/8bbcf2f9ccb55755e748b7644164cd4bdce94c1d/common.go#L13-L25
19,486
trustmaster/goflow
component.go
Run
func Run(c Component) Wait { wait := make(Wait) go func() { c.Process() wait <- Done{} }() return wait }
go
func Run(c Component) Wait { wait := make(Wait) go func() { c.Process() wait <- Done{} }() return wait }
[ "func", "Run", "(", "c", "Component", ")", "Wait", "{", "wait", ":=", "make", "(", "Wait", ")", "\n", "go", "func", "(", ")", "{", "c", ".", "Process", "(", ")", "\n", "wait", "<-", "Done", "{", "}", "\n", "}", "(", ")", "\n", "return", "wait...
// Run the component process
[ "Run", "the", "component", "process" ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/component.go#L15-L22
19,487
trustmaster/goflow
component.go
NewInputGuard
func NewInputGuard(ports ...string) *InputGuard { portMap := make(map[string]bool, len(ports)) for _, p := range ports { portMap[p] = false } return &InputGuard{portMap, 0} }
go
func NewInputGuard(ports ...string) *InputGuard { portMap := make(map[string]bool, len(ports)) for _, p := range ports { portMap[p] = false } return &InputGuard{portMap, 0} }
[ "func", "NewInputGuard", "(", "ports", "...", "string", ")", "*", "InputGuard", "{", "portMap", ":=", "make", "(", "map", "[", "string", "]", "bool", ",", "len", "(", "ports", ")", ")", "\n", "for", "_", ",", "p", ":=", "range", "ports", "{", "port...
// NewInputGuard returns a guard for a given number of inputs
[ "NewInputGuard", "returns", "a", "guard", "for", "a", "given", "number", "of", "inputs" ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/component.go#L31-L37
19,488
trustmaster/goflow
component.go
Complete
func (g *InputGuard) Complete(port string) bool { if !g.ports[port] { g.ports[port] = true g.complete++ } return g.complete >= len(g.ports) }
go
func (g *InputGuard) Complete(port string) bool { if !g.ports[port] { g.ports[port] = true g.complete++ } return g.complete >= len(g.ports) }
[ "func", "(", "g", "*", "InputGuard", ")", "Complete", "(", "port", "string", ")", "bool", "{", "if", "!", "g", ".", "ports", "[", "port", "]", "{", "g", ".", "ports", "[", "port", "]", "=", "true", "\n", "g", ".", "complete", "++", "\n", "}", ...
// Complete is called when a port is closed and returns true when all the ports have been closed
[ "Complete", "is", "called", "when", "a", "port", "is", "closed", "and", "returns", "true", "when", "all", "the", "ports", "have", "been", "closed" ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/component.go#L40-L46
19,489
trustmaster/goflow
loader.go
ParseJSON
func ParseJSON(js []byte) *Graph { // Parse JSON into Go struct var descr graphDescription err := json.Unmarshal(js, &descr) if err != nil { return nil } // fmt.Printf("%+v\n", descr) constructor := func() interface{} { // Create a new Graph net := new(Graph) net.InitGraphState() // Add processes to ...
go
func ParseJSON(js []byte) *Graph { // Parse JSON into Go struct var descr graphDescription err := json.Unmarshal(js, &descr) if err != nil { return nil } // fmt.Printf("%+v\n", descr) constructor := func() interface{} { // Create a new Graph net := new(Graph) net.InitGraphState() // Add processes to ...
[ "func", "ParseJSON", "(", "js", "[", "]", "byte", ")", "*", "Graph", "{", "// Parse JSON into Go struct", "var", "descr", "graphDescription", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "js", ",", "&", "descr", ")", "\n", "if", "err", "!=", "nil", ...
// ParseJSON converts a JSON network definition string into // a flow.Graph object that can be run or used in other networks
[ "ParseJSON", "converts", "a", "JSON", "network", "definition", "string", "into", "a", "flow", ".", "Graph", "object", "that", "can", "be", "run", "or", "used", "in", "other", "networks" ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/loader.go#L46-L119
19,490
trustmaster/goflow
loader.go
LoadJSON
func LoadJSON(filename string) *Graph { js, err := ioutil.ReadFile(filename) if err != nil { return nil } return ParseJSON(js) }
go
func LoadJSON(filename string) *Graph { js, err := ioutil.ReadFile(filename) if err != nil { return nil } return ParseJSON(js) }
[ "func", "LoadJSON", "(", "filename", "string", ")", "*", "Graph", "{", "js", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "ParseJSON", "(", "js", ...
// LoadJSON loads a JSON graph definition file into // a flow.Graph object that can be run or used in other networks
[ "LoadJSON", "loads", "a", "JSON", "graph", "definition", "file", "into", "a", "flow", ".", "Graph", "object", "that", "can", "be", "run", "or", "used", "in", "other", "networks" ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/loader.go#L123-L129
19,491
trustmaster/goflow
loader.go
RegisterJSON
func RegisterJSON(componentName, filePath string) bool { var constructor ComponentConstructor constructor = func() interface{} { return LoadJSON(filePath) } return Register(componentName, constructor) }
go
func RegisterJSON(componentName, filePath string) bool { var constructor ComponentConstructor constructor = func() interface{} { return LoadJSON(filePath) } return Register(componentName, constructor) }
[ "func", "RegisterJSON", "(", "componentName", ",", "filePath", "string", ")", "bool", "{", "var", "constructor", "ComponentConstructor", "\n", "constructor", "=", "func", "(", ")", "interface", "{", "}", "{", "return", "LoadJSON", "(", "filePath", ")", "\n", ...
// RegisterJSON registers an external JSON graph definition as a component // that can be instantiated at run-time using component Factory. // It returns true on success or false if component name is already taken.
[ "RegisterJSON", "registers", "an", "external", "JSON", "graph", "definition", "as", "a", "component", "that", "can", "be", "instantiated", "at", "run", "-", "time", "using", "component", "Factory", ".", "It", "returns", "true", "on", "success", "or", "false", ...
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/loader.go#L134-L140
19,492
trustmaster/goflow
factory.go
NewFactory
func NewFactory(config ...FactoryConfig) *Factory { conf := defaultFactoryConfig() if len(config) == 1 { conf = config[0] } return &Factory{ registry: make(map[string]registryEntry, conf.RegistryCapacity), } }
go
func NewFactory(config ...FactoryConfig) *Factory { conf := defaultFactoryConfig() if len(config) == 1 { conf = config[0] } return &Factory{ registry: make(map[string]registryEntry, conf.RegistryCapacity), } }
[ "func", "NewFactory", "(", "config", "...", "FactoryConfig", ")", "*", "Factory", "{", "conf", ":=", "defaultFactoryConfig", "(", ")", "\n", "if", "len", "(", "config", ")", "==", "1", "{", "conf", "=", "config", "[", "0", "]", "\n", "}", "\n\n", "re...
// NewFactory creates a new component Factory instance
[ "NewFactory", "creates", "a", "new", "component", "Factory", "instance" ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/factory.go#L43-L52
19,493
trustmaster/goflow
factory.go
Register
func (f *Factory) Register(componentName string, constructor Constructor) error { if _, exists := f.registry[componentName]; exists { return fmt.Errorf("Registry error: component '%s' already registered", componentName) } f.registry[componentName] = registryEntry{ Constructor: constructor, Info: ComponentInfo{...
go
func (f *Factory) Register(componentName string, constructor Constructor) error { if _, exists := f.registry[componentName]; exists { return fmt.Errorf("Registry error: component '%s' already registered", componentName) } f.registry[componentName] = registryEntry{ Constructor: constructor, Info: ComponentInfo{...
[ "func", "(", "f", "*", "Factory", ")", "Register", "(", "componentName", "string", ",", "constructor", "Constructor", ")", "error", "{", "if", "_", ",", "exists", ":=", "f", ".", "registry", "[", "componentName", "]", ";", "exists", "{", "return", "fmt",...
// Register registers a component so that it can be instantiated at run-time
[ "Register", "registers", "a", "component", "so", "that", "it", "can", "be", "instantiated", "at", "run", "-", "time" ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/factory.go#L55-L66
19,494
trustmaster/goflow
factory.go
Annotate
func (f *Factory) Annotate(componentName string, annotation Annotation) error { if _, exists := f.registry[componentName]; !exists { return fmt.Errorf("Registry annotation error: component '%s' is not registered", componentName) } entry := f.registry[componentName] entry.Info.Description = annotation.Description ...
go
func (f *Factory) Annotate(componentName string, annotation Annotation) error { if _, exists := f.registry[componentName]; !exists { return fmt.Errorf("Registry annotation error: component '%s' is not registered", componentName) } entry := f.registry[componentName] entry.Info.Description = annotation.Description ...
[ "func", "(", "f", "*", "Factory", ")", "Annotate", "(", "componentName", "string", ",", "annotation", "Annotation", ")", "error", "{", "if", "_", ",", "exists", ":=", "f", ".", "registry", "[", "componentName", "]", ";", "!", "exists", "{", "return", "...
// Annotate adds human-readable documentation for a component to the runtime
[ "Annotate", "adds", "human", "-", "readable", "documentation", "for", "a", "component", "to", "the", "runtime" ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/factory.go#L69-L78
19,495
trustmaster/goflow
factory.go
Unregister
func (f *Factory) Unregister(componentName string) error { if _, exists := f.registry[componentName]; exists { delete(f.registry, componentName) return nil } return fmt.Errorf("Registry error: component '%s' is not registered", componentName) }
go
func (f *Factory) Unregister(componentName string) error { if _, exists := f.registry[componentName]; exists { delete(f.registry, componentName) return nil } return fmt.Errorf("Registry error: component '%s' is not registered", componentName) }
[ "func", "(", "f", "*", "Factory", ")", "Unregister", "(", "componentName", "string", ")", "error", "{", "if", "_", ",", "exists", ":=", "f", ".", "registry", "[", "componentName", "]", ";", "exists", "{", "delete", "(", "f", ".", "registry", ",", "co...
// Unregister removes a component with a given name from the component registry and returns true // or returns false if no such component is registered.
[ "Unregister", "removes", "a", "component", "with", "a", "given", "name", "from", "the", "component", "registry", "and", "returns", "true", "or", "returns", "false", "if", "no", "such", "component", "is", "registered", "." ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/factory.go#L82-L88
19,496
trustmaster/goflow
factory.go
Create
func (f *Factory) Create(componentName string) (interface{}, error) { if info, exists := f.registry[componentName]; exists { return info.Constructor() } return nil, fmt.Errorf("Factory error: component '%s' does not exist", componentName) }
go
func (f *Factory) Create(componentName string) (interface{}, error) { if info, exists := f.registry[componentName]; exists { return info.Constructor() } return nil, fmt.Errorf("Factory error: component '%s' does not exist", componentName) }
[ "func", "(", "f", "*", "Factory", ")", "Create", "(", "componentName", "string", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "info", ",", "exists", ":=", "f", ".", "registry", "[", "componentName", "]", ";", "exists", "{", "return"...
// Create creates a new instance of a component registered under a specific name.
[ "Create", "creates", "a", "new", "instance", "of", "a", "component", "registered", "under", "a", "specific", "name", "." ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/factory.go#L91-L96
19,497
trustmaster/goflow
graph_connect.go
ConnectBuf
func (n *Graph) ConnectBuf(senderName, senderPort, receiverName, receiverPort string, bufferSize int) error { senderPortVal, err := n.getProcPort(senderName, senderPort, reflect.SendDir) if err != nil { return err } receiverPortVal, err := n.getProcPort(receiverName, receiverPort, reflect.RecvDir) if err != nil...
go
func (n *Graph) ConnectBuf(senderName, senderPort, receiverName, receiverPort string, bufferSize int) error { senderPortVal, err := n.getProcPort(senderName, senderPort, reflect.SendDir) if err != nil { return err } receiverPortVal, err := n.getProcPort(receiverName, receiverPort, reflect.RecvDir) if err != nil...
[ "func", "(", "n", "*", "Graph", ")", "ConnectBuf", "(", "senderName", ",", "senderPort", ",", "receiverName", ",", "receiverPort", "string", ",", "bufferSize", "int", ")", "error", "{", "senderPortVal", ",", "err", ":=", "n", ".", "getProcPort", "(", "send...
// ConnectBuf connects a sender to a receiver using a channel with a buffer of a given size. // It returns true on success or panics and returns false if error occurs.
[ "ConnectBuf", "connects", "a", "sender", "to", "a", "receiver", "using", "a", "channel", "with", "a", "buffer", "of", "a", "given", "size", ".", "It", "returns", "true", "on", "success", "or", "panics", "and", "returns", "false", "if", "error", "occurs", ...
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/graph_connect.go#L47-L106
19,498
trustmaster/goflow
graph_connect.go
getProcPort
func (n *Graph) getProcPort(procName, portName string, dir reflect.ChanDir) (reflect.Value, error) { nilValue := reflect.ValueOf(nil) // Ensure process exists proc, ok := n.procs[procName] if !ok { return nilValue, fmt.Errorf("Connect error: process '%s' not found", procName) } // Ensure sender is settable va...
go
func (n *Graph) getProcPort(procName, portName string, dir reflect.ChanDir) (reflect.Value, error) { nilValue := reflect.ValueOf(nil) // Ensure process exists proc, ok := n.procs[procName] if !ok { return nilValue, fmt.Errorf("Connect error: process '%s' not found", procName) } // Ensure sender is settable va...
[ "func", "(", "n", "*", "Graph", ")", "getProcPort", "(", "procName", ",", "portName", "string", ",", "dir", "reflect", ".", "ChanDir", ")", "(", "reflect", ".", "Value", ",", "error", ")", "{", "nilValue", ":=", "reflect", ".", "ValueOf", "(", "nil", ...
// getProcPort finds an assignable port field in one of the subprocesses
[ "getProcPort", "finds", "an", "assignable", "port", "field", "in", "one", "of", "the", "subprocesses" ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/graph_connect.go#L109-L169
19,499
trustmaster/goflow
graph_connect.go
findExistingChan
func (n *Graph) findExistingChan(proc, procPort string, dir reflect.ChanDir) reflect.Value { var channel reflect.Value // Find existing channel attached to the receiver for _, conn := range n.connections { var p portName if dir == reflect.SendDir { p = conn.src } else { p = conn.tgt } if p.port == pr...
go
func (n *Graph) findExistingChan(proc, procPort string, dir reflect.ChanDir) reflect.Value { var channel reflect.Value // Find existing channel attached to the receiver for _, conn := range n.connections { var p portName if dir == reflect.SendDir { p = conn.src } else { p = conn.tgt } if p.port == pr...
[ "func", "(", "n", "*", "Graph", ")", "findExistingChan", "(", "proc", ",", "procPort", "string", ",", "dir", "reflect", ".", "ChanDir", ")", "reflect", ".", "Value", "{", "var", "channel", "reflect", ".", "Value", "\n", "// Find existing channel attached to th...
// findExistingChan returns a channel attached to receiver if it already exists among connections
[ "findExistingChan", "returns", "a", "channel", "attached", "to", "receiver", "if", "it", "already", "exists", "among", "connections" ]
98ea6cda15a37b5df5b92f04daa4af10e58c1874
https://github.com/trustmaster/goflow/blob/98ea6cda15a37b5df5b92f04daa4af10e58c1874/graph_connect.go#L172-L188