id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
142,000
gosexy/gettext
gettext.go
cDomainName
func cDomainName(domain string) *C.char { if domain == "" { return nil } // The caller is responsible for freeing this up. return C.CString(domain) }
go
func cDomainName(domain string) *C.char { if domain == "" { return nil } // The caller is responsible for freeing this up. return C.CString(domain) }
[ "func", "cDomainName", "(", "domain", "string", ")", "*", "C", ".", "char", "{", "if", "domain", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n", "// The caller is responsible for freeing this up.", "return", "C", ".", "CString", "(", "domain", ")", ...
// cDomainName returns the domain name CString that can be nil.
[ "cDomainName", "returns", "the", "domain", "name", "CString", "that", "can", "be", "nil", "." ]
74466a0a0c4a62fea38f44aa161d4bbfbe79dd6b
https://github.com/gosexy/gettext/blob/74466a0a0c4a62fea38f44aa161d4bbfbe79dd6b/gettext.go#L213-L219
142,001
quasoft/memstore
memstore.go
Get
func (m *MemStore) Get(r *http.Request, name string) (*sessions.Session, error) { return sessions.GetRegistry(r).Get(m, name) }
go
func (m *MemStore) Get(r *http.Request, name string) (*sessions.Session, error) { return sessions.GetRegistry(r).Get(m, name) }
[ "func", "(", "m", "*", "MemStore", ")", "Get", "(", "r", "*", "http", ".", "Request", ",", "name", "string", ")", "(", "*", "sessions", ".", "Session", ",", "error", ")", "{", "return", "sessions", ".", "GetRegistry", "(", "r", ")", ".", "Get", "...
// Get returns a session for the given name after adding it to the registry. // // It returns a new session if the sessions doesn't exist. Access IsNew on // the session to check if it is an existing session or a new one. // // It returns a new session and an error if the session exists but could // not be decoded.
[ "Get", "returns", "a", "session", "for", "the", "given", "name", "after", "adding", "it", "to", "the", "registry", ".", "It", "returns", "a", "new", "session", "if", "the", "sessions", "doesn", "t", "exist", ".", "Access", "IsNew", "on", "the", "session"...
84a050167438e9a9344feb4d869289db0969b2fe
https://github.com/quasoft/memstore/blob/84a050167438e9a9344feb4d869289db0969b2fe/memstore.go#L62-L64
142,002
gopherjs/jsbuiltin
jsbuiltin.go
In
func In(key string, obj *js.Object) (ok bool, err error) { if obj == nil || obj == js.Undefined || TypeOf(obj) != TypeObject { return false, errors.New("obj not a JavaScript object") } return js.Global.Get("$jsbuiltin$").Call("infunc", key, obj).Bool(), nil }
go
func In(key string, obj *js.Object) (ok bool, err error) { if obj == nil || obj == js.Undefined || TypeOf(obj) != TypeObject { return false, errors.New("obj not a JavaScript object") } return js.Global.Get("$jsbuiltin$").Call("infunc", key, obj).Bool(), nil }
[ "func", "In", "(", "key", "string", ",", "obj", "*", "js", ".", "Object", ")", "(", "ok", "bool", ",", "err", "error", ")", "{", "if", "obj", "==", "nil", "||", "obj", "==", "js", ".", "Undefined", "||", "TypeOf", "(", "obj", ")", "!=", "TypeOb...
// In returns true if key is a member of obj. An error is returned if obj is not // a JavaScript object.
[ "In", "returns", "true", "if", "key", "is", "a", "member", "of", "obj", ".", "An", "error", "is", "returned", "if", "obj", "is", "not", "a", "JavaScript", "object", "." ]
50091555e127a1aecfeb33cf7101f6a47973b48e
https://github.com/gopherjs/jsbuiltin/blob/50091555e127a1aecfeb33cf7101f6a47973b48e/jsbuiltin.go#L93-L98
142,003
GeertJohan/yubigo
yubigo.go
buildWorkers
func (ya *YubiAuth) buildWorkers() { // Unexported (internal) method, so no locking. // create tls config tlsConfig := &tls.Config{} if !ya.verifyCertificate { tlsConfig.InsecureSkipVerify = true } // stop all existing workers for _, worker := range ya.workers { worker.stop <- true } // create new (empt...
go
func (ya *YubiAuth) buildWorkers() { // Unexported (internal) method, so no locking. // create tls config tlsConfig := &tls.Config{} if !ya.verifyCertificate { tlsConfig.InsecureSkipVerify = true } // stop all existing workers for _, worker := range ya.workers { worker.stop <- true } // create new (empt...
[ "func", "(", "ya", "*", "YubiAuth", ")", "buildWorkers", "(", ")", "{", "// Unexported (internal) method, so no locking.", "// create tls config", "tlsConfig", ":=", "&", "tls", ".", "Config", "{", "}", "\n", "if", "!", "ya", ".", "verifyCertificate", "{", "tlsC...
// Stops existing workers and creates new ones.
[ "Stops", "existing", "workers", "and", "creates", "new", "ones", "." ]
b1764f04aa9ba3c98a15084e7e13c1a69753e1da
https://github.com/GeertJohan/yubigo/blob/b1764f04aa9ba3c98a15084e7e13c1a69753e1da/yubigo.go#L209-L252
142,004
GeertJohan/yubigo
yubigo.go
UseHttps
func (ya *YubiAuth) UseHttps(useHttps bool) { // Lock ya.use.Lock() defer ya.use.Unlock() // change setting if useHttps { ya.protocol = "https://" } else { ya.protocol = "http://" } // no need to rebuild workers, they re-read ya.protocol on each request. }
go
func (ya *YubiAuth) UseHttps(useHttps bool) { // Lock ya.use.Lock() defer ya.use.Unlock() // change setting if useHttps { ya.protocol = "https://" } else { ya.protocol = "http://" } // no need to rebuild workers, they re-read ya.protocol on each request. }
[ "func", "(", "ya", "*", "YubiAuth", ")", "UseHttps", "(", "useHttps", "bool", ")", "{", "// Lock", "ya", ".", "use", ".", "Lock", "(", ")", "\n", "defer", "ya", ".", "use", ".", "Unlock", "(", ")", "\n\n", "// change setting", "if", "useHttps", "{", ...
// Enable or disable the use of https
[ "Enable", "or", "disable", "the", "use", "of", "https" ]
b1764f04aa9ba3c98a15084e7e13c1a69753e1da
https://github.com/GeertJohan/yubigo/blob/b1764f04aa9ba3c98a15084e7e13c1a69753e1da/yubigo.go#L275-L288
142,005
GeertJohan/yubigo
yubigo.go
HttpsVerifyCertificate
func (ya *YubiAuth) HttpsVerifyCertificate(verifyCertificate bool) { // Lock ya.use.Lock() defer ya.use.Unlock() // save setting ya.verifyCertificate = verifyCertificate // rebuild workers (client has to be changed) ya.buildWorkers() }
go
func (ya *YubiAuth) HttpsVerifyCertificate(verifyCertificate bool) { // Lock ya.use.Lock() defer ya.use.Unlock() // save setting ya.verifyCertificate = verifyCertificate // rebuild workers (client has to be changed) ya.buildWorkers() }
[ "func", "(", "ya", "*", "YubiAuth", ")", "HttpsVerifyCertificate", "(", "verifyCertificate", "bool", ")", "{", "// Lock", "ya", ".", "use", ".", "Lock", "(", ")", "\n", "defer", "ya", ".", "use", ".", "Unlock", "(", ")", "\n\n", "// save setting", "ya", ...
// Enable or disable https certificate verification // Disable this at your own risk.
[ "Enable", "or", "disable", "https", "certificate", "verification", "Disable", "this", "at", "your", "own", "risk", "." ]
b1764f04aa9ba3c98a15084e7e13c1a69753e1da
https://github.com/GeertJohan/yubigo/blob/b1764f04aa9ba3c98a15084e7e13c1a69753e1da/yubigo.go#L292-L302
142,006
GeertJohan/yubigo
yubigo.go
GetResultParameter
func (yr *YubiResponse) GetResultParameter(key string) (value string) { value, ok := yr.resultParameters[key] if !ok { value = "" } return value }
go
func (yr *YubiResponse) GetResultParameter(key string) (value string) { value, ok := yr.resultParameters[key] if !ok { value = "" } return value }
[ "func", "(", "yr", "*", "YubiResponse", ")", "GetResultParameter", "(", "key", "string", ")", "(", "value", "string", ")", "{", "value", ",", "ok", ":=", "yr", ".", "resultParameters", "[", "key", "]", "\n", "if", "!", "ok", "{", "value", "=", "\"", ...
// Retrieve a parameter from the api's response
[ "Retrieve", "a", "parameter", "from", "the", "api", "s", "response" ]
b1764f04aa9ba3c98a15084e7e13c1a69753e1da
https://github.com/GeertJohan/yubigo/blob/b1764f04aa9ba3c98a15084e7e13c1a69753e1da/yubigo.go#L559-L565
142,007
kpawlik/geojson
geometry.go
AddGeometry
func (t *Point) AddGeometry(g interface{}) error { if c, ok := g.(Coordinate); ok { t.Coordinates = c } else { return fmt.Errorf("AssertionError: %v to %v", g, "Coordinate") } return nil }
go
func (t *Point) AddGeometry(g interface{}) error { if c, ok := g.(Coordinate); ok { t.Coordinates = c } else { return fmt.Errorf("AssertionError: %v to %v", g, "Coordinate") } return nil }
[ "func", "(", "t", "*", "Point", ")", "AddGeometry", "(", "g", "interface", "{", "}", ")", "error", "{", "if", "c", ",", "ok", ":=", "g", ".", "(", "Coordinate", ")", ";", "ok", "{", "t", ".", "Coordinates", "=", "c", "\n", "}", "else", "{", "...
// AddGeometry adds geometry to coordinates. // New value will replace existing
[ "AddGeometry", "adds", "geometry", "to", "coordinates", ".", "New", "value", "will", "replace", "existing" ]
1a4f120c6b41bf523f825519ef8c25a50d1c9628
https://github.com/kpawlik/geojson/blob/1a4f120c6b41bf523f825519ef8c25a50d1c9628/geometry.go#L74-L81
142,008
kpawlik/geojson
geometry.go
AddCoordinates
func (t *MultiPoint) AddCoordinates(p ...Coordinate) { t.Coordinates = append(t.Coordinates, p...) }
go
func (t *MultiPoint) AddCoordinates(p ...Coordinate) { t.Coordinates = append(t.Coordinates, p...) }
[ "func", "(", "t", "*", "MultiPoint", ")", "AddCoordinates", "(", "p", "...", "Coordinate", ")", "{", "t", ".", "Coordinates", "=", "append", "(", "t", ".", "Coordinates", ",", "p", "...", ")", "\n", "}" ]
// Add new point to MultiPoint object
[ "Add", "new", "point", "to", "MultiPoint", "object" ]
1a4f120c6b41bf523f825519ef8c25a50d1c9628
https://github.com/kpawlik/geojson/blob/1a4f120c6b41bf523f825519ef8c25a50d1c9628/geometry.go#L125-L127
142,009
kpawlik/geojson
geometry.go
NewMultiPoint
func NewMultiPoint(coordinates Coordinates) *MultiPoint { if coordinates == nil { coordinates = make(Coordinates, 0, INIT_GEOM_CAP) } return &MultiPoint{Type: "MultiPoint", Coordinates: coordinates} }
go
func NewMultiPoint(coordinates Coordinates) *MultiPoint { if coordinates == nil { coordinates = make(Coordinates, 0, INIT_GEOM_CAP) } return &MultiPoint{Type: "MultiPoint", Coordinates: coordinates} }
[ "func", "NewMultiPoint", "(", "coordinates", "Coordinates", ")", "*", "MultiPoint", "{", "if", "coordinates", "==", "nil", "{", "coordinates", "=", "make", "(", "Coordinates", ",", "0", ",", "INIT_GEOM_CAP", ")", "\n", "}", "\n", "return", "&", "MultiPoint",...
//Factory function to create new object
[ "Factory", "function", "to", "create", "new", "object" ]
1a4f120c6b41bf523f825519ef8c25a50d1c9628
https://github.com/kpawlik/geojson/blob/1a4f120c6b41bf523f825519ef8c25a50d1c9628/geometry.go#L139-L144
142,010
kpawlik/geojson
geometry.go
NewLineString
func NewLineString(coordinates Coordinates) *LineString { if coordinates == nil { coordinates = make(Coordinates, 0, INIT_GEOM_CAP) } return &LineString{Type: "LineString", Coordinates: coordinates} }
go
func NewLineString(coordinates Coordinates) *LineString { if coordinates == nil { coordinates = make(Coordinates, 0, INIT_GEOM_CAP) } return &LineString{Type: "LineString", Coordinates: coordinates} }
[ "func", "NewLineString", "(", "coordinates", "Coordinates", ")", "*", "LineString", "{", "if", "coordinates", "==", "nil", "{", "coordinates", "=", "make", "(", "Coordinates", ",", "0", ",", "INIT_GEOM_CAP", ")", "\n", "}", "\n", "return", "&", "LineString",...
//Factory function to create new object with points
[ "Factory", "function", "to", "create", "new", "object", "with", "points" ]
1a4f120c6b41bf523f825519ef8c25a50d1c9628
https://github.com/kpawlik/geojson/blob/1a4f120c6b41bf523f825519ef8c25a50d1c9628/geometry.go#L187-L192
142,011
kpawlik/geojson
geometry.go
AddCoordinates
func (t *MultiLineString) AddCoordinates(coordinates ...Coordinates) { t.Coordinates = append(t.Coordinates, coordinates...) }
go
func (t *MultiLineString) AddCoordinates(coordinates ...Coordinates) { t.Coordinates = append(t.Coordinates, coordinates...) }
[ "func", "(", "t", "*", "MultiLineString", ")", "AddCoordinates", "(", "coordinates", "...", "Coordinates", ")", "{", "t", ".", "Coordinates", "=", "append", "(", "t", ".", "Coordinates", ",", "coordinates", "...", ")", "\n", "}" ]
// Add collection of coordinates to MultiLineString // new data are append
[ "Add", "collection", "of", "coordinates", "to", "MultiLineString", "new", "data", "are", "append" ]
1a4f120c6b41bf523f825519ef8c25a50d1c9628
https://github.com/kpawlik/geojson/blob/1a4f120c6b41bf523f825519ef8c25a50d1c9628/geometry.go#L226-L228
142,012
kpawlik/geojson
geometry.go
NewMultiLineString
func NewMultiLineString(coordinates MultiLine) *MultiLineString { if coordinates == nil { coordinates = make(MultiLine, 0, INIT_GEOM_CAP) } return &MultiLineString{Type: "MultiLineString", Coordinates: coordinates} }
go
func NewMultiLineString(coordinates MultiLine) *MultiLineString { if coordinates == nil { coordinates = make(MultiLine, 0, INIT_GEOM_CAP) } return &MultiLineString{Type: "MultiLineString", Coordinates: coordinates} }
[ "func", "NewMultiLineString", "(", "coordinates", "MultiLine", ")", "*", "MultiLineString", "{", "if", "coordinates", "==", "nil", "{", "coordinates", "=", "make", "(", "MultiLine", ",", "0", ",", "INIT_GEOM_CAP", ")", "\n", "}", "\n", "return", "&", "MultiL...
// Factory function for type MultiLineString
[ "Factory", "function", "for", "type", "MultiLineString" ]
1a4f120c6b41bf523f825519ef8c25a50d1c9628
https://github.com/kpawlik/geojson/blob/1a4f120c6b41bf523f825519ef8c25a50d1c9628/geometry.go#L240-L245
142,013
kpawlik/geojson
geometry.go
AddGeometry
func (t *Polygon) AddGeometry(g interface{}) error { switch c := g.(type) { case MultiLine: t.AddCoordinates(c...) break case Coordinates: t.AddCoordinates(c) break default: return errors.New(fmt.Sprintf("AssertionError %v", g)) } return nil }
go
func (t *Polygon) AddGeometry(g interface{}) error { switch c := g.(type) { case MultiLine: t.AddCoordinates(c...) break case Coordinates: t.AddCoordinates(c) break default: return errors.New(fmt.Sprintf("AssertionError %v", g)) } return nil }
[ "func", "(", "t", "*", "Polygon", ")", "AddGeometry", "(", "g", "interface", "{", "}", ")", "error", "{", "switch", "c", ":=", "g", ".", "(", "type", ")", "{", "case", "MultiLine", ":", "t", ".", "AddCoordinates", "(", "c", "...", ")", "\n", "bre...
// Add new polygon or hole to Polygon
[ "Add", "new", "polygon", "or", "hole", "to", "Polygon" ]
1a4f120c6b41bf523f825519ef8c25a50d1c9628
https://github.com/kpawlik/geojson/blob/1a4f120c6b41bf523f825519ef8c25a50d1c9628/geometry.go#L264-L276
142,014
kpawlik/geojson
geometry.go
AddGeometries
func (t *GeometryCollection) AddGeometries(g ...interface{}) { t.Geometries = append(t.Geometries, g...) }
go
func (t *GeometryCollection) AddGeometries(g ...interface{}) { t.Geometries = append(t.Geometries, g...) }
[ "func", "(", "t", "*", "GeometryCollection", ")", "AddGeometries", "(", "g", "...", "interface", "{", "}", ")", "{", "t", ".", "Geometries", "=", "append", "(", "t", ".", "Geometries", ",", "g", "...", ")", "\n", "}" ]
// AddGeometries appends new values to Geometries
[ "AddGeometries", "appends", "new", "values", "to", "Geometries" ]
1a4f120c6b41bf523f825519ef8c25a50d1c9628
https://github.com/kpawlik/geojson/blob/1a4f120c6b41bf523f825519ef8c25a50d1c9628/geometry.go#L380-L382
142,015
kpawlik/geojson
geometry.go
AddGeometry
func (t *GeometryCollection) AddGeometry(g interface{}) error { switch c := g.(type) { case []interface{}: t.AddGeometries(c...) break case interface{}: t.AddGeometries(c) break default: return errors.New(fmt.Sprintf("AssertionError %v", g)) } return nil }
go
func (t *GeometryCollection) AddGeometry(g interface{}) error { switch c := g.(type) { case []interface{}: t.AddGeometries(c...) break case interface{}: t.AddGeometries(c) break default: return errors.New(fmt.Sprintf("AssertionError %v", g)) } return nil }
[ "func", "(", "t", "*", "GeometryCollection", ")", "AddGeometry", "(", "g", "interface", "{", "}", ")", "error", "{", "switch", "c", ":=", "g", ".", "(", "type", ")", "{", "case", "[", "]", "interface", "{", "}", ":", "t", ".", "AddGeometries", "(",...
// AddGeometry add new geometry or hole to GeometryCollection
[ "AddGeometry", "add", "new", "geometry", "or", "hole", "to", "GeometryCollection" ]
1a4f120c6b41bf523f825519ef8c25a50d1c9628
https://github.com/kpawlik/geojson/blob/1a4f120c6b41bf523f825519ef8c25a50d1c9628/geometry.go#L385-L397
142,016
kpawlik/geojson
feature.go
NewFeature
func NewFeature(geom Geometry, properties map[string]interface{}, id interface{}) *Feature { return &Feature{Type: "Feature", Geometry: geom, Properties: properties, Id: id} }
go
func NewFeature(geom Geometry, properties map[string]interface{}, id interface{}) *Feature { return &Feature{Type: "Feature", Geometry: geom, Properties: properties, Id: id} }
[ "func", "NewFeature", "(", "geom", "Geometry", ",", "properties", "map", "[", "string", "]", "interface", "{", "}", ",", "id", "interface", "{", "}", ")", "*", "Feature", "{", "return", "&", "Feature", "{", "Type", ":", "\"", "\"", ",", "Geometry", "...
// Factory constructor method
[ "Factory", "constructor", "method" ]
1a4f120c6b41bf523f825519ef8c25a50d1c9628
https://github.com/kpawlik/geojson/blob/1a4f120c6b41bf523f825519ef8c25a50d1c9628/feature.go#L34-L40
142,017
kpawlik/geojson
feature.go
ParseGeometry
func ParseGeometry(gi interface{}) (geom Geometry, err error) { switch g := gi.(type) { case map[string]interface{}: coord := g["coordinates"] switch typ := g["type"]; typ { case "Point": return parsePoint(coord) case "LineString": return parseLineString(coord) case "MultiPoint": return parseMultiP...
go
func ParseGeometry(gi interface{}) (geom Geometry, err error) { switch g := gi.(type) { case map[string]interface{}: coord := g["coordinates"] switch typ := g["type"]; typ { case "Point": return parsePoint(coord) case "LineString": return parseLineString(coord) case "MultiPoint": return parseMultiP...
[ "func", "ParseGeometry", "(", "gi", "interface", "{", "}", ")", "(", "geom", "Geometry", ",", "err", "error", ")", "{", "switch", "g", ":=", "gi", ".", "(", "type", ")", "{", "case", "map", "[", "string", "]", "interface", "{", "}", ":", "coord", ...
// ParseGeometry parse and returns Geometry from generic interface
[ "ParseGeometry", "parse", "and", "returns", "Geometry", "from", "generic", "interface" ]
1a4f120c6b41bf523f825519ef8c25a50d1c9628
https://github.com/kpawlik/geojson/blob/1a4f120c6b41bf523f825519ef8c25a50d1c9628/feature.go#L215-L240
142,018
kpawlik/geojson
geojson.go
Marshal
func Marshal(object interface{}) (data string, err error) { if t, err := json.Marshal(object); err != nil { data = "" } else { data = string(t) } return }
go
func Marshal(object interface{}) (data string, err error) { if t, err := json.Marshal(object); err != nil { data = "" } else { data = string(t) } return }
[ "func", "Marshal", "(", "object", "interface", "{", "}", ")", "(", "data", "string", ",", "err", "error", ")", "{", "if", "t", ",", "err", ":=", "json", ".", "Marshal", "(", "object", ")", ";", "err", "!=", "nil", "{", "data", "=", "\"", "\"", ...
// Marshal object to json string representation
[ "Marshal", "object", "to", "json", "string", "representation" ]
1a4f120c6b41bf523f825519ef8c25a50d1c9628
https://github.com/kpawlik/geojson/blob/1a4f120c6b41bf523f825519ef8c25a50d1c9628/geojson.go#L13-L20
142,019
tcnksm/go-gitconfig
gitconfig.go
Repository
func Repository() (string, error) { url, err := OriginURL() if err != nil { return "", err } repo := retrieveRepoName(url) return repo, nil }
go
func Repository() (string, error) { url, err := OriginURL() if err != nil { return "", err } repo := retrieveRepoName(url) return repo, nil }
[ "func", "Repository", "(", ")", "(", "string", ",", "error", ")", "{", "url", ",", "err", ":=", "OriginURL", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "repo", ":=", "retrieveRepoName", "(", ...
// Repository extract repository name of current project repository.
[ "Repository", "extract", "repository", "name", "of", "current", "project", "repository", "." ]
6411ba19847f20afe47f603328d97aaeca6def6f
https://github.com/tcnksm/go-gitconfig/blob/6411ba19847f20afe47f603328d97aaeca6def6f/gitconfig.go#L80-L88
142,020
qor/publish
event.go
Publish
func (publishEvent *PublishEvent) Publish(db *gorm.DB) error { if event, ok := events[publishEvent.Name]; ok { err := event.Publish(db, publishEvent) if err == nil { var updateAttrs = map[string]interface{}{"PublishStatus": PUBLISHED} if user, hasUser := getCurrentUser(db); hasUser { updateAttrs["Publish...
go
func (publishEvent *PublishEvent) Publish(db *gorm.DB) error { if event, ok := events[publishEvent.Name]; ok { err := event.Publish(db, publishEvent) if err == nil { var updateAttrs = map[string]interface{}{"PublishStatus": PUBLISHED} if user, hasUser := getCurrentUser(db); hasUser { updateAttrs["Publish...
[ "func", "(", "publishEvent", "*", "PublishEvent", ")", "Publish", "(", "db", "*", "gorm", ".", "DB", ")", "error", "{", "if", "event", ",", "ok", ":=", "events", "[", "publishEvent", ".", "Name", "]", ";", "ok", "{", "err", ":=", "event", ".", "Pub...
// Publish publish data
[ "Publish", "publish", "data" ]
abfbacee9e0d575c2feb6200135ead56444067e7
https://github.com/qor/publish/blob/abfbacee9e0d575c2feb6200135ead56444067e7/event.go#L50-L63
142,021
qor/publish
publish.go
IsDraftMode
func IsDraftMode(db *gorm.DB) bool { if draftMode, ok := db.Get(publishDraftMode); ok { if isDraft, ok := draftMode.(bool); ok && isDraft { return true } } return false }
go
func IsDraftMode(db *gorm.DB) bool { if draftMode, ok := db.Get(publishDraftMode); ok { if isDraft, ok := draftMode.(bool); ok && isDraft { return true } } return false }
[ "func", "IsDraftMode", "(", "db", "*", "gorm", ".", "DB", ")", "bool", "{", "if", "draftMode", ",", "ok", ":=", "db", ".", "Get", "(", "publishDraftMode", ")", ";", "ok", "{", "if", "isDraft", ",", "ok", ":=", "draftMode", ".", "(", "bool", ")", ...
// IsDraftMode check if current db in draft mode
[ "IsDraftMode", "check", "if", "current", "db", "in", "draft", "mode" ]
abfbacee9e0d575c2feb6200135ead56444067e7
https://github.com/qor/publish/blob/abfbacee9e0d575c2feb6200135ead56444067e7/publish.go#L75-L82
142,022
qor/publish
publish.go
IsPublishEvent
func IsPublishEvent(model interface{}) (ok bool) { if model != nil { _, ok = reflect.New(utils.ModelType(model)).Interface().(PublishEventInterface) } return }
go
func IsPublishEvent(model interface{}) (ok bool) { if model != nil { _, ok = reflect.New(utils.ModelType(model)).Interface().(PublishEventInterface) } return }
[ "func", "IsPublishEvent", "(", "model", "interface", "{", "}", ")", "(", "ok", "bool", ")", "{", "if", "model", "!=", "nil", "{", "_", ",", "ok", "=", "reflect", ".", "New", "(", "utils", ".", "ModelType", "(", "model", ")", ")", ".", "Interface", ...
// IsPublishEvent check if current model is a publish event model
[ "IsPublishEvent", "check", "if", "current", "model", "is", "a", "publish", "event", "model" ]
abfbacee9e0d575c2feb6200135ead56444067e7
https://github.com/qor/publish/blob/abfbacee9e0d575c2feb6200135ead56444067e7/publish.go#L85-L90
142,023
qor/publish
publish.go
IsPublishableModel
func IsPublishableModel(model interface{}) (ok bool) { if model != nil { _, ok = reflect.New(utils.ModelType(model)).Interface().(publishInterface) } return }
go
func IsPublishableModel(model interface{}) (ok bool) { if model != nil { _, ok = reflect.New(utils.ModelType(model)).Interface().(publishInterface) } return }
[ "func", "IsPublishableModel", "(", "model", "interface", "{", "}", ")", "(", "ok", "bool", ")", "{", "if", "model", "!=", "nil", "{", "_", ",", "ok", "=", "reflect", ".", "New", "(", "utils", ".", "ModelType", "(", "model", ")", ")", ".", "Interfac...
// IsPublishableModel check if current model is a publishable
[ "IsPublishableModel", "check", "if", "current", "model", "is", "a", "publishable" ]
abfbacee9e0d575c2feb6200135ead56444067e7
https://github.com/qor/publish/blob/abfbacee9e0d575c2feb6200135ead56444067e7/publish.go#L93-L98
142,024
qor/publish
publish.go
AutoMigrate
func (pb *Publish) AutoMigrate(values ...interface{}) { for _, value := range values { tableName := pb.DB.NewScope(value).TableName() pb.DraftDB().Table(DraftTableName(tableName)).AutoMigrate(value) } }
go
func (pb *Publish) AutoMigrate(values ...interface{}) { for _, value := range values { tableName := pb.DB.NewScope(value).TableName() pb.DraftDB().Table(DraftTableName(tableName)).AutoMigrate(value) } }
[ "func", "(", "pb", "*", "Publish", ")", "AutoMigrate", "(", "values", "...", "interface", "{", "}", ")", "{", "for", "_", ",", "value", ":=", "range", "values", "{", "tableName", ":=", "pb", ".", "DB", ".", "NewScope", "(", "value", ")", ".", "Tabl...
// AutoMigrate run auto migrate in draft tables
[ "AutoMigrate", "run", "auto", "migrate", "in", "draft", "tables" ]
abfbacee9e0d575c2feb6200135ead56444067e7
https://github.com/qor/publish/blob/abfbacee9e0d575c2feb6200135ead56444067e7/publish.go#L177-L182
142,025
qor/publish
publish.go
ProductionDB
func (pb Publish) ProductionDB() *gorm.DB { return pb.DB.Set(publishDraftMode, false) }
go
func (pb Publish) ProductionDB() *gorm.DB { return pb.DB.Set(publishDraftMode, false) }
[ "func", "(", "pb", "Publish", ")", "ProductionDB", "(", ")", "*", "gorm", ".", "DB", "{", "return", "pb", ".", "DB", ".", "Set", "(", "publishDraftMode", ",", "false", ")", "\n", "}" ]
// ProductionDB get db in production mode
[ "ProductionDB", "get", "db", "in", "production", "mode" ]
abfbacee9e0d575c2feb6200135ead56444067e7
https://github.com/qor/publish/blob/abfbacee9e0d575c2feb6200135ead56444067e7/publish.go#L185-L187
142,026
qor/publish
publish.go
DraftDB
func (pb Publish) DraftDB() *gorm.DB { return pb.DB.Set(publishDraftMode, true) }
go
func (pb Publish) DraftDB() *gorm.DB { return pb.DB.Set(publishDraftMode, true) }
[ "func", "(", "pb", "Publish", ")", "DraftDB", "(", ")", "*", "gorm", ".", "DB", "{", "return", "pb", ".", "DB", ".", "Set", "(", "publishDraftMode", ",", "true", ")", "\n", "}" ]
// DraftDB get db in draft mode
[ "DraftDB", "get", "db", "in", "draft", "mode" ]
abfbacee9e0d575c2feb6200135ead56444067e7
https://github.com/qor/publish/blob/abfbacee9e0d575c2feb6200135ead56444067e7/publish.go#L190-L192
142,027
qor/publish
publish.go
Logger
func (pb Publish) Logger(l LoggerInterface) *Publish { return &Publish{ WorkerScheduler: pb.WorkerScheduler, DB: pb.DB, logger: l, deleteCallback: pb.deleteCallback, } }
go
func (pb Publish) Logger(l LoggerInterface) *Publish { return &Publish{ WorkerScheduler: pb.WorkerScheduler, DB: pb.DB, logger: l, deleteCallback: pb.deleteCallback, } }
[ "func", "(", "pb", "Publish", ")", "Logger", "(", "l", "LoggerInterface", ")", "*", "Publish", "{", "return", "&", "Publish", "{", "WorkerScheduler", ":", "pb", ".", "WorkerScheduler", ",", "DB", ":", "pb", ".", "DB", ",", "logger", ":", "l", ",", "d...
// Logger set logger that used to print publish logs
[ "Logger", "set", "logger", "that", "used", "to", "print", "publish", "logs" ]
abfbacee9e0d575c2feb6200135ead56444067e7
https://github.com/qor/publish/blob/abfbacee9e0d575c2feb6200135ead56444067e7/publish.go#L195-L202
142,028
qor/publish
worker.go
SetWorker
func (publish *Publish) SetWorker(w *worker.Worker) { publish.WorkerScheduler = w publish.registerWorkerJob() }
go
func (publish *Publish) SetWorker(w *worker.Worker) { publish.WorkerScheduler = w publish.registerWorkerJob() }
[ "func", "(", "publish", "*", "Publish", ")", "SetWorker", "(", "w", "*", "worker", ".", "Worker", ")", "{", "publish", ".", "WorkerScheduler", "=", "w", "\n", "publish", ".", "registerWorkerJob", "(", ")", "\n", "}" ]
// SetWorker set publish's worker
[ "SetWorker", "set", "publish", "s", "worker" ]
abfbacee9e0d575c2feb6200135ead56444067e7
https://github.com/qor/publish/blob/abfbacee9e0d575c2feb6200135ead56444067e7/worker.go#L28-L31
142,029
qor/publish
controller.go
ConfigureQorResourceBeforeInitialize
func (publish *Publish) ConfigureQorResourceBeforeInitialize(res resource.Resourcer) { if res, ok := res.(*admin.Resource); ok { res.GetAdmin().RegisterViewPath("github.com/qor/publish/views") res.UseTheme("publish") if event := res.GetAdmin().GetResource("PublishEvent"); event == nil { eventResource := res....
go
func (publish *Publish) ConfigureQorResourceBeforeInitialize(res resource.Resourcer) { if res, ok := res.(*admin.Resource); ok { res.GetAdmin().RegisterViewPath("github.com/qor/publish/views") res.UseTheme("publish") if event := res.GetAdmin().GetResource("PublishEvent"); event == nil { eventResource := res....
[ "func", "(", "publish", "*", "Publish", ")", "ConfigureQorResourceBeforeInitialize", "(", "res", "resource", ".", "Resourcer", ")", "{", "if", "res", ",", "ok", ":=", "res", ".", "(", "*", "admin", ".", "Resource", ")", ";", "ok", "{", "res", ".", "Get...
// ConfigureQorResourceBeforeInitialize configure qor resource when initialize qor admin
[ "ConfigureQorResourceBeforeInitialize", "configure", "qor", "resource", "when", "initialize", "qor", "admin" ]
abfbacee9e0d575c2feb6200135ead56444067e7
https://github.com/qor/publish/blob/abfbacee9e0d575c2feb6200135ead56444067e7/controller.go#L116-L126
142,030
lestrrat-go/server-starter
starter.go
SigFromName
func SigFromName(n string) os.Signal { n = strings.ToUpper(n) if strings.HasPrefix(n, "SIG") { n = n[3:] // remove SIG prefix } if sig, ok := niceNameToSigs[n]; ok { return sig } return nil }
go
func SigFromName(n string) os.Signal { n = strings.ToUpper(n) if strings.HasPrefix(n, "SIG") { n = n[3:] // remove SIG prefix } if sig, ok := niceNameToSigs[n]; ok { return sig } return nil }
[ "func", "SigFromName", "(", "n", "string", ")", "os", ".", "Signal", "{", "n", "=", "strings", ".", "ToUpper", "(", "n", ")", "\n", "if", "strings", ".", "HasPrefix", "(", "n", ",", "\"", "\"", ")", "{", "n", "=", "n", "[", "3", ":", "]", "//...
// SigFromName returns the signal corresponding to the given signal name string. // If the given name string is not defined, it returns nil.
[ "SigFromName", "returns", "the", "signal", "corresponding", "to", "the", "given", "signal", "name", "string", ".", "If", "the", "given", "name", "string", "is", "not", "defined", "it", "returns", "nil", "." ]
8564cc80d990ee80619b86b17946ceac65a4977d
https://github.com/lestrrat-go/server-starter/blob/8564cc80d990ee80619b86b17946ceac65a4977d/starter.go#L170-L180
142,031
lestrrat-go/server-starter
listener/listener.go
ListenAll
func ListenAll() ([]net.Listener, error) { targets, err := parseListenTargets(GetPortsSpecification()) if err != nil { return nil, err } ret := make([]net.Listener, len(targets)) for i, target := range targets { ret[i], err = target.Listen() if err != nil { // Close everything up to this listener for ...
go
func ListenAll() ([]net.Listener, error) { targets, err := parseListenTargets(GetPortsSpecification()) if err != nil { return nil, err } ret := make([]net.Listener, len(targets)) for i, target := range targets { ret[i], err = target.Listen() if err != nil { // Close everything up to this listener for ...
[ "func", "ListenAll", "(", ")", "(", "[", "]", "net", ".", "Listener", ",", "error", ")", "{", "targets", ",", "err", ":=", "parseListenTargets", "(", "GetPortsSpecification", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "...
// ListenAll parses environment variable SERVER_STARTER_PORT, and creates // net.Listener objects
[ "ListenAll", "parses", "environment", "variable", "SERVER_STARTER_PORT", "and", "creates", "net", ".", "Listener", "objects" ]
8564cc80d990ee80619b86b17946ceac65a4977d
https://github.com/lestrrat-go/server-starter/blob/8564cc80d990ee80619b86b17946ceac65a4977d/listener/listener.go#L152-L170
142,032
syntaqx/go-metrics-datadog
reporter.go
NewReporter
func NewReporter(r metrics.Registry, addr string, d time.Duration, options ...ReporterOption) (*Reporter, error) { if r == nil { r = metrics.DefaultRegistry } client, err := statsd.New(addr) if err != nil { return nil, err } reporter := &Reporter{ Client: client, Registry: r, interval: d, ss: ...
go
func NewReporter(r metrics.Registry, addr string, d time.Duration, options ...ReporterOption) (*Reporter, error) { if r == nil { r = metrics.DefaultRegistry } client, err := statsd.New(addr) if err != nil { return nil, err } reporter := &Reporter{ Client: client, Registry: r, interval: d, ss: ...
[ "func", "NewReporter", "(", "r", "metrics", ".", "Registry", ",", "addr", "string", ",", "d", "time", ".", "Duration", ",", "options", "...", "ReporterOption", ")", "(", "*", "Reporter", ",", "error", ")", "{", "if", "r", "==", "nil", "{", "r", "=", ...
// NewReporter creates a new Reporter with a pre-configured statsd client.
[ "NewReporter", "creates", "a", "new", "Reporter", "with", "a", "pre", "-", "configured", "statsd", "client", "." ]
312b31920cc58d05bd8f8b562c84928e8485b8d3
https://github.com/syntaqx/go-metrics-datadog/blob/312b31920cc58d05bd8f8b562c84928e8485b8d3/reporter.go#L40-L61
142,033
syntaqx/go-metrics-datadog
reporter.go
Flush
func (r *Reporter) Flush() { defer func() { if rec := recover(); rec != nil { handlePanic(rec) } }() for range time.Tick(r.interval) { if err := r.FlushOnce(); err != nil { log.Println(err) } } }
go
func (r *Reporter) Flush() { defer func() { if rec := recover(); rec != nil { handlePanic(rec) } }() for range time.Tick(r.interval) { if err := r.FlushOnce(); err != nil { log.Println(err) } } }
[ "func", "(", "r", "*", "Reporter", ")", "Flush", "(", ")", "{", "defer", "func", "(", ")", "{", "if", "rec", ":=", "recover", "(", ")", ";", "rec", "!=", "nil", "{", "handlePanic", "(", "rec", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "for...
// Flush is a blocking exporter function which reports metrics in the registry // to the statsd client, flushing every d duration
[ "Flush", "is", "a", "blocking", "exporter", "function", "which", "reports", "metrics", "in", "the", "registry", "to", "the", "statsd", "client", "flushing", "every", "d", "duration" ]
312b31920cc58d05bd8f8b562c84928e8485b8d3
https://github.com/syntaqx/go-metrics-datadog/blob/312b31920cc58d05bd8f8b562c84928e8485b8d3/reporter.go#L90-L102
142,034
segmentio/conf
source.go
NewEnvSource
func NewEnvSource(prefix string, env ...string) Source { vars := makeEnvVars(env) base := make([]string, 0, 10) if prefix != "" { base = append(base, prefix) } return SourceFunc(func(dst Map) (err error) { dst.Scan(func(path []string, item MapItem) { path = append(base, path...) path = append(path, ite...
go
func NewEnvSource(prefix string, env ...string) Source { vars := makeEnvVars(env) base := make([]string, 0, 10) if prefix != "" { base = append(base, prefix) } return SourceFunc(func(dst Map) (err error) { dst.Scan(func(path []string, item MapItem) { path = append(base, path...) path = append(path, ite...
[ "func", "NewEnvSource", "(", "prefix", "string", ",", "env", "...", "string", ")", "Source", "{", "vars", ":=", "makeEnvVars", "(", "env", ")", "\n", "base", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "10", ")", "\n\n", "if", "prefix", "...
// NewEnvSource creates a new source which loads values from the environment // variables given in env. // // A prefix may be set to namespace the environment variables that the source // will be looking at.
[ "NewEnvSource", "creates", "a", "new", "source", "which", "loads", "values", "from", "the", "environment", "variables", "given", "in", "env", ".", "A", "prefix", "may", "be", "set", "to", "namespace", "the", "environment", "variables", "that", "the", "source",...
f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181
https://github.com/segmentio/conf/blob/f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181/source.go#L54-L77
142,035
segmentio/conf
load.go
Load
func Load(cfg interface{}) (args []string) { _, args = LoadWith(cfg, defaultLoader(os.Args, os.Environ())) return }
go
func Load(cfg interface{}) (args []string) { _, args = LoadWith(cfg, defaultLoader(os.Args, os.Environ())) return }
[ "func", "Load", "(", "cfg", "interface", "{", "}", ")", "(", "args", "[", "]", "string", ")", "{", "_", ",", "args", "=", "LoadWith", "(", "cfg", ",", "defaultLoader", "(", "os", ".", "Args", ",", "os", ".", "Environ", "(", ")", ")", ")", "\n",...
// Load the program's configuration into cfg, and returns the list of leftover // arguments. // // The cfg argument is expected to be a pointer to a struct type where exported // fields or fields with a "conf" tag will be used to load the program // configuration. // The function panics if cfg is not a pointer to struc...
[ "Load", "the", "program", "s", "configuration", "into", "cfg", "and", "returns", "the", "list", "of", "leftover", "arguments", ".", "The", "cfg", "argument", "is", "expected", "to", "be", "a", "pointer", "to", "a", "struct", "type", "where", "exported", "f...
f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181
https://github.com/segmentio/conf/blob/f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181/load.go#L50-L53
142,036
segmentio/conf
load.go
LoadWith
func LoadWith(cfg interface{}, ld Loader) (cmd string, args []string) { var err error switch cmd, args, err = ld.Load(cfg); err { case nil: case flag.ErrHelp: ld.PrintHelp(cfg) os.Exit(0) default: ld.PrintHelp(cfg) ld.PrintError(err) os.Exit(1) } return }
go
func LoadWith(cfg interface{}, ld Loader) (cmd string, args []string) { var err error switch cmd, args, err = ld.Load(cfg); err { case nil: case flag.ErrHelp: ld.PrintHelp(cfg) os.Exit(0) default: ld.PrintHelp(cfg) ld.PrintError(err) os.Exit(1) } return }
[ "func", "LoadWith", "(", "cfg", "interface", "{", "}", ",", "ld", "Loader", ")", "(", "cmd", "string", ",", "args", "[", "]", "string", ")", "{", "var", "err", "error", "\n", "switch", "cmd", ",", "args", ",", "err", "=", "ld", ".", "Load", "(", ...
// LoadWith behaves like Load but uses ld as a loader to parse the program // configuration. // // The function panics if cfg is not a pointer to struct, or if it's a nil // pointer and no commands were set.
[ "LoadWith", "behaves", "like", "Load", "but", "uses", "ld", "as", "a", "loader", "to", "parse", "the", "program", "configuration", ".", "The", "function", "panics", "if", "cfg", "is", "not", "a", "pointer", "to", "struct", "or", "if", "it", "s", "a", "...
f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181
https://github.com/segmentio/conf/blob/f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181/load.go#L60-L73
142,037
segmentio/conf
pprof.go
SetPPROF
func SetPPROF(config PPROF) { runtime.SetBlockProfileRate(config.BlockProfileRate) runtime.SetMutexProfileFraction(config.MutexProfileFraction) }
go
func SetPPROF(config PPROF) { runtime.SetBlockProfileRate(config.BlockProfileRate) runtime.SetMutexProfileFraction(config.MutexProfileFraction) }
[ "func", "SetPPROF", "(", "config", "PPROF", ")", "{", "runtime", ".", "SetBlockProfileRate", "(", "config", ".", "BlockProfileRate", ")", "\n", "runtime", ".", "SetMutexProfileFraction", "(", "config", ".", "MutexProfileFraction", ")", "\n", "}" ]
// SetPPROF configures the runtime profilers based on the given PPROF config.
[ "SetPPROF", "configures", "the", "runtime", "profilers", "based", "on", "the", "given", "PPROF", "config", "." ]
f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181
https://github.com/segmentio/conf/blob/f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181/pprof.go#L31-L34
142,038
segmentio/conf
node.go
EqualNode
func EqualNode(n1 Node, n2 Node) bool { if n1 == nil || n2 == nil { return n1 == n2 } k1 := n1.Kind() k2 := n2.Kind() if k1 != k2 { return false } switch k1 { case ArrayNode: return equalNodeArray(n1.(Array), n2.(Array)) case MapNode: return equalNodeMap(n1.(Map), n2.(Map)) default: return equalN...
go
func EqualNode(n1 Node, n2 Node) bool { if n1 == nil || n2 == nil { return n1 == n2 } k1 := n1.Kind() k2 := n2.Kind() if k1 != k2 { return false } switch k1 { case ArrayNode: return equalNodeArray(n1.(Array), n2.(Array)) case MapNode: return equalNodeMap(n1.(Map), n2.(Map)) default: return equalN...
[ "func", "EqualNode", "(", "n1", "Node", ",", "n2", "Node", ")", "bool", "{", "if", "n1", "==", "nil", "||", "n2", "==", "nil", "{", "return", "n1", "==", "n2", "\n", "}", "\n\n", "k1", ":=", "n1", ".", "Kind", "(", ")", "\n", "k2", ":=", "n2"...
// EqualNode compares n1 and n2, returning true if they are deeply equal.
[ "EqualNode", "compares", "n1", "and", "n2", "returning", "true", "if", "they", "are", "deeply", "equal", "." ]
f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181
https://github.com/segmentio/conf/blob/f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181/node.go#L47-L67
142,039
segmentio/conf
node.go
populateNodeStruct
func populateNodeStruct(originalT reflect.Type, path string, v reflect.Value, t reflect.Type, m Map) { for i, n := 0, v.NumField(); i != n; i++ { fv := v.Field(i) ft := t.Field(i) if !isExported(ft) { continue } name, help := ft.Tag.Get("conf"), ft.Tag.Get("help") switch name { case "-": continu...
go
func populateNodeStruct(originalT reflect.Type, path string, v reflect.Value, t reflect.Type, m Map) { for i, n := 0, v.NumField(); i != n; i++ { fv := v.Field(i) ft := t.Field(i) if !isExported(ft) { continue } name, help := ft.Tag.Get("conf"), ft.Tag.Get("help") switch name { case "-": continu...
[ "func", "populateNodeStruct", "(", "originalT", "reflect", ".", "Type", ",", "path", "string", ",", "v", "reflect", ".", "Value", ",", "t", "reflect", ".", "Type", ",", "m", "Map", ")", "{", "for", "i", ",", "n", ":=", "0", ",", "v", ".", "NumField...
// populateNodeStruct is the mutually recursive helper of makeNodeStruct to create the node struct with potentially // embedded types. It will populate m with the struct fields from v. The original type and path of the current field // are passed in order to create decent panic strings if an invalid configuration is ...
[ "populateNodeStruct", "is", "the", "mutually", "recursive", "helper", "of", "makeNodeStruct", "to", "create", "the", "node", "struct", "with", "potentially", "embedded", "types", ".", "It", "will", "populate", "m", "with", "the", "struct", "fields", "from", "v",...
f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181
https://github.com/segmentio/conf/blob/f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181/node.go#L198-L229
142,040
segmentio/conf
print.go
PrintError
func (ld Loader) PrintError(err error) { w := bufio.NewWriter(os.Stderr) ld.fprintError(w, err, stderr()) w.Flush() }
go
func (ld Loader) PrintError(err error) { w := bufio.NewWriter(os.Stderr) ld.fprintError(w, err, stderr()) w.Flush() }
[ "func", "(", "ld", "Loader", ")", "PrintError", "(", "err", "error", ")", "{", "w", ":=", "bufio", ".", "NewWriter", "(", "os", ".", "Stderr", ")", "\n", "ld", ".", "fprintError", "(", "w", ",", "err", ",", "stderr", "(", ")", ")", "\n", "w", "...
// PrintError outputs the error message for err to stderr.
[ "PrintError", "outputs", "the", "error", "message", "for", "err", "to", "stderr", "." ]
f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181
https://github.com/segmentio/conf/blob/f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181/print.go#L16-L20
142,041
segmentio/conf
print.go
FprintError
func (ld Loader) FprintError(w io.Writer, err error) { ld.fprintError(w, err, monochrome()) }
go
func (ld Loader) FprintError(w io.Writer, err error) { ld.fprintError(w, err, monochrome()) }
[ "func", "(", "ld", "Loader", ")", "FprintError", "(", "w", "io", ".", "Writer", ",", "err", "error", ")", "{", "ld", ".", "fprintError", "(", "w", ",", "err", ",", "monochrome", "(", ")", ")", "\n", "}" ]
// FprintError outputs the error message for err to w.
[ "FprintError", "outputs", "the", "error", "message", "for", "err", "to", "w", "." ]
f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181
https://github.com/segmentio/conf/blob/f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181/print.go#L23-L25
142,042
segmentio/conf
print.go
PrintHelp
func (ld Loader) PrintHelp(cfg interface{}) { w := bufio.NewWriter(os.Stderr) ld.fprintHelp(w, cfg, stderr()) w.Flush() }
go
func (ld Loader) PrintHelp(cfg interface{}) { w := bufio.NewWriter(os.Stderr) ld.fprintHelp(w, cfg, stderr()) w.Flush() }
[ "func", "(", "ld", "Loader", ")", "PrintHelp", "(", "cfg", "interface", "{", "}", ")", "{", "w", ":=", "bufio", ".", "NewWriter", "(", "os", ".", "Stderr", ")", "\n", "ld", ".", "fprintHelp", "(", "w", ",", "cfg", ",", "stderr", "(", ")", ")", ...
// PrintHelp outputs the help message for cfg to stderr.
[ "PrintHelp", "outputs", "the", "help", "message", "for", "cfg", "to", "stderr", "." ]
f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181
https://github.com/segmentio/conf/blob/f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181/print.go#L28-L32
142,043
segmentio/conf
print.go
FprintHelp
func (ld Loader) FprintHelp(w io.Writer, cfg interface{}) { ld.fprintHelp(w, cfg, monochrome()) }
go
func (ld Loader) FprintHelp(w io.Writer, cfg interface{}) { ld.fprintHelp(w, cfg, monochrome()) }
[ "func", "(", "ld", "Loader", ")", "FprintHelp", "(", "w", "io", ".", "Writer", ",", "cfg", "interface", "{", "}", ")", "{", "ld", ".", "fprintHelp", "(", "w", ",", "cfg", ",", "monochrome", "(", ")", ")", "\n", "}" ]
// FprintHelp outputs the help message for cfg to w.
[ "FprintHelp", "outputs", "the", "help", "message", "for", "cfg", "to", "w", "." ]
f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181
https://github.com/segmentio/conf/blob/f8f7ef2f578cf3bf3179c3d06f95cd2f676e7181/print.go#L35-L37
142,044
mwitkow/go-http-dialer
auth.go
AuthBasic
func AuthBasic(username string, password string) ProxyAuthorization { return &basicAuth{username: username, password: password} }
go
func AuthBasic(username string, password string) ProxyAuthorization { return &basicAuth{username: username, password: password} }
[ "func", "AuthBasic", "(", "username", "string", ",", "password", "string", ")", "ProxyAuthorization", "{", "return", "&", "basicAuth", "{", "username", ":", "username", ",", "password", ":", "password", "}", "\n", "}" ]
// AuthBasic returns a ProxyAuthorization that implements "Basic" protocol while ignoring realm challanges.
[ "AuthBasic", "returns", "a", "ProxyAuthorization", "that", "implements", "Basic", "protocol", "while", "ignoring", "realm", "challanges", "." ]
378f744fb2b81a6b96e3f40cde4f3bcab5a9cff0
https://github.com/mwitkow/go-http-dialer/blob/378f744fb2b81a6b96e3f40cde4f3bcab5a9cff0/auth.go#L34-L36
142,045
mwitkow/go-http-dialer
dialer.go
WithDialer
func WithDialer(dialer *net.Dialer) opt { return func(t *HttpTunnel) { t.parentDialer = dialer } }
go
func WithDialer(dialer *net.Dialer) opt { return func(t *HttpTunnel) { t.parentDialer = dialer } }
[ "func", "WithDialer", "(", "dialer", "*", "net", ".", "Dialer", ")", "opt", "{", "return", "func", "(", "t", "*", "HttpTunnel", ")", "{", "t", ".", "parentDialer", "=", "dialer", "\n", "}", "\n", "}" ]
// WithDialer allows the customization of the underlying net.Dialer used for establishing TCP connections to the proxy.
[ "WithDialer", "allows", "the", "customization", "of", "the", "underlying", "net", ".", "Dialer", "used", "for", "establishing", "TCP", "connections", "to", "the", "proxy", "." ]
378f744fb2b81a6b96e3f40cde4f3bcab5a9cff0
https://github.com/mwitkow/go-http-dialer/blob/378f744fb2b81a6b96e3f40cde4f3bcab5a9cff0/dialer.go#L44-L48
142,046
mwitkow/go-http-dialer
dialer.go
WithConnectionTimeout
func WithConnectionTimeout(timeout time.Duration) opt { return func(t *HttpTunnel) { t.parentDialer.Timeout = timeout } }
go
func WithConnectionTimeout(timeout time.Duration) opt { return func(t *HttpTunnel) { t.parentDialer.Timeout = timeout } }
[ "func", "WithConnectionTimeout", "(", "timeout", "time", ".", "Duration", ")", "opt", "{", "return", "func", "(", "t", "*", "HttpTunnel", ")", "{", "t", ".", "parentDialer", ".", "Timeout", "=", "timeout", "\n", "}", "\n", "}" ]
// WithConnectionTimeout customizes the underlying net.Dialer.Timeout.
[ "WithConnectionTimeout", "customizes", "the", "underlying", "net", ".", "Dialer", ".", "Timeout", "." ]
378f744fb2b81a6b96e3f40cde4f3bcab5a9cff0
https://github.com/mwitkow/go-http-dialer/blob/378f744fb2b81a6b96e3f40cde4f3bcab5a9cff0/dialer.go#L51-L55
142,047
mwitkow/go-http-dialer
dialer.go
Dial
func (t *HttpTunnel) Dial(network string, address string) (net.Conn, error) { if network != "tcp" { return nil, fmt.Errorf("network type '%v' unsupported (only 'tcp')", network) } conn, err := t.dialProxy() if err != nil { return nil, fmt.Errorf("http_tunnel: failed dialing to proxy: %v", err) } req := &http....
go
func (t *HttpTunnel) Dial(network string, address string) (net.Conn, error) { if network != "tcp" { return nil, fmt.Errorf("network type '%v' unsupported (only 'tcp')", network) } conn, err := t.dialProxy() if err != nil { return nil, fmt.Errorf("http_tunnel: failed dialing to proxy: %v", err) } req := &http....
[ "func", "(", "t", "*", "HttpTunnel", ")", "Dial", "(", "network", "string", ",", "address", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "if", "network", "!=", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "...
// Dial is an implementation of net.Dialer, and returns a TCP connection handle to the host that HTTP CONNECT reached.
[ "Dial", "is", "an", "implementation", "of", "net", ".", "Dialer", "and", "returns", "a", "TCP", "connection", "handle", "to", "the", "host", "that", "HTTP", "CONNECT", "reached", "." ]
378f744fb2b81a6b96e3f40cde4f3bcab5a9cff0
https://github.com/mwitkow/go-http-dialer/blob/378f744fb2b81a6b96e3f40cde4f3bcab5a9cff0/dialer.go#L96-L138
142,048
honeybadger-io/honeybadger-go
client.go
New
func New(c Configuration) *Client { config := newConfig(c) worker := newBufferedWorker(config) client := Client{ Config: config, worker: worker, context: newContextSync(), } return &client }
go
func New(c Configuration) *Client { config := newConfig(c) worker := newBufferedWorker(config) client := Client{ Config: config, worker: worker, context: newContextSync(), } return &client }
[ "func", "New", "(", "c", "Configuration", ")", "*", "Client", "{", "config", ":=", "newConfig", "(", "c", ")", "\n", "worker", ":=", "newBufferedWorker", "(", "config", ")", "\n\n", "client", ":=", "Client", "{", "Config", ":", "config", ",", "worker", ...
// New returns a new instance of Client.
[ "New", "returns", "a", "new", "instance", "of", "Client", "." ]
28b7a182233ede2d94641c95cb09dd918678f447
https://github.com/honeybadger-io/honeybadger-go/blob/28b7a182233ede2d94641c95cb09dd918678f447/client.go#L104-L115
142,049
zeebo/bencode
tag.go
Contains
func (options tagOptions) Contains(optionName string) bool { s := string(options) for s != "" { var next string i := strings.Index(s, ",") if i >= 0 { s, next = s[:i], s[i+1:] } if s == optionName { return true } s = next } return false }
go
func (options tagOptions) Contains(optionName string) bool { s := string(options) for s != "" { var next string i := strings.Index(s, ",") if i >= 0 { s, next = s[:i], s[i+1:] } if s == optionName { return true } s = next } return false }
[ "func", "(", "options", "tagOptions", ")", "Contains", "(", "optionName", "string", ")", "bool", "{", "s", ":=", "string", "(", "options", ")", "\n", "for", "s", "!=", "\"", "\"", "{", "var", "next", "string", "\n", "i", ":=", "strings", ".", "Index"...
// Contains returns whether checks that a comma-separated list of options // contains a particular substr flag. substr must be surrounded by a // string boundary or commas.
[ "Contains", "returns", "whether", "checks", "that", "a", "comma", "-", "separated", "list", "of", "options", "contains", "a", "particular", "substr", "flag", ".", "substr", "must", "be", "surrounded", "by", "a", "string", "boundary", "or", "commas", "." ]
cf5003e89e5a68181295c9383cd3329ef85549ac
https://github.com/zeebo/bencode/blob/cf5003e89e5a68181295c9383cd3329ef85549ac/tag.go#L25-L39
142,050
zeebo/bencode
encode.go
Encode
func (e *Encoder) Encode(val interface{}) error { return encodeValue(e.w, reflect.ValueOf(val)) }
go
func (e *Encoder) Encode(val interface{}) error { return encodeValue(e.w, reflect.ValueOf(val)) }
[ "func", "(", "e", "*", "Encoder", ")", "Encode", "(", "val", "interface", "{", "}", ")", "error", "{", "return", "encodeValue", "(", "e", ".", "w", ",", "reflect", ".", "ValueOf", "(", "val", ")", ")", "\n", "}" ]
// Encode writes the bencoded data of val to its output stream. // If an encountered value implements the Marshaler interface, // its MarshalBencode method is called to produce the bencode output for this value. // If no MarshalBencode method is present but the value implements encoding.TextMarshaler instead, // its Ma...
[ "Encode", "writes", "the", "bencoded", "data", "of", "val", "to", "its", "output", "stream", ".", "If", "an", "encountered", "value", "implements", "the", "Marshaler", "interface", "its", "MarshalBencode", "method", "is", "called", "to", "produce", "the", "ben...
cf5003e89e5a68181295c9383cd3329ef85549ac
https://github.com/zeebo/bencode/blob/cf5003e89e5a68181295c9383cd3329ef85549ac/encode.go#L41-L43
142,051
zeebo/bencode
encode.go
EncodeString
func EncodeString(val interface{}) (string, error) { buf := new(bytes.Buffer) e := NewEncoder(buf) if err := e.Encode(val); err != nil { return "", err } return buf.String(), nil }
go
func EncodeString(val interface{}) (string, error) { buf := new(bytes.Buffer) e := NewEncoder(buf) if err := e.Encode(val); err != nil { return "", err } return buf.String(), nil }
[ "func", "EncodeString", "(", "val", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n", "e", ":=", "NewEncoder", "(", "buf", ")", "\n", "if", "err", ":=", "e", ".", "Encod...
// EncodeString returns the bencoded data of val as a string.
[ "EncodeString", "returns", "the", "bencoded", "data", "of", "val", "as", "a", "string", "." ]
cf5003e89e5a68181295c9383cd3329ef85549ac
https://github.com/zeebo/bencode/blob/cf5003e89e5a68181295c9383cd3329ef85549ac/encode.go#L46-L53
142,052
zeebo/bencode
encode.go
EncodeBytes
func EncodeBytes(val interface{}) ([]byte, error) { buf := new(bytes.Buffer) e := NewEncoder(buf) if err := e.Encode(val); err != nil { return nil, err } return buf.Bytes(), nil }
go
func EncodeBytes(val interface{}) ([]byte, error) { buf := new(bytes.Buffer) e := NewEncoder(buf) if err := e.Encode(val); err != nil { return nil, err } return buf.Bytes(), nil }
[ "func", "EncodeBytes", "(", "val", "interface", "{", "}", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n", "e", ":=", "NewEncoder", "(", "buf", ")", "\n", "if", "err", ":=", "e", "....
// EncodeBytes returns the bencoded data of val as a slice of bytes.
[ "EncodeBytes", "returns", "the", "bencoded", "data", "of", "val", "as", "a", "slice", "of", "bytes", "." ]
cf5003e89e5a68181295c9383cd3329ef85549ac
https://github.com/zeebo/bencode/blob/cf5003e89e5a68181295c9383cd3329ef85549ac/encode.go#L56-L63
142,053
zeebo/bencode
decode.go
read
func (d *Decoder) read(p []byte) (n int, err error) { n, err = d.r.Read(p) if d.raw { d.buf = append(d.buf, p[:n]...) } d.n += n return }
go
func (d *Decoder) read(p []byte) (n int, err error) { n, err = d.r.Read(p) if d.raw { d.buf = append(d.buf, p[:n]...) } d.n += n return }
[ "func", "(", "d", "*", "Decoder", ")", "read", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "n", ",", "err", "=", "d", ".", "r", ".", "Read", "(", "p", ")", "\n", "if", "d", ".", "raw", "{", "d", ".",...
// read also writes into the buffer when d.raw is set.
[ "read", "also", "writes", "into", "the", "buffer", "when", "d", ".", "raw", "is", "set", "." ]
cf5003e89e5a68181295c9383cd3329ef85549ac
https://github.com/zeebo/bencode/blob/cf5003e89e5a68181295c9383cd3329ef85549ac/decode.go#L49-L56
142,054
zeebo/bencode
decode.go
readBytes
func (d *Decoder) readBytes(delim byte) (line []byte, err error) { line, err = d.r.ReadBytes(delim) if d.raw { d.buf = append(d.buf, line...) } d.n += len(line) return }
go
func (d *Decoder) readBytes(delim byte) (line []byte, err error) { line, err = d.r.ReadBytes(delim) if d.raw { d.buf = append(d.buf, line...) } d.n += len(line) return }
[ "func", "(", "d", "*", "Decoder", ")", "readBytes", "(", "delim", "byte", ")", "(", "line", "[", "]", "byte", ",", "err", "error", ")", "{", "line", ",", "err", "=", "d", ".", "r", ".", "ReadBytes", "(", "delim", ")", "\n", "if", "d", ".", "r...
// readBytes also writes into the buffer when d.raw is set.
[ "readBytes", "also", "writes", "into", "the", "buffer", "when", "d", ".", "raw", "is", "set", "." ]
cf5003e89e5a68181295c9383cd3329ef85549ac
https://github.com/zeebo/bencode/blob/cf5003e89e5a68181295c9383cd3329ef85549ac/decode.go#L59-L66
142,055
zeebo/bencode
decode.go
readByte
func (d *Decoder) readByte() (b byte, err error) { b, err = d.r.ReadByte() if d.raw { d.buf = append(d.buf, b) } d.n++ return }
go
func (d *Decoder) readByte() (b byte, err error) { b, err = d.r.ReadByte() if d.raw { d.buf = append(d.buf, b) } d.n++ return }
[ "func", "(", "d", "*", "Decoder", ")", "readByte", "(", ")", "(", "b", "byte", ",", "err", "error", ")", "{", "b", ",", "err", "=", "d", ".", "r", ".", "ReadByte", "(", ")", "\n", "if", "d", ".", "raw", "{", "d", ".", "buf", "=", "append", ...
// readByte also writes into the buffer when d.raw is set.
[ "readByte", "also", "writes", "into", "the", "buffer", "when", "d", ".", "raw", "is", "set", "." ]
cf5003e89e5a68181295c9383cd3329ef85549ac
https://github.com/zeebo/bencode/blob/cf5003e89e5a68181295c9383cd3329ef85549ac/decode.go#L69-L76
142,056
zeebo/bencode
decode.go
readFull
func (d *Decoder) readFull(p []byte) (n int, err error) { n, err = io.ReadFull(d.r, p) if d.raw { d.buf = append(d.buf, p[:n]...) } d.n += n return }
go
func (d *Decoder) readFull(p []byte) (n int, err error) { n, err = io.ReadFull(d.r, p) if d.raw { d.buf = append(d.buf, p[:n]...) } d.n += n return }
[ "func", "(", "d", "*", "Decoder", ")", "readFull", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "n", ",", "err", "=", "io", ".", "ReadFull", "(", "d", ".", "r", ",", "p", ")", "\n", "if", "d", ".", "raw...
// readFull also writes into the buffer when d.raw is set.
[ "readFull", "also", "writes", "into", "the", "buffer", "when", "d", ".", "raw", "is", "set", "." ]
cf5003e89e5a68181295c9383cd3329ef85549ac
https://github.com/zeebo/bencode/blob/cf5003e89e5a68181295c9383cd3329ef85549ac/decode.go#L79-L86
142,057
zeebo/bencode
decode.go
DecodeString
func DecodeString(in string, val interface{}) error { buf := strings.NewReader(in) d := NewDecoder(buf) return d.Decode(val) }
go
func DecodeString(in string, val interface{}) error { buf := strings.NewReader(in) d := NewDecoder(buf) return d.Decode(val) }
[ "func", "DecodeString", "(", "in", "string", ",", "val", "interface", "{", "}", ")", "error", "{", "buf", ":=", "strings", ".", "NewReader", "(", "in", ")", "\n", "d", ":=", "NewDecoder", "(", "buf", ")", "\n", "return", "d", ".", "Decode", "(", "v...
// DecodeString reads the data in the string and stores it into the value pointed to by val. // Read the docs for Decode for more information.
[ "DecodeString", "reads", "the", "data", "in", "the", "string", "and", "stores", "it", "into", "the", "value", "pointed", "to", "by", "val", ".", "Read", "the", "docs", "for", "Decode", "for", "more", "information", "." ]
cf5003e89e5a68181295c9383cd3329ef85549ac
https://github.com/zeebo/bencode/blob/cf5003e89e5a68181295c9383cd3329ef85549ac/decode.go#L125-L129
142,058
zeebo/bencode
decode.go
DecodeBytes
func DecodeBytes(b []byte, val interface{}) error { r := bytes.NewReader(b) d := NewDecoder(r) return d.Decode(val) }
go
func DecodeBytes(b []byte, val interface{}) error { r := bytes.NewReader(b) d := NewDecoder(r) return d.Decode(val) }
[ "func", "DecodeBytes", "(", "b", "[", "]", "byte", ",", "val", "interface", "{", "}", ")", "error", "{", "r", ":=", "bytes", ".", "NewReader", "(", "b", ")", "\n", "d", ":=", "NewDecoder", "(", "r", ")", "\n", "return", "d", ".", "Decode", "(", ...
// DecodeBytes reads the data in b and stores it into the value pointed to by val. // Read the docs for Decode for more information.
[ "DecodeBytes", "reads", "the", "data", "in", "b", "and", "stores", "it", "into", "the", "value", "pointed", "to", "by", "val", ".", "Read", "the", "docs", "for", "Decode", "for", "more", "information", "." ]
cf5003e89e5a68181295c9383cd3329ef85549ac
https://github.com/zeebo/bencode/blob/cf5003e89e5a68181295c9383cd3329ef85549ac/decode.go#L133-L137
142,059
Songmu/axslogparser
axslogparser.go
GuessParser
func GuessParser(line string) (Parser, *Log, error) { var p Parser if strings.Contains(line, "\thost:") || strings.Contains(line, "\ttime:") { p = &LTSV{} l, err := p.Parse(line) if err == nil { return p, l, err } } p = &Apache{} l, err := p.Parse(line) if err != nil { return nil, nil, err } return...
go
func GuessParser(line string) (Parser, *Log, error) { var p Parser if strings.Contains(line, "\thost:") || strings.Contains(line, "\ttime:") { p = &LTSV{} l, err := p.Parse(line) if err == nil { return p, l, err } } p = &Apache{} l, err := p.Parse(line) if err != nil { return nil, nil, err } return...
[ "func", "GuessParser", "(", "line", "string", ")", "(", "Parser", ",", "*", "Log", ",", "error", ")", "{", "var", "p", "Parser", "\n", "if", "strings", ".", "Contains", "(", "line", ",", "\"", "\\t", "\"", ")", "||", "strings", ".", "Contains", "("...
// GuessParser guesses the parser from line
[ "GuessParser", "guesses", "the", "parser", "from", "line" ]
31874ad7dc8d453b39e3494f8979cedfaa386199
https://github.com/Songmu/axslogparser/blob/31874ad7dc8d453b39e3494f8979cedfaa386199/axslogparser.go#L60-L75
142,060
Songmu/axslogparser
axslogparser.go
Parse
func Parse(line string) (*Log, error) { _, l, err := GuessParser(line) return l, err }
go
func Parse(line string) (*Log, error) { _, l, err := GuessParser(line) return l, err }
[ "func", "Parse", "(", "line", "string", ")", "(", "*", "Log", ",", "error", ")", "{", "_", ",", "l", ",", "err", ":=", "GuessParser", "(", "line", ")", "\n", "return", "l", ",", "err", "\n", "}" ]
// Parse log line
[ "Parse", "log", "line" ]
31874ad7dc8d453b39e3494f8979cedfaa386199
https://github.com/Songmu/axslogparser/blob/31874ad7dc8d453b39e3494f8979cedfaa386199/axslogparser.go#L78-L81
142,061
tv42/zbase32
zbase32.go
EncodeBitsToString
func EncodeBitsToString(src []byte, bits int) string { dst := make([]byte, EncodedLen(len(src))) n := EncodeBits(dst, src, bits) return string(dst[:n]) }
go
func EncodeBitsToString(src []byte, bits int) string { dst := make([]byte, EncodedLen(len(src))) n := EncodeBits(dst, src, bits) return string(dst[:n]) }
[ "func", "EncodeBitsToString", "(", "src", "[", "]", "byte", ",", "bits", "int", ")", "string", "{", "dst", ":=", "make", "(", "[", "]", "byte", ",", "EncodedLen", "(", "len", "(", "src", ")", ")", ")", "\n", "n", ":=", "EncodeBits", "(", "dst", "...
// EncodeBitsToString returns the z-base-32 encoding of the specified // number of bits of src.
[ "EncodeBitsToString", "returns", "the", "z", "-", "base", "-", "32", "encoding", "of", "the", "specified", "number", "of", "bits", "of", "src", "." ]
501572607d0273fc75b3b261fa4904d63f6ffa0e
https://github.com/tv42/zbase32/blob/501572607d0273fc75b3b261fa4904d63f6ffa0e/zbase32.go#L128-L132
142,062
tv42/zbase32
zbase32.go
DecodeBitsString
func DecodeBitsString(s string, bits int) ([]byte, error) { if bits < 0 { return nil, errors.New("cannot decode a negative bit count") } return decodeString(s, bits) }
go
func DecodeBitsString(s string, bits int) ([]byte, error) { if bits < 0 { return nil, errors.New("cannot decode a negative bit count") } return decodeString(s, bits) }
[ "func", "DecodeBitsString", "(", "s", "string", ",", "bits", "int", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "bits", "<", "0", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "d...
// DecodeBitsString returns the bytes represented by the z-base-32 // string s containing the specified number of bits.
[ "DecodeBitsString", "returns", "the", "bytes", "represented", "by", "the", "z", "-", "base", "-", "32", "string", "s", "containing", "the", "specified", "number", "of", "bits", "." ]
501572607d0273fc75b3b261fa4904d63f6ffa0e
https://github.com/tv42/zbase32/blob/501572607d0273fc75b3b261fa4904d63f6ffa0e/zbase32.go#L211-L216
142,063
tv42/zbase32
flag.go
Set
func (v *Value) Set(s string) error { b, err := DecodeString(s) if err != nil { return err } *v = b return nil }
go
func (v *Value) Set(s string) error { b, err := DecodeString(s) if err != nil { return err } *v = b return nil }
[ "func", "(", "v", "*", "Value", ")", "Set", "(", "s", "string", ")", "error", "{", "b", ",", "err", ":=", "DecodeString", "(", "s", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "*", "v", "=", "b", "\n", "return"...
// Set the value to data encoded by string.
[ "Set", "the", "value", "to", "data", "encoded", "by", "string", "." ]
501572607d0273fc75b3b261fa4904d63f6ffa0e
https://github.com/tv42/zbase32/blob/501572607d0273fc75b3b261fa4904d63f6ffa0e/flag.go#L16-L23
142,064
qor/media_library
filesystem.go
GetFullPath
func (f FileSystem) GetFullPath(url string, option *Option) (path string, err error) { if option != nil && option.Get("path") != "" { path = filepath.Join(option.Get("path"), url) } else { path = filepath.Join("./public", url) } dir := filepath.Dir(path) if _, err := os.Stat(dir); os.IsNotExist(err) { err =...
go
func (f FileSystem) GetFullPath(url string, option *Option) (path string, err error) { if option != nil && option.Get("path") != "" { path = filepath.Join(option.Get("path"), url) } else { path = filepath.Join("./public", url) } dir := filepath.Dir(path) if _, err := os.Stat(dir); os.IsNotExist(err) { err =...
[ "func", "(", "f", "FileSystem", ")", "GetFullPath", "(", "url", "string", ",", "option", "*", "Option", ")", "(", "path", "string", ",", "err", "error", ")", "{", "if", "option", "!=", "nil", "&&", "option", ".", "Get", "(", "\"", "\"", ")", "!=", ...
// GetFullPath return full file path from a relative file path
[ "GetFullPath", "return", "full", "file", "path", "from", "a", "relative", "file", "path" ]
7c6ac542ddccad82fc4a552333d1af6c20c217c6
https://github.com/qor/media_library/blob/7c6ac542ddccad82fc4a552333d1af6c20c217c6/filesystem.go#L15-L28
142,065
qor/media_library
filesystem.go
Store
func (f FileSystem) Store(name string, option *Option, reader io.Reader) (err error) { if fullpath, err := f.GetFullPath(name, option); err == nil { if dst, err := os.Create(fullpath); err == nil { _, err = io.Copy(dst, reader) } } return err }
go
func (f FileSystem) Store(name string, option *Option, reader io.Reader) (err error) { if fullpath, err := f.GetFullPath(name, option); err == nil { if dst, err := os.Create(fullpath); err == nil { _, err = io.Copy(dst, reader) } } return err }
[ "func", "(", "f", "FileSystem", ")", "Store", "(", "name", "string", ",", "option", "*", "Option", ",", "reader", "io", ".", "Reader", ")", "(", "err", "error", ")", "{", "if", "fullpath", ",", "err", ":=", "f", ".", "GetFullPath", "(", "name", ","...
// Store save reader's context with name
[ "Store", "save", "reader", "s", "context", "with", "name" ]
7c6ac542ddccad82fc4a552333d1af6c20c217c6
https://github.com/qor/media_library/blob/7c6ac542ddccad82fc4a552333d1af6c20c217c6/filesystem.go#L31-L38
142,066
qor/media_library
base.go
Scan
func (b *Base) Scan(data interface{}) (err error) { switch values := data.(type) { case *os.File: b.FileHeader = &fileWrapper{values} b.FileName = filepath.Base(values.Name()) case *multipart.FileHeader: b.FileHeader, b.FileName = values, values.Filename case []*multipart.FileHeader: if len(values) > 0 { ...
go
func (b *Base) Scan(data interface{}) (err error) { switch values := data.(type) { case *os.File: b.FileHeader = &fileWrapper{values} b.FileName = filepath.Base(values.Name()) case *multipart.FileHeader: b.FileHeader, b.FileName = values, values.Filename case []*multipart.FileHeader: if len(values) > 0 { ...
[ "func", "(", "b", "*", "Base", ")", "Scan", "(", "data", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "switch", "values", ":=", "data", ".", "(", "type", ")", "{", "case", "*", "os", ".", "File", ":", "b", ".", "FileHeader", "=", ...
// Scan scan files, crop options, db values into struct
[ "Scan", "scan", "files", "crop", "options", "db", "values", "into", "struct" ]
7c6ac542ddccad82fc4a552333d1af6c20c217c6
https://github.com/qor/media_library/blob/7c6ac542ddccad82fc4a552333d1af6c20c217c6/base.go#L61-L101
142,067
qor/media_library
base.go
IsImage
func (b Base) IsImage() bool { _, err := getImageFormat(b.URL()) return err == nil }
go
func (b Base) IsImage() bool { _, err := getImageFormat(b.URL()) return err == nil }
[ "func", "(", "b", "Base", ")", "IsImage", "(", ")", "bool", "{", "_", ",", "err", ":=", "getImageFormat", "(", "b", ".", "URL", "(", ")", ")", "\n", "return", "err", "==", "nil", "\n", "}" ]
// IsImage return if it is an image
[ "IsImage", "return", "if", "it", "is", "an", "image" ]
7c6ac542ddccad82fc4a552333d1af6c20c217c6
https://github.com/qor/media_library/blob/7c6ac542ddccad82fc4a552333d1af6c20c217c6/base.go#L217-L220
142,068
qor/media_library
base.go
ConfigureQorMetaBeforeInitialize
func (Base) ConfigureQorMetaBeforeInitialize(meta resource.Metaor) { if meta, ok := meta.(*admin.Meta); ok { meta.Type = "file" if meta.GetFormattedValuer() == nil { meta.SetFormattedValuer(func(value interface{}, context *qor.Context) interface{} { return utils.Stringify(meta.GetValuer()(value, context)) ...
go
func (Base) ConfigureQorMetaBeforeInitialize(meta resource.Metaor) { if meta, ok := meta.(*admin.Meta); ok { meta.Type = "file" if meta.GetFormattedValuer() == nil { meta.SetFormattedValuer(func(value interface{}, context *qor.Context) interface{} { return utils.Stringify(meta.GetValuer()(value, context)) ...
[ "func", "(", "Base", ")", "ConfigureQorMetaBeforeInitialize", "(", "meta", "resource", ".", "Metaor", ")", "{", "if", "meta", ",", "ok", ":=", "meta", ".", "(", "*", "admin", ".", "Meta", ")", ";", "ok", "{", "meta", ".", "Type", "=", "\"", "\"", "...
// ConfigureQorMetaBeforeInitialize configure this field for Qor Admin
[ "ConfigureQorMetaBeforeInitialize", "configure", "this", "field", "for", "Qor", "Admin" ]
7c6ac542ddccad82fc4a552333d1af6c20c217c6
https://github.com/qor/media_library/blob/7c6ac542ddccad82fc4a552333d1af6c20c217c6/base.go#L231-L241
142,069
gravitational/configure
jsonschema/schema.go
New
func New(data []byte) (*JSONSchema, error) { j := JSONSchema{} err := json.Unmarshal(data, &j.rawSchema) if err != nil { return nil, trace.Wrap(err) } loader := gojsonschema.NewGoLoader(j.rawSchema) j.schema, err = gojsonschema.NewSchema(loader) if err != nil { return nil, trace.Wrap(err) } return &j, nil...
go
func New(data []byte) (*JSONSchema, error) { j := JSONSchema{} err := json.Unmarshal(data, &j.rawSchema) if err != nil { return nil, trace.Wrap(err) } loader := gojsonschema.NewGoLoader(j.rawSchema) j.schema, err = gojsonschema.NewSchema(loader) if err != nil { return nil, trace.Wrap(err) } return &j, nil...
[ "func", "New", "(", "data", "[", "]", "byte", ")", "(", "*", "JSONSchema", ",", "error", ")", "{", "j", ":=", "JSONSchema", "{", "}", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "j", ".", "rawSchema", ")", "\n", "if", "e...
// New returns JSON schema created from JSON byte string // returns a valid schema or error if schema is invalid
[ "New", "returns", "JSON", "schema", "created", "from", "JSON", "byte", "string", "returns", "a", "valid", "schema", "or", "error", "if", "schema", "is", "invalid" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/jsonschema/schema.go#L42-L55
142,070
gravitational/configure
jsonschema/schema.go
ProcessObject
func (j *JSONSchema) ProcessObject(in interface{}) (interface{}, error) { defaults := setDefaults(j.rawSchema, in) result, err := j.schema.Validate(gojsonschema.NewGoLoader(defaults)) if err != nil { return nil, trace.Wrap(err) } if !result.Valid() { errors := result.Errors() output := make([]string, len(er...
go
func (j *JSONSchema) ProcessObject(in interface{}) (interface{}, error) { defaults := setDefaults(j.rawSchema, in) result, err := j.schema.Validate(gojsonschema.NewGoLoader(defaults)) if err != nil { return nil, trace.Wrap(err) } if !result.Valid() { errors := result.Errors() output := make([]string, len(er...
[ "func", "(", "j", "*", "JSONSchema", ")", "ProcessObject", "(", "in", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "defaults", ":=", "setDefaults", "(", "j", ".", "rawSchema", ",", "in", ")", "\n\n", "result", ",", ...
// ProcessObject checks if the object is valid from this schema's standpoint // and returns an object with defaults set up according to schema's spec
[ "ProcessObject", "checks", "if", "the", "object", "is", "valid", "from", "this", "schema", "s", "standpoint", "and", "returns", "an", "object", "with", "defaults", "set", "up", "according", "to", "schema", "s", "spec" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/jsonschema/schema.go#L59-L76
142,071
sfreiberg/simplessh
simplessh.go
ConnectWithPassword
func ConnectWithPassword(host, username, pass string) (*Client, error) { return ConnectWithPasswordTimeout(host, username, pass, DefaultTimeout) }
go
func ConnectWithPassword(host, username, pass string) (*Client, error) { return ConnectWithPasswordTimeout(host, username, pass, DefaultTimeout) }
[ "func", "ConnectWithPassword", "(", "host", ",", "username", ",", "pass", "string", ")", "(", "*", "Client", ",", "error", ")", "{", "return", "ConnectWithPasswordTimeout", "(", "host", ",", "username", ",", "pass", ",", "DefaultTimeout", ")", "\n", "}" ]
// Connect with a password. If username is empty simplessh will attempt to get the current user.
[ "Connect", "with", "a", "password", ".", "If", "username", "is", "empty", "simplessh", "will", "attempt", "to", "get", "the", "current", "user", "." ]
495cbb862a9c6348e0fff479ed1e7b70c871b372
https://github.com/sfreiberg/simplessh/blob/495cbb862a9c6348e0fff479ed1e7b70c871b372/simplessh.go#L57-L59
142,072
sfreiberg/simplessh
simplessh.go
ConnectWithPasswordTimeout
func ConnectWithPasswordTimeout(host, username, pass string, timeout time.Duration) (*Client, error) { authMethod := ssh.Password(pass) return connect(username, host, authMethod, timeout) }
go
func ConnectWithPasswordTimeout(host, username, pass string, timeout time.Duration) (*Client, error) { authMethod := ssh.Password(pass) return connect(username, host, authMethod, timeout) }
[ "func", "ConnectWithPasswordTimeout", "(", "host", ",", "username", ",", "pass", "string", ",", "timeout", "time", ".", "Duration", ")", "(", "*", "Client", ",", "error", ")", "{", "authMethod", ":=", "ssh", ".", "Password", "(", "pass", ")", "\n\n", "re...
// Same as ConnectWithPassword but allows a custom timeout. If username is empty simplessh will attempt to get the current user.
[ "Same", "as", "ConnectWithPassword", "but", "allows", "a", "custom", "timeout", ".", "If", "username", "is", "empty", "simplessh", "will", "attempt", "to", "get", "the", "current", "user", "." ]
495cbb862a9c6348e0fff479ed1e7b70c871b372
https://github.com/sfreiberg/simplessh/blob/495cbb862a9c6348e0fff479ed1e7b70c871b372/simplessh.go#L62-L66
142,073
sfreiberg/simplessh
simplessh.go
ConnectWithKeyFile
func ConnectWithKeyFile(host, username, privKeyPath string) (*Client, error) { return ConnectWithKeyFileTimeout(host, username, privKeyPath, DefaultTimeout) }
go
func ConnectWithKeyFile(host, username, privKeyPath string) (*Client, error) { return ConnectWithKeyFileTimeout(host, username, privKeyPath, DefaultTimeout) }
[ "func", "ConnectWithKeyFile", "(", "host", ",", "username", ",", "privKeyPath", "string", ")", "(", "*", "Client", ",", "error", ")", "{", "return", "ConnectWithKeyFileTimeout", "(", "host", ",", "username", ",", "privKeyPath", ",", "DefaultTimeout", ")", "\n"...
// Same as ConnectWithKeyFile but allows a custom timeout. If username is empty simplessh will attempt to get the current user.
[ "Same", "as", "ConnectWithKeyFile", "but", "allows", "a", "custom", "timeout", ".", "If", "username", "is", "empty", "simplessh", "will", "attempt", "to", "get", "the", "current", "user", "." ]
495cbb862a9c6348e0fff479ed1e7b70c871b372
https://github.com/sfreiberg/simplessh/blob/495cbb862a9c6348e0fff479ed1e7b70c871b372/simplessh.go#L87-L89
142,074
sfreiberg/simplessh
simplessh.go
ConnectWithKeyTimeout
func ConnectWithKeyTimeout(host, username, privKey string, timeout time.Duration) (*Client, error) { signer, err := ssh.ParsePrivateKey([]byte(privKey)) if err != nil { return nil, err } authMethod := ssh.PublicKeys(signer) return connect(username, host, authMethod, timeout) }
go
func ConnectWithKeyTimeout(host, username, privKey string, timeout time.Duration) (*Client, error) { signer, err := ssh.ParsePrivateKey([]byte(privKey)) if err != nil { return nil, err } authMethod := ssh.PublicKeys(signer) return connect(username, host, authMethod, timeout) }
[ "func", "ConnectWithKeyTimeout", "(", "host", ",", "username", ",", "privKey", "string", ",", "timeout", "time", ".", "Duration", ")", "(", "*", "Client", ",", "error", ")", "{", "signer", ",", "err", ":=", "ssh", ".", "ParsePrivateKey", "(", "[", "]", ...
// Connect with a private key with a custom timeout. If username is empty simplessh will attempt to get the current user.
[ "Connect", "with", "a", "private", "key", "with", "a", "custom", "timeout", ".", "If", "username", "is", "empty", "simplessh", "will", "attempt", "to", "get", "the", "current", "user", "." ]
495cbb862a9c6348e0fff479ed1e7b70c871b372
https://github.com/sfreiberg/simplessh/blob/495cbb862a9c6348e0fff479ed1e7b70c871b372/simplessh.go#L92-L101
142,075
sfreiberg/simplessh
simplessh.go
ConnectWithKey
func ConnectWithKey(host, username, privKey string) (*Client, error) { return ConnectWithKeyTimeout(host, username, privKey, DefaultTimeout) }
go
func ConnectWithKey(host, username, privKey string) (*Client, error) { return ConnectWithKeyTimeout(host, username, privKey, DefaultTimeout) }
[ "func", "ConnectWithKey", "(", "host", ",", "username", ",", "privKey", "string", ")", "(", "*", "Client", ",", "error", ")", "{", "return", "ConnectWithKeyTimeout", "(", "host", ",", "username", ",", "privKey", ",", "DefaultTimeout", ")", "\n", "}" ]
// Connect with a private key. If username is empty simplessh will attempt to get the current user.
[ "Connect", "with", "a", "private", "key", ".", "If", "username", "is", "empty", "simplessh", "will", "attempt", "to", "get", "the", "current", "user", "." ]
495cbb862a9c6348e0fff479ed1e7b70c871b372
https://github.com/sfreiberg/simplessh/blob/495cbb862a9c6348e0fff479ed1e7b70c871b372/simplessh.go#L104-L106
142,076
sfreiberg/simplessh
simplessh.go
ConnectWithAgentTimeout
func ConnectWithAgentTimeout(host, username string, timeout time.Duration) (*Client, error) { return connectWithAgentTimeout(host, username, timeout) }
go
func ConnectWithAgentTimeout(host, username string, timeout time.Duration) (*Client, error) { return connectWithAgentTimeout(host, username, timeout) }
[ "func", "ConnectWithAgentTimeout", "(", "host", ",", "username", "string", ",", "timeout", "time", ".", "Duration", ")", "(", "*", "Client", ",", "error", ")", "{", "return", "connectWithAgentTimeout", "(", "host", ",", "username", ",", "timeout", ")", "\n",...
// Connect to an ssh agent with a custom timeout. If username is empty simplessh will attempt to get the current user. The windows implementation uses a different library which expects pageant to be running.
[ "Connect", "to", "an", "ssh", "agent", "with", "a", "custom", "timeout", ".", "If", "username", "is", "empty", "simplessh", "will", "attempt", "to", "get", "the", "current", "user", ".", "The", "windows", "implementation", "uses", "a", "different", "library"...
495cbb862a9c6348e0fff479ed1e7b70c871b372
https://github.com/sfreiberg/simplessh/blob/495cbb862a9c6348e0fff479ed1e7b70c871b372/simplessh.go#L109-L111
142,077
sfreiberg/simplessh
simplessh.go
ConnectWithAgent
func ConnectWithAgent(host, username string) (*Client, error) { return ConnectWithAgentTimeout(host, username, DefaultTimeout) }
go
func ConnectWithAgent(host, username string) (*Client, error) { return ConnectWithAgentTimeout(host, username, DefaultTimeout) }
[ "func", "ConnectWithAgent", "(", "host", ",", "username", "string", ")", "(", "*", "Client", ",", "error", ")", "{", "return", "ConnectWithAgentTimeout", "(", "host", ",", "username", ",", "DefaultTimeout", ")", "\n", "}" ]
// Connect to an ssh agent. If username is empty simplessh will attempt to get the current user. The windows implementation uses a different library which expects pageant to be running.
[ "Connect", "to", "an", "ssh", "agent", ".", "If", "username", "is", "empty", "simplessh", "will", "attempt", "to", "get", "the", "current", "user", ".", "The", "windows", "implementation", "uses", "a", "different", "library", "which", "expects", "pageant", "...
495cbb862a9c6348e0fff479ed1e7b70c871b372
https://github.com/sfreiberg/simplessh/blob/495cbb862a9c6348e0fff479ed1e7b70c871b372/simplessh.go#L114-L116
142,078
sfreiberg/simplessh
simplessh.go
Exec
func (c *Client) Exec(cmd string) ([]byte, error) { session, err := c.SSHClient.NewSession() if err != nil { return nil, err } defer session.Close() return session.CombinedOutput(cmd) }
go
func (c *Client) Exec(cmd string) ([]byte, error) { session, err := c.SSHClient.NewSession() if err != nil { return nil, err } defer session.Close() return session.CombinedOutput(cmd) }
[ "func", "(", "c", "*", "Client", ")", "Exec", "(", "cmd", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "session", ",", "err", ":=", "c", ".", "SSHClient", ".", "NewSession", "(", ")", "\n", "if", "err", "!=", "nil", "{", "retur...
// Execute cmd on the remote host and return stderr and stdout
[ "Execute", "cmd", "on", "the", "remote", "host", "and", "return", "stderr", "and", "stdout" ]
495cbb862a9c6348e0fff479ed1e7b70c871b372
https://github.com/sfreiberg/simplessh/blob/495cbb862a9c6348e0fff479ed1e7b70c871b372/simplessh.go#L151-L159
142,079
sfreiberg/simplessh
simplessh.go
Download
func (c *Client) Download(remote, local string) error { client, err := sftp.NewClient(c.SSHClient) if err != nil { return err } defer client.Close() remoteFile, err := client.Open(remote) if err != nil { return err } defer remoteFile.Close() localFile, err := os.Create(local) if err != nil { return er...
go
func (c *Client) Download(remote, local string) error { client, err := sftp.NewClient(c.SSHClient) if err != nil { return err } defer client.Close() remoteFile, err := client.Open(remote) if err != nil { return err } defer remoteFile.Close() localFile, err := os.Create(local) if err != nil { return er...
[ "func", "(", "c", "*", "Client", ")", "Download", "(", "remote", ",", "local", "string", ")", "error", "{", "client", ",", "err", ":=", "sftp", ".", "NewClient", "(", "c", ".", "SSHClient", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err",...
// Download a file from the remote server
[ "Download", "a", "file", "from", "the", "remote", "server" ]
495cbb862a9c6348e0fff479ed1e7b70c871b372
https://github.com/sfreiberg/simplessh/blob/495cbb862a9c6348e0fff479ed1e7b70c871b372/simplessh.go#L198-L219
142,080
sfreiberg/simplessh
simplessh.go
Remove
func (c *Client) Remove(path string) error { client, err := sftp.NewClient(c.SSHClient) if err != nil { return err } defer client.Close() return client.Remove(path) }
go
func (c *Client) Remove(path string) error { client, err := sftp.NewClient(c.SSHClient) if err != nil { return err } defer client.Close() return client.Remove(path) }
[ "func", "(", "c", "*", "Client", ")", "Remove", "(", "path", "string", ")", "error", "{", "client", ",", "err", ":=", "sftp", ".", "NewClient", "(", "c", ".", "SSHClient", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n"...
// Remove a file from the remote server
[ "Remove", "a", "file", "from", "the", "remote", "server" ]
495cbb862a9c6348e0fff479ed1e7b70c871b372
https://github.com/sfreiberg/simplessh/blob/495cbb862a9c6348e0fff479ed1e7b70c871b372/simplessh.go#L245-L253
142,081
sfreiberg/simplessh
simplessh.go
ReadAll
func (c *Client) ReadAll(filepath string) ([]byte, error) { sftp, err := c.SFTPClient() if err != nil { panic(err) } defer sftp.Close() file, err := sftp.Open(filepath) if err != nil { return nil, err } defer file.Close() return ioutil.ReadAll(file) }
go
func (c *Client) ReadAll(filepath string) ([]byte, error) { sftp, err := c.SFTPClient() if err != nil { panic(err) } defer sftp.Close() file, err := sftp.Open(filepath) if err != nil { return nil, err } defer file.Close() return ioutil.ReadAll(file) }
[ "func", "(", "c", "*", "Client", ")", "ReadAll", "(", "filepath", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "sftp", ",", "err", ":=", "c", ".", "SFTPClient", "(", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err"...
// Read a remote file and return the contents.
[ "Read", "a", "remote", "file", "and", "return", "the", "contents", "." ]
495cbb862a9c6348e0fff479ed1e7b70c871b372
https://github.com/sfreiberg/simplessh/blob/495cbb862a9c6348e0fff479ed1e7b70c871b372/simplessh.go#L267-L281
142,082
sfreiberg/simplessh
simplessh.go
SFTPClient
func (c *Client) SFTPClient() (*sftp.Client, error) { return sftp.NewClient(c.SSHClient) }
go
func (c *Client) SFTPClient() (*sftp.Client, error) { return sftp.NewClient(c.SSHClient) }
[ "func", "(", "c", "*", "Client", ")", "SFTPClient", "(", ")", "(", "*", "sftp", ".", "Client", ",", "error", ")", "{", "return", "sftp", ".", "NewClient", "(", "c", ".", "SSHClient", ")", "\n", "}" ]
// Return an sftp client. The client needs to be closed when it's no // longer needed.
[ "Return", "an", "sftp", "client", ".", "The", "client", "needs", "to", "be", "closed", "when", "it", "s", "no", "longer", "needed", "." ]
495cbb862a9c6348e0fff479ed1e7b70c871b372
https://github.com/sfreiberg/simplessh/blob/495cbb862a9c6348e0fff479ed1e7b70c871b372/simplessh.go#L290-L292
142,083
gravitational/configure
cstrings/user.go
IsValidUnixUser
func IsValidUnixUser(u string) bool { /* See http://www.unix.com/man-page/linux/8/useradd: On Debian, the only constraints are that usernames must neither start with a dash ('-') nor contain a colon (':') or a whitespace (space: ' ', end of line: '\n', tabulation: '\t', etc.). Note that using a slash ('/'...
go
func IsValidUnixUser(u string) bool { /* See http://www.unix.com/man-page/linux/8/useradd: On Debian, the only constraints are that usernames must neither start with a dash ('-') nor contain a colon (':') or a whitespace (space: ' ', end of line: '\n', tabulation: '\t', etc.). Note that using a slash ('/'...
[ "func", "IsValidUnixUser", "(", "u", "string", ")", "bool", "{", "/* See http://www.unix.com/man-page/linux/8/useradd:\n\n\t\tOn Debian, the only constraints are that usernames must neither start with a dash ('-')\n\t nor contain a colon (':') or a whitespace (space: ' ', end of line: '\\n', tabu...
// IsValidUnixUser returns true if passed string can be used // to create a valid UNIX user
[ "IsValidUnixUser", "returns", "true", "if", "passed", "string", "can", "be", "used", "to", "create", "a", "valid", "UNIX", "user" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cstrings/user.go#L14-L35
142,084
gravitational/configure
cstrings/split.go
Split
func Split(delim, escape rune, v string) []string { if delim == 0 || escape == 0 { return []string{v} } scanner := bufio.NewScanner(strings.NewReader(v)) s := &splitter{delim: delim, escape: escape} scanner.Split(s.scan) out := []string{} for scanner.Scan() { out = append(out, scanner.Text()) } return out...
go
func Split(delim, escape rune, v string) []string { if delim == 0 || escape == 0 { return []string{v} } scanner := bufio.NewScanner(strings.NewReader(v)) s := &splitter{delim: delim, escape: escape} scanner.Split(s.scan) out := []string{} for scanner.Scan() { out = append(out, scanner.Text()) } return out...
[ "func", "Split", "(", "delim", ",", "escape", "rune", ",", "v", "string", ")", "[", "]", "string", "{", "if", "delim", "==", "0", "||", "escape", "==", "0", "{", "return", "[", "]", "string", "{", "v", "}", "\n", "}", "\n", "scanner", ":=", "bu...
// Split splits the string v using delimiter rune. Rune can be escaped // if prefixed with the escape rune.
[ "Split", "splits", "the", "string", "v", "using", "delimiter", "rune", ".", "Rune", "can", "be", "escaped", "if", "prefixed", "with", "the", "escape", "rune", "." ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cstrings/split.go#L32-L45
142,085
gravitational/configure
cstrings/split.go
SplitAt
func SplitAt(args []string, sep string) ([]string, []string) { index := -1 for i, a := range args { if a == sep { index = i break } } if index == -1 { return args, []string{} } return args[:index], args[index+1:] }
go
func SplitAt(args []string, sep string) ([]string, []string) { index := -1 for i, a := range args { if a == sep { index = i break } } if index == -1 { return args, []string{} } return args[:index], args[index+1:] }
[ "func", "SplitAt", "(", "args", "[", "]", "string", ",", "sep", "string", ")", "(", "[", "]", "string", ",", "[", "]", "string", ")", "{", "index", ":=", "-", "1", "\n", "for", "i", ",", "a", ":=", "range", "args", "{", "if", "a", "==", "sep"...
// SplitAt splits array of strings at a given separator
[ "SplitAt", "splits", "array", "of", "strings", "at", "a", "given", "separator" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cstrings/split.go#L48-L60
142,086
gravitational/configure
cstrings/split.go
WithoutFlag
func WithoutFlag(args []string, flag string) []string { out := make([]string, 0, len(args)) for i := 0; i < len(args); i += 1 { val := args[i] if !strings.HasPrefix(val, flag) { out = append(out, val) } else { if !strings.Contains(val, "=") && i+1 <= len(args)-1 { i += 1 } } } return out }
go
func WithoutFlag(args []string, flag string) []string { out := make([]string, 0, len(args)) for i := 0; i < len(args); i += 1 { val := args[i] if !strings.HasPrefix(val, flag) { out = append(out, val) } else { if !strings.Contains(val, "=") && i+1 <= len(args)-1 { i += 1 } } } return out }
[ "func", "WithoutFlag", "(", "args", "[", "]", "string", ",", "flag", "string", ")", "[", "]", "string", "{", "out", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "args", ")", ")", "\n", "for", "i", ":=", "0", ";", "i", "<"...
// WithoutFlag removes the flag from the argument list
[ "WithoutFlag", "removes", "the", "flag", "from", "the", "argument", "list" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cstrings/split.go#L63-L76
142,087
gravitational/configure
cxml/xml.go
TransformXML
func TransformXML(decoder *xml.Decoder, encoder *xml.Encoder, fn TransformFunc) error { parentNodes := &NodeList{} for { token, err := decoder.Token() if err != nil { if err != io.EOF { return trace.Wrap(err) } break } for _, t := range fn(parentNodes, token) { if err := encoder.EncodeToken(t)...
go
func TransformXML(decoder *xml.Decoder, encoder *xml.Encoder, fn TransformFunc) error { parentNodes := &NodeList{} for { token, err := decoder.Token() if err != nil { if err != io.EOF { return trace.Wrap(err) } break } for _, t := range fn(parentNodes, token) { if err := encoder.EncodeToken(t)...
[ "func", "TransformXML", "(", "decoder", "*", "xml", ".", "Decoder", ",", "encoder", "*", "xml", ".", "Encoder", ",", "fn", "TransformFunc", ")", "error", "{", "parentNodes", ":=", "&", "NodeList", "{", "}", "\n", "for", "{", "token", ",", "err", ":=", ...
// TransformXML parses the XML tree, traverses it and calls TransformFunc // on each XML token, writing the output to the writer, resulting in a // transformed XML tree
[ "TransformXML", "parses", "the", "XML", "tree", "traverses", "it", "and", "calls", "TransformFunc", "on", "each", "XML", "token", "writing", "the", "output", "to", "the", "writer", "resulting", "in", "a", "transformed", "XML", "tree" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cxml/xml.go#L37-L61
142,088
gravitational/configure
cxml/xml.go
SetAttribute
func SetAttribute(e xml.StartElement, name, value string) xml.StartElement { for i := range e.Attr { if e.Attr[i].Name.Local == name { e.Attr[i].Value = value return e } } e.Attr = append(e.Attr, xml.Attr{Name: xml.Name{Local: name}, Value: value}) return e }
go
func SetAttribute(e xml.StartElement, name, value string) xml.StartElement { for i := range e.Attr { if e.Attr[i].Name.Local == name { e.Attr[i].Value = value return e } } e.Attr = append(e.Attr, xml.Attr{Name: xml.Name{Local: name}, Value: value}) return e }
[ "func", "SetAttribute", "(", "e", "xml", ".", "StartElement", ",", "name", ",", "value", "string", ")", "xml", ".", "StartElement", "{", "for", "i", ":=", "range", "e", ".", "Attr", "{", "if", "e", ".", "Attr", "[", "i", "]", ".", "Name", ".", "L...
// SetAttribute is XML helper that allows to set attribute on a node
[ "SetAttribute", "is", "XML", "helper", "that", "allows", "to", "set", "attribute", "on", "a", "node" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cxml/xml.go#L64-L73
142,089
gravitational/configure
cxml/xml.go
ReplaceCDATAIf
func ReplaceCDATAIf(val xml.CharData, cond ConditionFunc) TransformFunc { return func(parents *NodeList, in xml.Token) []xml.Token { switch in.(type) { case xml.CharData: if cond(parents, in) { return []xml.Token{val.Copy()} } } return []xml.Token{in} } }
go
func ReplaceCDATAIf(val xml.CharData, cond ConditionFunc) TransformFunc { return func(parents *NodeList, in xml.Token) []xml.Token { switch in.(type) { case xml.CharData: if cond(parents, in) { return []xml.Token{val.Copy()} } } return []xml.Token{in} } }
[ "func", "ReplaceCDATAIf", "(", "val", "xml", ".", "CharData", ",", "cond", "ConditionFunc", ")", "TransformFunc", "{", "return", "func", "(", "parents", "*", "NodeList", ",", "in", "xml", ".", "Token", ")", "[", "]", "xml", ".", "Token", "{", "switch", ...
// ReplaceCDATAIf replaces CDATA value of the matched node // if the parent node name matches the name
[ "ReplaceCDATAIf", "replaces", "CDATA", "value", "of", "the", "matched", "node", "if", "the", "parent", "node", "name", "matches", "the", "name" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cxml/xml.go#L77-L87
142,090
gravitational/configure
cxml/xml.go
InjectNodesIf
func InjectNodesIf(nodes []xml.Token, cond ConditionFunc) TransformFunc { return func(parents *NodeList, in xml.Token) []xml.Token { if cond(parents, in) { return append(nodes, in) } return []xml.Token{in} } }
go
func InjectNodesIf(nodes []xml.Token, cond ConditionFunc) TransformFunc { return func(parents *NodeList, in xml.Token) []xml.Token { if cond(parents, in) { return append(nodes, in) } return []xml.Token{in} } }
[ "func", "InjectNodesIf", "(", "nodes", "[", "]", "xml", ".", "Token", ",", "cond", "ConditionFunc", ")", "TransformFunc", "{", "return", "func", "(", "parents", "*", "NodeList", ",", "in", "xml", ".", "Token", ")", "[", "]", "xml", ".", "Token", "{", ...
// InjectNodes injects nodes at the end of the tag that matches name
[ "InjectNodes", "injects", "nodes", "at", "the", "end", "of", "the", "tag", "that", "matches", "name" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cxml/xml.go#L90-L97
142,091
gravitational/configure
cxml/xml.go
ReplaceAttributeIf
func ReplaceAttributeIf(attrName, attrValue string, cond ConditionFunc) TransformFunc { return func(parents *NodeList, in xml.Token) []xml.Token { switch t := in.(type) { case xml.StartElement: if cond(parents, in) { e := xml.StartElement(t) return []xml.Token{SetAttribute(e, attrName, attrValue)} } ...
go
func ReplaceAttributeIf(attrName, attrValue string, cond ConditionFunc) TransformFunc { return func(parents *NodeList, in xml.Token) []xml.Token { switch t := in.(type) { case xml.StartElement: if cond(parents, in) { e := xml.StartElement(t) return []xml.Token{SetAttribute(e, attrName, attrValue)} } ...
[ "func", "ReplaceAttributeIf", "(", "attrName", ",", "attrValue", "string", ",", "cond", "ConditionFunc", ")", "TransformFunc", "{", "return", "func", "(", "parents", "*", "NodeList", ",", "in", "xml", ".", "Token", ")", "[", "]", "xml", ".", "Token", "{", ...
// ReplaceAttribute replaces the attribute of the first node that matches the name
[ "ReplaceAttribute", "replaces", "the", "attribute", "of", "the", "first", "node", "that", "matches", "the", "name" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cxml/xml.go#L100-L111
142,092
gravitational/configure
cxml/xml.go
TrimSpace
func TrimSpace(parents *NodeList, in xml.Token) []xml.Token { switch t := in.(type) { case xml.CharData: return []xml.Token{xml.CharData(bytes.TrimSpace(t))} } return []xml.Token{in} }
go
func TrimSpace(parents *NodeList, in xml.Token) []xml.Token { switch t := in.(type) { case xml.CharData: return []xml.Token{xml.CharData(bytes.TrimSpace(t))} } return []xml.Token{in} }
[ "func", "TrimSpace", "(", "parents", "*", "NodeList", ",", "in", "xml", ".", "Token", ")", "[", "]", "xml", ".", "Token", "{", "switch", "t", ":=", "in", ".", "(", "type", ")", "{", "case", "xml", ".", "CharData", ":", "return", "[", "]", "xml", ...
// TrimSpace is a transformer function that replaces CDATA with blank // characters with empty strings
[ "TrimSpace", "is", "a", "transformer", "function", "that", "replaces", "CDATA", "with", "blank", "characters", "with", "empty", "strings" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cxml/xml.go#L115-L121
142,093
gravitational/configure
cxml/xml.go
Combine
func Combine(funcs ...TransformFunc) TransformFunc { return func(parents *NodeList, in xml.Token) []xml.Token { out := []xml.Token{in} for _, f := range funcs { new := []xml.Token{} for _, t := range out { new = append(new, f(parents, t)...) } out = new } return out } }
go
func Combine(funcs ...TransformFunc) TransformFunc { return func(parents *NodeList, in xml.Token) []xml.Token { out := []xml.Token{in} for _, f := range funcs { new := []xml.Token{} for _, t := range out { new = append(new, f(parents, t)...) } out = new } return out } }
[ "func", "Combine", "(", "funcs", "...", "TransformFunc", ")", "TransformFunc", "{", "return", "func", "(", "parents", "*", "NodeList", ",", "in", "xml", ".", "Token", ")", "[", "]", "xml", ".", "Token", "{", "out", ":=", "[", "]", "xml", ".", "Token"...
// Combine takes a list of TransformFuncs and converts them // into a single transform function applying all functions one by one
[ "Combine", "takes", "a", "list", "of", "TransformFuncs", "and", "converts", "them", "into", "a", "single", "transform", "function", "applying", "all", "functions", "one", "by", "one" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cxml/xml.go#L125-L137
142,094
gravitational/configure
cxml/xml.go
ParentIs
func ParentIs(name xml.Name) ConditionFunc { return func(parents *NodeList, el xml.Token) bool { return parents.ParentIs(name) } }
go
func ParentIs(name xml.Name) ConditionFunc { return func(parents *NodeList, el xml.Token) bool { return parents.ParentIs(name) } }
[ "func", "ParentIs", "(", "name", "xml", ".", "Name", ")", "ConditionFunc", "{", "return", "func", "(", "parents", "*", "NodeList", ",", "el", "xml", ".", "Token", ")", "bool", "{", "return", "parents", ".", "ParentIs", "(", "name", ")", "\n", "}", "\...
// ParentIs is a functon that returns ConditionFunc checking // if immediate parent's name matches name
[ "ParentIs", "is", "a", "functon", "that", "returns", "ConditionFunc", "checking", "if", "immediate", "parent", "s", "name", "matches", "name" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cxml/xml.go#L141-L145
142,095
gravitational/configure
cxml/xml.go
GetAttribute
func GetAttribute(e xml.StartElement, name xml.Name) string { for _, a := range e.Attr { if NameEquals(a.Name, name) { return a.Value } } return "" }
go
func GetAttribute(e xml.StartElement, name xml.Name) string { for _, a := range e.Attr { if NameEquals(a.Name, name) { return a.Value } } return "" }
[ "func", "GetAttribute", "(", "e", "xml", ".", "StartElement", ",", "name", "xml", ".", "Name", ")", "string", "{", "for", "_", ",", "a", ":=", "range", "e", ".", "Attr", "{", "if", "NameEquals", "(", "a", ".", "Name", ",", "name", ")", "{", "retu...
// GetAttribute returns attribute value if it's present, otherwise // it returns an empty string
[ "GetAttribute", "returns", "attribute", "value", "if", "it", "s", "present", "otherwise", "it", "returns", "an", "empty", "string" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cxml/xml.go#L149-L156
142,096
gravitational/configure
cxml/xml.go
HasAttribute
func HasAttribute(e xml.StartElement, name xml.Name) bool { for _, a := range e.Attr { if NameEquals(name, a.Name) { return true } } return false }
go
func HasAttribute(e xml.StartElement, name xml.Name) bool { for _, a := range e.Attr { if NameEquals(name, a.Name) { return true } } return false }
[ "func", "HasAttribute", "(", "e", "xml", ".", "StartElement", ",", "name", "xml", ".", "Name", ")", "bool", "{", "for", "_", ",", "a", ":=", "range", "e", ".", "Attr", "{", "if", "NameEquals", "(", "name", ",", "a", ".", "Name", ")", "{", "return...
// HasAttribute returns true if element has an attribute with given // name, false otherwise
[ "HasAttribute", "returns", "true", "if", "element", "has", "an", "attribute", "with", "given", "name", "false", "otherwise" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cxml/xml.go#L160-L167
142,097
gravitational/configure
cxml/xml.go
ParentIs
func (n *NodeList) ParentIs(a xml.Name) bool { if len(n.nodes) == 0 { return false } return NameEquals(a, n.nodes[len(n.nodes)-1].Name) }
go
func (n *NodeList) ParentIs(a xml.Name) bool { if len(n.nodes) == 0 { return false } return NameEquals(a, n.nodes[len(n.nodes)-1].Name) }
[ "func", "(", "n", "*", "NodeList", ")", "ParentIs", "(", "a", "xml", ".", "Name", ")", "bool", "{", "if", "len", "(", "n", ".", "nodes", ")", "==", "0", "{", "return", "false", "\n", "}", "\n", "return", "NameEquals", "(", "a", ",", "n", ".", ...
// ParentIs returns true if last element exists and // it's name equals to this name
[ "ParentIs", "returns", "true", "if", "last", "element", "exists", "and", "it", "s", "name", "equals", "to", "this", "name" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cxml/xml.go#L191-L196
142,098
gravitational/configure
cxml/xml.go
NameEquals
func NameEquals(a, b xml.Name) bool { return a.Local == b.Local && a.Space == b.Space }
go
func NameEquals(a, b xml.Name) bool { return a.Local == b.Local && a.Space == b.Space }
[ "func", "NameEquals", "(", "a", ",", "b", "xml", ".", "Name", ")", "bool", "{", "return", "a", ".", "Local", "==", "b", ".", "Local", "&&", "a", ".", "Space", "==", "b", ".", "Space", "\n", "}" ]
// NameEquals return true if both namespaces and local names of nodes // match, and false otherwise
[ "NameEquals", "return", "true", "if", "both", "namespaces", "and", "local", "names", "of", "nodes", "match", "and", "false", "otherwise" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/cxml/xml.go#L200-L202
142,099
gravitational/configure
schema/schema.go
EnvVars
func (c *Config) EnvVars() map[string]string { vars := make(map[string]string, len(c.Params)) for _, p := range c.Params { k, v := p.EnvVars() vars[k] = v } return vars }
go
func (c *Config) EnvVars() map[string]string { vars := make(map[string]string, len(c.Params)) for _, p := range c.Params { k, v := p.EnvVars() vars[k] = v } return vars }
[ "func", "(", "c", "*", "Config", ")", "EnvVars", "(", ")", "map", "[", "string", "]", "string", "{", "vars", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "c", ".", "Params", ")", ")", "\n", "for", "_", ",", "p", ":...
// EnvVars returns a map with environment variables for all parameters
[ "EnvVars", "returns", "a", "map", "with", "environment", "variables", "for", "all", "parameters" ]
c3428bd84c23f0cfcc759f2ef12632be5ff5d95d
https://github.com/gravitational/configure/blob/c3428bd84c23f0cfcc759f2ef12632be5ff5d95d/schema/schema.go#L64-L71