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
24,700
go-ini/ini
section.go
HasValue
func (s *Section) HasValue(value string) bool { if s.f.BlockMode { s.f.lock.RLock() defer s.f.lock.RUnlock() } for _, k := range s.keys { if value == k.value { return true } } return false }
go
func (s *Section) HasValue(value string) bool { if s.f.BlockMode { s.f.lock.RLock() defer s.f.lock.RUnlock() } for _, k := range s.keys { if value == k.value { return true } } return false }
[ "func", "(", "s", "*", "Section", ")", "HasValue", "(", "value", "string", ")", "bool", "{", "if", "s", ".", "f", ".", "BlockMode", "{", "s", ".", "f", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "f", ".", "lock", ".", "RUnl...
// HasValue returns true if section contains given raw value.
[ "HasValue", "returns", "true", "if", "section", "contains", "given", "raw", "value", "." ]
3be5ad479f69d4e08d7fe25edf79bf3346bd658e
https://github.com/go-ini/ini/blob/3be5ad479f69d4e08d7fe25edf79bf3346bd658e/section.go#L151-L163
24,701
go-ini/ini
section.go
Key
func (s *Section) Key(name string) *Key { key, err := s.GetKey(name) if err != nil { // It's OK here because the only possible error is empty key name, // but if it's empty, this piece of code won't be executed. key, _ = s.NewKey(name, "") return key } return key }
go
func (s *Section) Key(name string) *Key { key, err := s.GetKey(name) if err != nil { // It's OK here because the only possible error is empty key name, // but if it's empty, this piece of code won't be executed. key, _ = s.NewKey(name, "") return key } return key }
[ "func", "(", "s", "*", "Section", ")", "Key", "(", "name", "string", ")", "*", "Key", "{", "key", ",", "err", ":=", "s", ".", "GetKey", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "// It's OK here because the only possible error is empty key nam...
// Key assumes named Key exists in section and returns a zero-value when not.
[ "Key", "assumes", "named", "Key", "exists", "in", "section", "and", "returns", "a", "zero", "-", "value", "when", "not", "." ]
3be5ad479f69d4e08d7fe25edf79bf3346bd658e
https://github.com/go-ini/ini/blob/3be5ad479f69d4e08d7fe25edf79bf3346bd658e/section.go#L166-L175
24,702
go-ini/ini
section.go
Keys
func (s *Section) Keys() []*Key { keys := make([]*Key, len(s.keyList)) for i := range s.keyList { keys[i] = s.Key(s.keyList[i]) } return keys }
go
func (s *Section) Keys() []*Key { keys := make([]*Key, len(s.keyList)) for i := range s.keyList { keys[i] = s.Key(s.keyList[i]) } return keys }
[ "func", "(", "s", "*", "Section", ")", "Keys", "(", ")", "[", "]", "*", "Key", "{", "keys", ":=", "make", "(", "[", "]", "*", "Key", ",", "len", "(", "s", ".", "keyList", ")", ")", "\n", "for", "i", ":=", "range", "s", ".", "keyList", "{", ...
// Keys returns list of keys of section.
[ "Keys", "returns", "list", "of", "keys", "of", "section", "." ]
3be5ad479f69d4e08d7fe25edf79bf3346bd658e
https://github.com/go-ini/ini/blob/3be5ad479f69d4e08d7fe25edf79bf3346bd658e/section.go#L178-L184
24,703
go-ini/ini
section.go
ParentKeys
func (s *Section) ParentKeys() []*Key { var parentKeys []*Key sname := s.name for { if i := strings.LastIndex(sname, "."); i > -1 { sname = sname[:i] sec, err := s.f.GetSection(sname) if err != nil { continue } parentKeys = append(parentKeys, sec.Keys()...) } else { break } } return pa...
go
func (s *Section) ParentKeys() []*Key { var parentKeys []*Key sname := s.name for { if i := strings.LastIndex(sname, "."); i > -1 { sname = sname[:i] sec, err := s.f.GetSection(sname) if err != nil { continue } parentKeys = append(parentKeys, sec.Keys()...) } else { break } } return pa...
[ "func", "(", "s", "*", "Section", ")", "ParentKeys", "(", ")", "[", "]", "*", "Key", "{", "var", "parentKeys", "[", "]", "*", "Key", "\n", "sname", ":=", "s", ".", "name", "\n", "for", "{", "if", "i", ":=", "strings", ".", "LastIndex", "(", "sn...
// ParentKeys returns list of keys of parent section.
[ "ParentKeys", "returns", "list", "of", "keys", "of", "parent", "section", "." ]
3be5ad479f69d4e08d7fe25edf79bf3346bd658e
https://github.com/go-ini/ini/blob/3be5ad479f69d4e08d7fe25edf79bf3346bd658e/section.go#L187-L204
24,704
go-ini/ini
section.go
KeyStrings
func (s *Section) KeyStrings() []string { list := make([]string, len(s.keyList)) copy(list, s.keyList) return list }
go
func (s *Section) KeyStrings() []string { list := make([]string, len(s.keyList)) copy(list, s.keyList) return list }
[ "func", "(", "s", "*", "Section", ")", "KeyStrings", "(", ")", "[", "]", "string", "{", "list", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "s", ".", "keyList", ")", ")", "\n", "copy", "(", "list", ",", "s", ".", "keyList", ")", "...
// KeyStrings returns list of key names of section.
[ "KeyStrings", "returns", "list", "of", "key", "names", "of", "section", "." ]
3be5ad479f69d4e08d7fe25edf79bf3346bd658e
https://github.com/go-ini/ini/blob/3be5ad479f69d4e08d7fe25edf79bf3346bd658e/section.go#L207-L211
24,705
go-ini/ini
section.go
KeysHash
func (s *Section) KeysHash() map[string]string { if s.f.BlockMode { s.f.lock.RLock() defer s.f.lock.RUnlock() } hash := map[string]string{} for key, value := range s.keysHash { hash[key] = value } return hash }
go
func (s *Section) KeysHash() map[string]string { if s.f.BlockMode { s.f.lock.RLock() defer s.f.lock.RUnlock() } hash := map[string]string{} for key, value := range s.keysHash { hash[key] = value } return hash }
[ "func", "(", "s", "*", "Section", ")", "KeysHash", "(", ")", "map", "[", "string", "]", "string", "{", "if", "s", ".", "f", ".", "BlockMode", "{", "s", ".", "f", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "f", ".", "lock", ...
// KeysHash returns keys hash consisting of names and values.
[ "KeysHash", "returns", "keys", "hash", "consisting", "of", "names", "and", "values", "." ]
3be5ad479f69d4e08d7fe25edf79bf3346bd658e
https://github.com/go-ini/ini/blob/3be5ad479f69d4e08d7fe25edf79bf3346bd658e/section.go#L214-L225
24,706
go-ini/ini
section.go
DeleteKey
func (s *Section) DeleteKey(name string) { if s.f.BlockMode { s.f.lock.Lock() defer s.f.lock.Unlock() } for i, k := range s.keyList { if k == name { s.keyList = append(s.keyList[:i], s.keyList[i+1:]...) delete(s.keys, name) delete(s.keysHash, name) return } } }
go
func (s *Section) DeleteKey(name string) { if s.f.BlockMode { s.f.lock.Lock() defer s.f.lock.Unlock() } for i, k := range s.keyList { if k == name { s.keyList = append(s.keyList[:i], s.keyList[i+1:]...) delete(s.keys, name) delete(s.keysHash, name) return } } }
[ "func", "(", "s", "*", "Section", ")", "DeleteKey", "(", "name", "string", ")", "{", "if", "s", ".", "f", ".", "BlockMode", "{", "s", ".", "f", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "f", ".", "lock", ".", "Unlock", "(",...
// DeleteKey deletes a key from section.
[ "DeleteKey", "deletes", "a", "key", "from", "section", "." ]
3be5ad479f69d4e08d7fe25edf79bf3346bd658e
https://github.com/go-ini/ini/blob/3be5ad479f69d4e08d7fe25edf79bf3346bd658e/section.go#L228-L242
24,707
emicklei/go-restful
curly.go
selectRoutes
func (c CurlyRouter) selectRoutes(ws *WebService, requestTokens []string) sortableCurlyRoutes { candidates := make(sortableCurlyRoutes, 0, 8) for _, each := range ws.routes { matches, paramCount, staticCount := c.matchesRouteByPathTokens(each.pathParts, requestTokens) if matches { candidates.add(curlyRoute{eac...
go
func (c CurlyRouter) selectRoutes(ws *WebService, requestTokens []string) sortableCurlyRoutes { candidates := make(sortableCurlyRoutes, 0, 8) for _, each := range ws.routes { matches, paramCount, staticCount := c.matchesRouteByPathTokens(each.pathParts, requestTokens) if matches { candidates.add(curlyRoute{eac...
[ "func", "(", "c", "CurlyRouter", ")", "selectRoutes", "(", "ws", "*", "WebService", ",", "requestTokens", "[", "]", "string", ")", "sortableCurlyRoutes", "{", "candidates", ":=", "make", "(", "sortableCurlyRoutes", ",", "0", ",", "8", ")", "\n", "for", "_"...
// selectRoutes return a collection of Route from a WebService that matches the path tokens from the request.
[ "selectRoutes", "return", "a", "collection", "of", "Route", "from", "a", "WebService", "that", "matches", "the", "path", "tokens", "from", "the", "request", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/curly.go#L47-L57
24,708
emicklei/go-restful
curly.go
matchesRouteByPathTokens
func (c CurlyRouter) matchesRouteByPathTokens(routeTokens, requestTokens []string) (matches bool, paramCount int, staticCount int) { if len(routeTokens) < len(requestTokens) { // proceed in matching only if last routeToken is wildcard count := len(routeTokens) if count == 0 || !strings.HasSuffix(routeTokens[coun...
go
func (c CurlyRouter) matchesRouteByPathTokens(routeTokens, requestTokens []string) (matches bool, paramCount int, staticCount int) { if len(routeTokens) < len(requestTokens) { // proceed in matching only if last routeToken is wildcard count := len(routeTokens) if count == 0 || !strings.HasSuffix(routeTokens[coun...
[ "func", "(", "c", "CurlyRouter", ")", "matchesRouteByPathTokens", "(", "routeTokens", ",", "requestTokens", "[", "]", "string", ")", "(", "matches", "bool", ",", "paramCount", "int", ",", "staticCount", "int", ")", "{", "if", "len", "(", "routeTokens", ")", ...
// matchesRouteByPathTokens computes whether it matches, howmany parameters do match and what the number of static path elements are.
[ "matchesRouteByPathTokens", "computes", "whether", "it", "matches", "howmany", "parameters", "do", "match", "and", "what", "the", "number", "of", "static", "path", "elements", "are", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/curly.go#L60-L95
24,709
emicklei/go-restful
curly.go
detectRoute
func (c CurlyRouter) detectRoute(candidateRoutes sortableCurlyRoutes, httpRequest *http.Request) (*Route, error) { // tracing is done inside detectRoute return jsr311Router.detectRoute(candidateRoutes.routes(), httpRequest) }
go
func (c CurlyRouter) detectRoute(candidateRoutes sortableCurlyRoutes, httpRequest *http.Request) (*Route, error) { // tracing is done inside detectRoute return jsr311Router.detectRoute(candidateRoutes.routes(), httpRequest) }
[ "func", "(", "c", "CurlyRouter", ")", "detectRoute", "(", "candidateRoutes", "sortableCurlyRoutes", ",", "httpRequest", "*", "http", ".", "Request", ")", "(", "*", "Route", ",", "error", ")", "{", "// tracing is done inside detectRoute", "return", "jsr311Router", ...
// detectRoute selectes from a list of Route the first match by inspecting both the Accept and Content-Type // headers of the Request. See also RouterJSR311 in jsr311.go
[ "detectRoute", "selectes", "from", "a", "list", "of", "Route", "the", "first", "match", "by", "inspecting", "both", "the", "Accept", "and", "Content", "-", "Type", "headers", "of", "the", "Request", ".", "See", "also", "RouterJSR311", "in", "jsr311", ".", ...
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/curly.go#L115-L118
24,710
emicklei/go-restful
curly.go
detectWebService
func (c CurlyRouter) detectWebService(requestTokens []string, webServices []*WebService) *WebService { var best *WebService score := -1 for _, each := range webServices { matches, eachScore := c.computeWebserviceScore(requestTokens, each.pathExpr.tokens) if matches && (eachScore > score) { best = each scor...
go
func (c CurlyRouter) detectWebService(requestTokens []string, webServices []*WebService) *WebService { var best *WebService score := -1 for _, each := range webServices { matches, eachScore := c.computeWebserviceScore(requestTokens, each.pathExpr.tokens) if matches && (eachScore > score) { best = each scor...
[ "func", "(", "c", "CurlyRouter", ")", "detectWebService", "(", "requestTokens", "[", "]", "string", ",", "webServices", "[", "]", "*", "WebService", ")", "*", "WebService", "{", "var", "best", "*", "WebService", "\n", "score", ":=", "-", "1", "\n", "for"...
// detectWebService returns the best matching webService given the list of path tokens. // see also computeWebserviceScore
[ "detectWebService", "returns", "the", "best", "matching", "webService", "given", "the", "list", "of", "path", "tokens", ".", "see", "also", "computeWebserviceScore" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/curly.go#L122-L133
24,711
emicklei/go-restful
curly.go
computeWebserviceScore
func (c CurlyRouter) computeWebserviceScore(requestTokens []string, tokens []string) (bool, int) { if len(tokens) > len(requestTokens) { return false, 0 } score := 0 for i := 0; i < len(tokens); i++ { each := requestTokens[i] other := tokens[i] if len(each) == 0 && len(other) == 0 { score++ continue ...
go
func (c CurlyRouter) computeWebserviceScore(requestTokens []string, tokens []string) (bool, int) { if len(tokens) > len(requestTokens) { return false, 0 } score := 0 for i := 0; i < len(tokens); i++ { each := requestTokens[i] other := tokens[i] if len(each) == 0 && len(other) == 0 { score++ continue ...
[ "func", "(", "c", "CurlyRouter", ")", "computeWebserviceScore", "(", "requestTokens", "[", "]", "string", ",", "tokens", "[", "]", "string", ")", "(", "bool", ",", "int", ")", "{", "if", "len", "(", "tokens", ")", ">", "len", "(", "requestTokens", ")",...
// computeWebserviceScore returns whether tokens match and // the weighted score of the longest matching consecutive tokens from the beginning.
[ "computeWebserviceScore", "returns", "whether", "tokens", "match", "and", "the", "weighted", "score", "of", "the", "longest", "matching", "consecutive", "tokens", "from", "the", "beginning", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/curly.go#L137-L164
24,712
emicklei/go-restful
examples/restful-full-logging-filter.go
main
func main() { restful.Add(newUserService()) log.Print("start listening on localhost:8080") log.Fatal(http.ListenAndServe(":8080", nil)) }
go
func main() { restful.Add(newUserService()) log.Print("start listening on localhost:8080") log.Fatal(http.ListenAndServe(":8080", nil)) }
[ "func", "main", "(", ")", "{", "restful", ".", "Add", "(", "newUserService", "(", ")", ")", "\n", "log", ".", "Print", "(", "\"", "\"", ")", "\n", "log", ".", "Fatal", "(", "http", ".", "ListenAndServe", "(", "\"", "\"", ",", "nil", ")", ")", "...
// // This example shows how to log both the request body and response body
[ "This", "example", "shows", "how", "to", "log", "both", "the", "request", "body", "and", "response", "body" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/examples/restful-full-logging-filter.go#L20-L24
24,713
emicklei/go-restful
route_builder.go
Method
func (b *RouteBuilder) Method(method string) *RouteBuilder { b.httpMethod = method return b }
go
func (b *RouteBuilder) Method(method string) *RouteBuilder { b.httpMethod = method return b }
[ "func", "(", "b", "*", "RouteBuilder", ")", "Method", "(", "method", "string", ")", "*", "RouteBuilder", "{", "b", ".", "httpMethod", "=", "method", "\n", "return", "b", "\n", "}" ]
// Method specifies what HTTP method to match. Required.
[ "Method", "specifies", "what", "HTTP", "method", "to", "match", ".", "Required", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route_builder.go#L67-L70
24,714
emicklei/go-restful
route_builder.go
Produces
func (b *RouteBuilder) Produces(mimeTypes ...string) *RouteBuilder { b.produces = mimeTypes return b }
go
func (b *RouteBuilder) Produces(mimeTypes ...string) *RouteBuilder { b.produces = mimeTypes return b }
[ "func", "(", "b", "*", "RouteBuilder", ")", "Produces", "(", "mimeTypes", "...", "string", ")", "*", "RouteBuilder", "{", "b", ".", "produces", "=", "mimeTypes", "\n", "return", "b", "\n", "}" ]
// Produces specifies what MIME types can be produced ; the matched one will appear in the Content-Type Http header.
[ "Produces", "specifies", "what", "MIME", "types", "can", "be", "produced", ";", "the", "matched", "one", "will", "appear", "in", "the", "Content", "-", "Type", "Http", "header", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route_builder.go#L73-L76
24,715
emicklei/go-restful
route_builder.go
Consumes
func (b *RouteBuilder) Consumes(mimeTypes ...string) *RouteBuilder { b.consumes = mimeTypes return b }
go
func (b *RouteBuilder) Consumes(mimeTypes ...string) *RouteBuilder { b.consumes = mimeTypes return b }
[ "func", "(", "b", "*", "RouteBuilder", ")", "Consumes", "(", "mimeTypes", "...", "string", ")", "*", "RouteBuilder", "{", "b", ".", "consumes", "=", "mimeTypes", "\n", "return", "b", "\n", "}" ]
// Consumes specifies what MIME types can be consumes ; the Accept Http header must matched any of these
[ "Consumes", "specifies", "what", "MIME", "types", "can", "be", "consumes", ";", "the", "Accept", "Http", "header", "must", "matched", "any", "of", "these" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route_builder.go#L79-L82
24,716
emicklei/go-restful
route_builder.go
Doc
func (b *RouteBuilder) Doc(documentation string) *RouteBuilder { b.doc = documentation return b }
go
func (b *RouteBuilder) Doc(documentation string) *RouteBuilder { b.doc = documentation return b }
[ "func", "(", "b", "*", "RouteBuilder", ")", "Doc", "(", "documentation", "string", ")", "*", "RouteBuilder", "{", "b", ".", "doc", "=", "documentation", "\n", "return", "b", "\n", "}" ]
// Doc tells what this route is all about. Optional.
[ "Doc", "tells", "what", "this", "route", "is", "all", "about", ".", "Optional", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route_builder.go#L91-L94
24,717
emicklei/go-restful
route_builder.go
Notes
func (b *RouteBuilder) Notes(notes string) *RouteBuilder { b.notes = notes return b }
go
func (b *RouteBuilder) Notes(notes string) *RouteBuilder { b.notes = notes return b }
[ "func", "(", "b", "*", "RouteBuilder", ")", "Notes", "(", "notes", "string", ")", "*", "RouteBuilder", "{", "b", ".", "notes", "=", "notes", "\n", "return", "b", "\n", "}" ]
// Notes is a verbose explanation of the operation behavior. Optional.
[ "Notes", "is", "a", "verbose", "explanation", "of", "the", "operation", "behavior", ".", "Optional", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route_builder.go#L97-L100
24,718
emicklei/go-restful
route_builder.go
Reads
func (b *RouteBuilder) Reads(sample interface{}, optionalDescription ...string) *RouteBuilder { fn := b.typeNameHandleFunc if fn == nil { fn = reflectTypeName } typeAsName := fn(sample) description := "" if len(optionalDescription) > 0 { description = optionalDescription[0] } b.readSample = sample bodyPara...
go
func (b *RouteBuilder) Reads(sample interface{}, optionalDescription ...string) *RouteBuilder { fn := b.typeNameHandleFunc if fn == nil { fn = reflectTypeName } typeAsName := fn(sample) description := "" if len(optionalDescription) > 0 { description = optionalDescription[0] } b.readSample = sample bodyPara...
[ "func", "(", "b", "*", "RouteBuilder", ")", "Reads", "(", "sample", "interface", "{", "}", ",", "optionalDescription", "...", "string", ")", "*", "RouteBuilder", "{", "fn", ":=", "b", ".", "typeNameHandleFunc", "\n", "if", "fn", "==", "nil", "{", "fn", ...
// Reads tells what resource type will be read from the request payload. Optional. // A parameter of type "body" is added ,required is set to true and the dataType is set to the qualified name of the sample's type.
[ "Reads", "tells", "what", "resource", "type", "will", "be", "read", "from", "the", "request", "payload", ".", "Optional", ".", "A", "parameter", "of", "type", "body", "is", "added", "required", "is", "set", "to", "true", "and", "the", "dataType", "is", "...
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route_builder.go#L104-L121
24,719
emicklei/go-restful
route_builder.go
ReturnsError
func (b *RouteBuilder) ReturnsError(code int, message string, model interface{}) *RouteBuilder { log.Print("ReturnsError is deprecated, use Returns instead.") return b.Returns(code, message, model) }
go
func (b *RouteBuilder) ReturnsError(code int, message string, model interface{}) *RouteBuilder { log.Print("ReturnsError is deprecated, use Returns instead.") return b.Returns(code, message, model) }
[ "func", "(", "b", "*", "RouteBuilder", ")", "ReturnsError", "(", "code", "int", ",", "message", "string", ",", "model", "interface", "{", "}", ")", "*", "RouteBuilder", "{", "log", ".", "Print", "(", "\"", "\"", ")", "\n", "return", "b", ".", "Return...
// ReturnsError is deprecated, use Returns instead.
[ "ReturnsError", "is", "deprecated", "use", "Returns", "instead", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route_builder.go#L157-L160
24,720
emicklei/go-restful
route_builder.go
DefaultReturns
func (b *RouteBuilder) DefaultReturns(message string, model interface{}) *RouteBuilder { b.defaultResponse = &ResponseError{ Message: message, Model: model, } return b }
go
func (b *RouteBuilder) DefaultReturns(message string, model interface{}) *RouteBuilder { b.defaultResponse = &ResponseError{ Message: message, Model: model, } return b }
[ "func", "(", "b", "*", "RouteBuilder", ")", "DefaultReturns", "(", "message", "string", ",", "model", "interface", "{", "}", ")", "*", "RouteBuilder", "{", "b", ".", "defaultResponse", "=", "&", "ResponseError", "{", "Message", ":", "message", ",", "Model"...
// DefaultReturns is a special Returns call that sets the default of the response.
[ "DefaultReturns", "is", "a", "special", "Returns", "call", "that", "sets", "the", "default", "of", "the", "response", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route_builder.go#L180-L186
24,721
emicklei/go-restful
route_builder.go
Metadata
func (b *RouteBuilder) Metadata(key string, value interface{}) *RouteBuilder { if b.metadata == nil { b.metadata = map[string]interface{}{} } b.metadata[key] = value return b }
go
func (b *RouteBuilder) Metadata(key string, value interface{}) *RouteBuilder { if b.metadata == nil { b.metadata = map[string]interface{}{} } b.metadata[key] = value return b }
[ "func", "(", "b", "*", "RouteBuilder", ")", "Metadata", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "*", "RouteBuilder", "{", "if", "b", ".", "metadata", "==", "nil", "{", "b", ".", "metadata", "=", "map", "[", "string", "]", "i...
// Metadata adds or updates a key=value pair to the metadata map.
[ "Metadata", "adds", "or", "updates", "a", "key", "=", "value", "pair", "to", "the", "metadata", "map", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route_builder.go#L189-L195
24,722
emicklei/go-restful
route_builder.go
Filter
func (b *RouteBuilder) Filter(filter FilterFunction) *RouteBuilder { b.filters = append(b.filters, filter) return b }
go
func (b *RouteBuilder) Filter(filter FilterFunction) *RouteBuilder { b.filters = append(b.filters, filter) return b }
[ "func", "(", "b", "*", "RouteBuilder", ")", "Filter", "(", "filter", "FilterFunction", ")", "*", "RouteBuilder", "{", "b", ".", "filters", "=", "append", "(", "b", ".", "filters", ",", "filter", ")", "\n", "return", "b", "\n", "}" ]
// Filter appends a FilterFunction to the end of filters for this Route to build.
[ "Filter", "appends", "a", "FilterFunction", "to", "the", "end", "of", "filters", "for", "this", "Route", "to", "build", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route_builder.go#L217-L220
24,723
emicklei/go-restful
route_builder.go
ContentEncodingEnabled
func (b *RouteBuilder) ContentEncodingEnabled(enabled bool) *RouteBuilder { b.contentEncodingEnabled = &enabled return b }
go
func (b *RouteBuilder) ContentEncodingEnabled(enabled bool) *RouteBuilder { b.contentEncodingEnabled = &enabled return b }
[ "func", "(", "b", "*", "RouteBuilder", ")", "ContentEncodingEnabled", "(", "enabled", "bool", ")", "*", "RouteBuilder", "{", "b", ".", "contentEncodingEnabled", "=", "&", "enabled", "\n", "return", "b", "\n", "}" ]
// ContentEncodingEnabled allows you to override the Containers value for auto-compressing this route response.
[ "ContentEncodingEnabled", "allows", "you", "to", "override", "the", "Containers", "value", "for", "auto", "-", "compressing", "this", "route", "response", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route_builder.go#L238-L241
24,724
emicklei/go-restful
route_builder.go
copyDefaults
func (b *RouteBuilder) copyDefaults(rootProduces, rootConsumes []string) { if len(b.produces) == 0 { b.produces = rootProduces } if len(b.consumes) == 0 { b.consumes = rootConsumes } }
go
func (b *RouteBuilder) copyDefaults(rootProduces, rootConsumes []string) { if len(b.produces) == 0 { b.produces = rootProduces } if len(b.consumes) == 0 { b.consumes = rootConsumes } }
[ "func", "(", "b", "*", "RouteBuilder", ")", "copyDefaults", "(", "rootProduces", ",", "rootConsumes", "[", "]", "string", ")", "{", "if", "len", "(", "b", ".", "produces", ")", "==", "0", "{", "b", ".", "produces", "=", "rootProduces", "\n", "}", "\n...
// If no specific Route path then set to rootPath // If no specific Produces then set to rootProduces // If no specific Consumes then set to rootConsumes
[ "If", "no", "specific", "Route", "path", "then", "set", "to", "rootPath", "If", "no", "specific", "Produces", "then", "set", "to", "rootProduces", "If", "no", "specific", "Consumes", "then", "set", "to", "rootConsumes" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route_builder.go#L246-L253
24,725
emicklei/go-restful
route_builder.go
typeNameHandler
func (b *RouteBuilder) typeNameHandler(handler TypeNameHandleFunction) *RouteBuilder { b.typeNameHandleFunc = handler return b }
go
func (b *RouteBuilder) typeNameHandler(handler TypeNameHandleFunction) *RouteBuilder { b.typeNameHandleFunc = handler return b }
[ "func", "(", "b", "*", "RouteBuilder", ")", "typeNameHandler", "(", "handler", "TypeNameHandleFunction", ")", "*", "RouteBuilder", "{", "b", ".", "typeNameHandleFunc", "=", "handler", "\n", "return", "b", "\n", "}" ]
// typeNameHandler sets the function that will convert types to strings in the parameter // and model definitions.
[ "typeNameHandler", "sets", "the", "function", "that", "will", "convert", "types", "to", "strings", "in", "the", "parameter", "and", "model", "definitions", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route_builder.go#L257-L260
24,726
emicklei/go-restful
route_builder.go
Build
func (b *RouteBuilder) Build() Route { pathExpr, err := newPathExpression(b.currentPath) if err != nil { log.Printf("Invalid path:%s because:%v", b.currentPath, err) os.Exit(1) } if b.function == nil { log.Printf("No function specified for route:" + b.currentPath) os.Exit(1) } operationName := b.operation...
go
func (b *RouteBuilder) Build() Route { pathExpr, err := newPathExpression(b.currentPath) if err != nil { log.Printf("Invalid path:%s because:%v", b.currentPath, err) os.Exit(1) } if b.function == nil { log.Printf("No function specified for route:" + b.currentPath) os.Exit(1) } operationName := b.operation...
[ "func", "(", "b", "*", "RouteBuilder", ")", "Build", "(", ")", "Route", "{", "pathExpr", ",", "err", ":=", "newPathExpression", "(", "b", ".", "currentPath", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "b",...
// Build creates a new Route using the specification details collected by the RouteBuilder
[ "Build", "creates", "a", "new", "Route", "using", "the", "specification", "details", "collected", "by", "the", "RouteBuilder" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route_builder.go#L263-L302
24,727
emicklei/go-restful
route_builder.go
nameOfFunction
func nameOfFunction(f interface{}) string { fun := runtime.FuncForPC(reflect.ValueOf(f).Pointer()) tokenized := strings.Split(fun.Name(), ".") last := tokenized[len(tokenized)-1] last = strings.TrimSuffix(last, ")·fm") // < Go 1.5 last = strings.TrimSuffix(last, ")-fm") // Go 1.5 last = strings.TrimSuffix(last, "...
go
func nameOfFunction(f interface{}) string { fun := runtime.FuncForPC(reflect.ValueOf(f).Pointer()) tokenized := strings.Split(fun.Name(), ".") last := tokenized[len(tokenized)-1] last = strings.TrimSuffix(last, ")·fm") // < Go 1.5 last = strings.TrimSuffix(last, ")-fm") // Go 1.5 last = strings.TrimSuffix(last, "...
[ "func", "nameOfFunction", "(", "f", "interface", "{", "}", ")", "string", "{", "fun", ":=", "runtime", ".", "FuncForPC", "(", "reflect", ".", "ValueOf", "(", "f", ")", ".", "Pointer", "(", ")", ")", "\n", "tokenized", ":=", "strings", ".", "Split", "...
// nameOfFunction returns the short name of the function f for documentation. // It uses a runtime feature for debugging ; its value may change for later Go versions.
[ "nameOfFunction", "returns", "the", "short", "name", "of", "the", "function", "f", "for", "documentation", ".", "It", "uses", "a", "runtime", "feature", "for", "debugging", ";", "its", "value", "may", "change", "for", "later", "Go", "versions", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route_builder.go#L312-L326
24,728
emicklei/go-restful
path_expression.go
newPathExpression
func newPathExpression(path string) (*pathExpression, error) { expression, literalCount, varNames, varCount, tokens := templateToRegularExpression(path) compiled, err := regexp.Compile(expression) if err != nil { return nil, err } return &pathExpression{literalCount, varNames, varCount, compiled, expression, tok...
go
func newPathExpression(path string) (*pathExpression, error) { expression, literalCount, varNames, varCount, tokens := templateToRegularExpression(path) compiled, err := regexp.Compile(expression) if err != nil { return nil, err } return &pathExpression{literalCount, varNames, varCount, compiled, expression, tok...
[ "func", "newPathExpression", "(", "path", "string", ")", "(", "*", "pathExpression", ",", "error", ")", "{", "expression", ",", "literalCount", ",", "varNames", ",", "varCount", ",", "tokens", ":=", "templateToRegularExpression", "(", "path", ")", "\n", "compi...
// NewPathExpression creates a PathExpression from the input URL path. // Returns an error if the path is invalid.
[ "NewPathExpression", "creates", "a", "PathExpression", "from", "the", "input", "URL", "path", ".", "Returns", "an", "error", "if", "the", "path", "is", "invalid", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/path_expression.go#L27-L34
24,729
emicklei/go-restful
request.go
QueryParameters
func (r *Request) QueryParameters(name string) []string { return r.Request.URL.Query()[name] }
go
func (r *Request) QueryParameters(name string) []string { return r.Request.URL.Query()[name] }
[ "func", "(", "r", "*", "Request", ")", "QueryParameters", "(", "name", "string", ")", "[", "]", "string", "{", "return", "r", ".", "Request", ".", "URL", ".", "Query", "(", ")", "[", "name", "]", "\n", "}" ]
// QueryParameters returns the all the query parameters values by name
[ "QueryParameters", "returns", "the", "all", "the", "query", "parameters", "values", "by", "name" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/request.go#L55-L57
24,730
emicklei/go-restful
request.go
HeaderParameter
func (r *Request) HeaderParameter(name string) string { return r.Request.Header.Get(name) }
go
func (r *Request) HeaderParameter(name string) string { return r.Request.Header.Get(name) }
[ "func", "(", "r", "*", "Request", ")", "HeaderParameter", "(", "name", "string", ")", "string", "{", "return", "r", ".", "Request", ".", "Header", ".", "Get", "(", "name", ")", "\n", "}" ]
// HeaderParameter returns the HTTP Header value of a Header name or empty if missing
[ "HeaderParameter", "returns", "the", "HTTP", "Header", "value", "of", "a", "Header", "name", "or", "empty", "if", "missing" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/request.go#L69-L71
24,731
emicklei/go-restful
request.go
ReadEntity
func (r *Request) ReadEntity(entityPointer interface{}) (err error) { contentType := r.Request.Header.Get(HEADER_ContentType) contentEncoding := r.Request.Header.Get(HEADER_ContentEncoding) // check if the request body needs decompression if ENCODING_GZIP == contentEncoding { gzipReader := currentCompressorProvi...
go
func (r *Request) ReadEntity(entityPointer interface{}) (err error) { contentType := r.Request.Header.Get(HEADER_ContentType) contentEncoding := r.Request.Header.Get(HEADER_ContentEncoding) // check if the request body needs decompression if ENCODING_GZIP == contentEncoding { gzipReader := currentCompressorProvi...
[ "func", "(", "r", "*", "Request", ")", "ReadEntity", "(", "entityPointer", "interface", "{", "}", ")", "(", "err", "error", ")", "{", "contentType", ":=", "r", ".", "Request", ".", "Header", ".", "Get", "(", "HEADER_ContentType", ")", "\n", "contentEncod...
// ReadEntity checks the Accept header and reads the content into the entityPointer.
[ "ReadEntity", "checks", "the", "Accept", "header", "and", "reads", "the", "content", "into", "the", "entityPointer", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/request.go#L74-L103
24,732
emicklei/go-restful
request.go
SetAttribute
func (r *Request) SetAttribute(name string, value interface{}) { r.attributes[name] = value }
go
func (r *Request) SetAttribute(name string, value interface{}) { r.attributes[name] = value }
[ "func", "(", "r", "*", "Request", ")", "SetAttribute", "(", "name", "string", ",", "value", "interface", "{", "}", ")", "{", "r", ".", "attributes", "[", "name", "]", "=", "value", "\n", "}" ]
// SetAttribute adds or replaces the attribute with the given value.
[ "SetAttribute", "adds", "or", "replaces", "the", "attribute", "with", "the", "given", "value", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/request.go#L106-L108
24,733
emicklei/go-restful
filter.go
ProcessFilter
func (f *FilterChain) ProcessFilter(request *Request, response *Response) { if f.Index < len(f.Filters) { f.Index++ f.Filters[f.Index-1](request, response, f) } else { f.Target(request, response) } }
go
func (f *FilterChain) ProcessFilter(request *Request, response *Response) { if f.Index < len(f.Filters) { f.Index++ f.Filters[f.Index-1](request, response, f) } else { f.Target(request, response) } }
[ "func", "(", "f", "*", "FilterChain", ")", "ProcessFilter", "(", "request", "*", "Request", ",", "response", "*", "Response", ")", "{", "if", "f", ".", "Index", "<", "len", "(", "f", ".", "Filters", ")", "{", "f", ".", "Index", "++", "\n", "f", "...
// ProcessFilter passes the request,response pair through the next of Filters. // Each filter can decide to proceed to the next Filter or handle the Response itself.
[ "ProcessFilter", "passes", "the", "request", "response", "pair", "through", "the", "next", "of", "Filters", ".", "Each", "filter", "can", "decide", "to", "proceed", "to", "the", "next", "Filter", "or", "handle", "the", "Response", "itself", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/filter.go#L16-L23
24,734
emicklei/go-restful
route.go
wrapRequestResponse
func (r *Route) wrapRequestResponse(httpWriter http.ResponseWriter, httpRequest *http.Request, pathParams map[string]string) (*Request, *Response) { wrappedRequest := NewRequest(httpRequest) wrappedRequest.pathParameters = pathParams wrappedRequest.selectedRoutePath = r.Path wrappedResponse := NewResponse(httpWrite...
go
func (r *Route) wrapRequestResponse(httpWriter http.ResponseWriter, httpRequest *http.Request, pathParams map[string]string) (*Request, *Response) { wrappedRequest := NewRequest(httpRequest) wrappedRequest.pathParameters = pathParams wrappedRequest.selectedRoutePath = r.Path wrappedResponse := NewResponse(httpWrite...
[ "func", "(", "r", "*", "Route", ")", "wrapRequestResponse", "(", "httpWriter", "http", ".", "ResponseWriter", ",", "httpRequest", "*", "http", ".", "Request", ",", "pathParams", "map", "[", "string", "]", "string", ")", "(", "*", "Request", ",", "*", "Re...
// Create Request and Response from their http versions
[ "Create", "Request", "and", "Response", "from", "their", "http", "versions" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route.go#L60-L68
24,735
emicklei/go-restful
route.go
dispatchWithFilters
func (r *Route) dispatchWithFilters(wrappedRequest *Request, wrappedResponse *Response) { if len(r.Filters) > 0 { chain := FilterChain{Filters: r.Filters, Target: r.Function} chain.ProcessFilter(wrappedRequest, wrappedResponse) } else { // unfiltered r.Function(wrappedRequest, wrappedResponse) } }
go
func (r *Route) dispatchWithFilters(wrappedRequest *Request, wrappedResponse *Response) { if len(r.Filters) > 0 { chain := FilterChain{Filters: r.Filters, Target: r.Function} chain.ProcessFilter(wrappedRequest, wrappedResponse) } else { // unfiltered r.Function(wrappedRequest, wrappedResponse) } }
[ "func", "(", "r", "*", "Route", ")", "dispatchWithFilters", "(", "wrappedRequest", "*", "Request", ",", "wrappedResponse", "*", "Response", ")", "{", "if", "len", "(", "r", ".", "Filters", ")", ">", "0", "{", "chain", ":=", "FilterChain", "{", "Filters",...
// dispatchWithFilters call the function after passing through its own filters
[ "dispatchWithFilters", "call", "the", "function", "after", "passing", "through", "its", "own", "filters" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route.go#L71-L79
24,736
emicklei/go-restful
route.go
matchesAccept
func (r Route) matchesAccept(mimeTypesWithQuality string) bool { remaining := mimeTypesWithQuality for { var mimeType string if end := strings.Index(remaining, ","); end == -1 { mimeType, remaining = remaining, "" } else { mimeType, remaining = remaining[:end], remaining[end+1:] } if quality := string...
go
func (r Route) matchesAccept(mimeTypesWithQuality string) bool { remaining := mimeTypesWithQuality for { var mimeType string if end := strings.Index(remaining, ","); end == -1 { mimeType, remaining = remaining, "" } else { mimeType, remaining = remaining[:end], remaining[end+1:] } if quality := string...
[ "func", "(", "r", "Route", ")", "matchesAccept", "(", "mimeTypesWithQuality", "string", ")", "bool", "{", "remaining", ":=", "mimeTypesWithQuality", "\n", "for", "{", "var", "mimeType", "string", "\n", "if", "end", ":=", "strings", ".", "Index", "(", "remain...
// Return whether the mimeType matches to what this Route can produce.
[ "Return", "whether", "the", "mimeType", "matches", "to", "what", "this", "Route", "can", "produce", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route.go#L86-L111
24,737
emicklei/go-restful
route.go
tokenizePath
func tokenizePath(path string) []string { if "/" == path { return nil } return strings.Split(strings.Trim(path, "/"), "/") }
go
func tokenizePath(path string) []string { if "/" == path { return nil } return strings.Split(strings.Trim(path, "/"), "/") }
[ "func", "tokenizePath", "(", "path", "string", ")", "[", "]", "string", "{", "if", "\"", "\"", "==", "path", "{", "return", "nil", "\n", "}", "\n", "return", "strings", ".", "Split", "(", "strings", ".", "Trim", "(", "path", ",", "\"", "\"", ")", ...
// Tokenize an URL path using the slash separator ; the result does not have empty tokens
[ "Tokenize", "an", "URL", "path", "using", "the", "slash", "separator", ";", "the", "result", "does", "not", "have", "empty", "tokens" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/route.go#L155-L160
24,738
emicklei/go-restful
examples/msgpack/msgpack_entity.go
Read
func (e entityMsgPackAccess) Read(req *restful.Request, v interface{}) error { return msgpack.NewDecoder(req.Request.Body).Decode(v) }
go
func (e entityMsgPackAccess) Read(req *restful.Request, v interface{}) error { return msgpack.NewDecoder(req.Request.Body).Decode(v) }
[ "func", "(", "e", "entityMsgPackAccess", ")", "Read", "(", "req", "*", "restful", ".", "Request", ",", "v", "interface", "{", "}", ")", "error", "{", "return", "msgpack", ".", "NewDecoder", "(", "req", ".", "Request", ".", "Body", ")", ".", "Decode", ...
// Read unmarshalls the value from byte slice and using msgpack to unmarshal
[ "Read", "unmarshalls", "the", "value", "from", "byte", "slice", "and", "using", "msgpack", "to", "unmarshal" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/examples/msgpack/msgpack_entity.go#L21-L23
24,739
emicklei/go-restful
examples/msgpack/msgpack_entity.go
Write
func (e entityMsgPackAccess) Write(resp *restful.Response, status int, v interface{}) error { if v == nil { resp.WriteHeader(status) // do not write a nil representation return nil } resp.WriteHeader(status) return msgpack.NewEncoder(resp).Encode(v) }
go
func (e entityMsgPackAccess) Write(resp *restful.Response, status int, v interface{}) error { if v == nil { resp.WriteHeader(status) // do not write a nil representation return nil } resp.WriteHeader(status) return msgpack.NewEncoder(resp).Encode(v) }
[ "func", "(", "e", "entityMsgPackAccess", ")", "Write", "(", "resp", "*", "restful", ".", "Response", ",", "status", "int", ",", "v", "interface", "{", "}", ")", "error", "{", "if", "v", "==", "nil", "{", "resp", ".", "WriteHeader", "(", "status", ")"...
// Write marshals the value to byte slice and set the Content-Type Header.
[ "Write", "marshals", "the", "value", "to", "byte", "slice", "and", "set", "the", "Content", "-", "Type", "Header", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/examples/msgpack/msgpack_entity.go#L26-L34
24,740
emicklei/go-restful
jsr311.go
ExtractParameters
func (r RouterJSR311) ExtractParameters(route *Route, webService *WebService, urlPath string) map[string]string { webServiceExpr := webService.pathExpr webServiceMatches := webServiceExpr.Matcher.FindStringSubmatch(urlPath) pathParameters := r.extractParams(webServiceExpr, webServiceMatches) routeExpr := route.path...
go
func (r RouterJSR311) ExtractParameters(route *Route, webService *WebService, urlPath string) map[string]string { webServiceExpr := webService.pathExpr webServiceMatches := webServiceExpr.Matcher.FindStringSubmatch(urlPath) pathParameters := r.extractParams(webServiceExpr, webServiceMatches) routeExpr := route.path...
[ "func", "(", "r", "RouterJSR311", ")", "ExtractParameters", "(", "route", "*", "Route", ",", "webService", "*", "WebService", ",", "urlPath", "string", ")", "map", "[", "string", "]", "string", "{", "webServiceExpr", ":=", "webService", ".", "pathExpr", "\n"...
// ExtractParameters is used to obtain the path parameters from the route using the same matching // engine as the JSR 311 router.
[ "ExtractParameters", "is", "used", "to", "obtain", "the", "path", "parameters", "from", "the", "route", "using", "the", "same", "matching", "engine", "as", "the", "JSR", "311", "router", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/jsr311.go#L44-L55
24,741
emicklei/go-restful
container.go
Add
func (c *Container) Add(service *WebService) *Container { c.webServicesLock.Lock() defer c.webServicesLock.Unlock() // if rootPath was not set then lazy initialize it if len(service.rootPath) == 0 { service.Path("/") } // cannot have duplicate root paths for _, each := range c.webServices { if each.RootPat...
go
func (c *Container) Add(service *WebService) *Container { c.webServicesLock.Lock() defer c.webServicesLock.Unlock() // if rootPath was not set then lazy initialize it if len(service.rootPath) == 0 { service.Path("/") } // cannot have duplicate root paths for _, each := range c.webServices { if each.RootPat...
[ "func", "(", "c", "*", "Container", ")", "Add", "(", "service", "*", "WebService", ")", "*", "Container", "{", "c", ".", "webServicesLock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "webServicesLock", ".", "Unlock", "(", ")", "\n\n", "// if rootP...
// Add a WebService to the Container. It will detect duplicate root paths and exit in that case.
[ "Add", "a", "WebService", "to", "the", "Container", ".", "It", "will", "detect", "duplicate", "root", "paths", "and", "exit", "in", "that", "case", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/container.go#L88-L111
24,742
emicklei/go-restful
container.go
logStackOnRecover
func logStackOnRecover(panicReason interface{}, httpWriter http.ResponseWriter) { var buffer bytes.Buffer buffer.WriteString(fmt.Sprintf("recover from panic situation: - %v\r\n", panicReason)) for i := 2; ; i += 1 { _, file, line, ok := runtime.Caller(i) if !ok { break } buffer.WriteString(fmt.Sprintf(" ...
go
func logStackOnRecover(panicReason interface{}, httpWriter http.ResponseWriter) { var buffer bytes.Buffer buffer.WriteString(fmt.Sprintf("recover from panic situation: - %v\r\n", panicReason)) for i := 2; ; i += 1 { _, file, line, ok := runtime.Caller(i) if !ok { break } buffer.WriteString(fmt.Sprintf(" ...
[ "func", "logStackOnRecover", "(", "panicReason", "interface", "{", "}", ",", "httpWriter", "http", ".", "ResponseWriter", ")", "{", "var", "buffer", "bytes", ".", "Buffer", "\n", "buffer", ".", "WriteString", "(", "fmt", ".", "Sprintf", "(", "\"", "\\r", "...
// logStackOnRecover is the default RecoverHandleFunction and is called // when DoNotRecover is false and the recoverHandleFunc is not set for the container. // Default implementation logs the stacktrace and writes the stacktrace on the response. // This may be a security issue as it exposes sourcecode information.
[ "logStackOnRecover", "is", "the", "default", "RecoverHandleFunction", "and", "is", "called", "when", "DoNotRecover", "is", "false", "and", "the", "recoverHandleFunc", "is", "not", "set", "for", "the", "container", ".", "Default", "implementation", "logs", "the", "...
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/container.go#L169-L182
24,743
emicklei/go-restful
container.go
HandleWithFilter
func (c *Container) HandleWithFilter(pattern string, handler http.Handler) { f := func(httpResponse http.ResponseWriter, httpRequest *http.Request) { if len(c.containerFilters) == 0 { handler.ServeHTTP(httpResponse, httpRequest) return } chain := FilterChain{Filters: c.containerFilters, Target: func(req *...
go
func (c *Container) HandleWithFilter(pattern string, handler http.Handler) { f := func(httpResponse http.ResponseWriter, httpRequest *http.Request) { if len(c.containerFilters) == 0 { handler.ServeHTTP(httpResponse, httpRequest) return } chain := FilterChain{Filters: c.containerFilters, Target: func(req *...
[ "func", "(", "c", "*", "Container", ")", "HandleWithFilter", "(", "pattern", "string", ",", "handler", "http", ".", "Handler", ")", "{", "f", ":=", "func", "(", "httpResponse", "http", ".", "ResponseWriter", ",", "httpRequest", "*", "http", ".", "Request",...
// HandleWithFilter registers the handler for the given pattern. // Container's filter chain is applied for handler. // If a handler already exists for pattern, HandleWithFilter panics.
[ "HandleWithFilter", "registers", "the", "handler", "for", "the", "given", "pattern", ".", "Container", "s", "filter", "chain", "is", "applied", "for", "handler", ".", "If", "a", "handler", "already", "exists", "for", "pattern", "HandleWithFilter", "panics", "." ...
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/container.go#L314-L328
24,744
emicklei/go-restful
container.go
Filter
func (c *Container) Filter(filter FilterFunction) { c.containerFilters = append(c.containerFilters, filter) }
go
func (c *Container) Filter(filter FilterFunction) { c.containerFilters = append(c.containerFilters, filter) }
[ "func", "(", "c", "*", "Container", ")", "Filter", "(", "filter", "FilterFunction", ")", "{", "c", ".", "containerFilters", "=", "append", "(", "c", ".", "containerFilters", ",", "filter", ")", "\n", "}" ]
// Filter appends a container FilterFunction. These are called before dispatching // a http.Request to a WebService from the container
[ "Filter", "appends", "a", "container", "FilterFunction", ".", "These", "are", "called", "before", "dispatching", "a", "http", ".", "Request", "to", "a", "WebService", "from", "the", "container" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/container.go#L332-L334
24,745
emicklei/go-restful
container.go
RegisteredWebServices
func (c *Container) RegisteredWebServices() []*WebService { c.webServicesLock.RLock() defer c.webServicesLock.RUnlock() result := make([]*WebService, len(c.webServices)) for ix := range c.webServices { result[ix] = c.webServices[ix] } return result }
go
func (c *Container) RegisteredWebServices() []*WebService { c.webServicesLock.RLock() defer c.webServicesLock.RUnlock() result := make([]*WebService, len(c.webServices)) for ix := range c.webServices { result[ix] = c.webServices[ix] } return result }
[ "func", "(", "c", "*", "Container", ")", "RegisteredWebServices", "(", ")", "[", "]", "*", "WebService", "{", "c", ".", "webServicesLock", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "webServicesLock", ".", "RUnlock", "(", ")", "\n", "result", ":=...
// RegisteredWebServices returns the collections of added WebServices
[ "RegisteredWebServices", "returns", "the", "collections", "of", "added", "WebServices" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/container.go#L337-L345
24,746
emicklei/go-restful
container.go
computeAllowedMethods
func (c *Container) computeAllowedMethods(req *Request) []string { // Go through all RegisteredWebServices() and all its Routes to collect the options methods := []string{} requestPath := req.Request.URL.Path for _, ws := range c.RegisteredWebServices() { matches := ws.pathExpr.Matcher.FindStringSubmatch(requestP...
go
func (c *Container) computeAllowedMethods(req *Request) []string { // Go through all RegisteredWebServices() and all its Routes to collect the options methods := []string{} requestPath := req.Request.URL.Path for _, ws := range c.RegisteredWebServices() { matches := ws.pathExpr.Matcher.FindStringSubmatch(requestP...
[ "func", "(", "c", "*", "Container", ")", "computeAllowedMethods", "(", "req", "*", "Request", ")", "[", "]", "string", "{", "// Go through all RegisteredWebServices() and all its Routes to collect the options", "methods", ":=", "[", "]", "string", "{", "}", "\n", "r...
// computeAllowedMethods returns a list of HTTP methods that are valid for a Request
[ "computeAllowedMethods", "returns", "a", "list", "of", "HTTP", "methods", "that", "are", "valid", "for", "a", "Request" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/container.go#L348-L369
24,747
emicklei/go-restful
compress.go
Write
func (c *CompressingResponseWriter) Write(bytes []byte) (int, error) { if c.isCompressorClosed() { return -1, errors.New("Compressing error: tried to write data using closed compressor") } return c.compressor.Write(bytes) }
go
func (c *CompressingResponseWriter) Write(bytes []byte) (int, error) { if c.isCompressorClosed() { return -1, errors.New("Compressing error: tried to write data using closed compressor") } return c.compressor.Write(bytes) }
[ "func", "(", "c", "*", "CompressingResponseWriter", ")", "Write", "(", "bytes", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "c", ".", "isCompressorClosed", "(", ")", "{", "return", "-", "1", ",", "errors", ".", "New", "(", "\""...
// Write is part of http.ResponseWriter interface // It is passed through the compressor
[ "Write", "is", "part", "of", "http", ".", "ResponseWriter", "interface", "It", "is", "passed", "through", "the", "compressor" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/compress.go#L40-L45
24,748
emicklei/go-restful
compress.go
wantsCompressedResponse
func wantsCompressedResponse(httpRequest *http.Request) (bool, string) { header := httpRequest.Header.Get(HEADER_AcceptEncoding) gi := strings.Index(header, ENCODING_GZIP) zi := strings.Index(header, ENCODING_DEFLATE) // use in order of appearance if gi == -1 { return zi != -1, ENCODING_DEFLATE } else if zi == ...
go
func wantsCompressedResponse(httpRequest *http.Request) (bool, string) { header := httpRequest.Header.Get(HEADER_AcceptEncoding) gi := strings.Index(header, ENCODING_GZIP) zi := strings.Index(header, ENCODING_DEFLATE) // use in order of appearance if gi == -1 { return zi != -1, ENCODING_DEFLATE } else if zi == ...
[ "func", "wantsCompressedResponse", "(", "httpRequest", "*", "http", ".", "Request", ")", "(", "bool", ",", "string", ")", "{", "header", ":=", "httpRequest", ".", "Header", ".", "Get", "(", "HEADER_AcceptEncoding", ")", "\n", "gi", ":=", "strings", ".", "I...
// WantsCompressedResponse reads the Accept-Encoding header to see if and which encoding is requested.
[ "WantsCompressedResponse", "reads", "the", "Accept", "-", "Encoding", "header", "to", "see", "if", "and", "which", "encoding", "is", "requested", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/compress.go#L86-L101
24,749
emicklei/go-restful
path_processor.go
ExtractParameters
func (d defaultPathProcessor) ExtractParameters(r *Route, _ *WebService, urlPath string) map[string]string { urlParts := tokenizePath(urlPath) pathParameters := map[string]string{} for i, key := range r.pathParts { var value string if i >= len(urlParts) { value = "" } else { value = urlParts[i] } if ...
go
func (d defaultPathProcessor) ExtractParameters(r *Route, _ *WebService, urlPath string) map[string]string { urlParts := tokenizePath(urlPath) pathParameters := map[string]string{} for i, key := range r.pathParts { var value string if i >= len(urlParts) { value = "" } else { value = urlParts[i] } if ...
[ "func", "(", "d", "defaultPathProcessor", ")", "ExtractParameters", "(", "r", "*", "Route", ",", "_", "*", "WebService", ",", "urlPath", "string", ")", "map", "[", "string", "]", "string", "{", "urlParts", ":=", "tokenizePath", "(", "urlPath", ")", "\n", ...
// Extract the parameters from the request url path
[ "Extract", "the", "parameters", "from", "the", "request", "url", "path" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/path_processor.go#L22-L50
24,750
emicklei/go-restful
path_processor.go
untokenizePath
func untokenizePath(offset int, parts []string) string { var buffer bytes.Buffer for p := offset; p < len(parts); p++ { buffer.WriteString(parts[p]) // do not end if p < len(parts)-1 { buffer.WriteString("/") } } return buffer.String() }
go
func untokenizePath(offset int, parts []string) string { var buffer bytes.Buffer for p := offset; p < len(parts); p++ { buffer.WriteString(parts[p]) // do not end if p < len(parts)-1 { buffer.WriteString("/") } } return buffer.String() }
[ "func", "untokenizePath", "(", "offset", "int", ",", "parts", "[", "]", "string", ")", "string", "{", "var", "buffer", "bytes", ".", "Buffer", "\n", "for", "p", ":=", "offset", ";", "p", "<", "len", "(", "parts", ")", ";", "p", "++", "{", "buffer",...
// Untokenize back into an URL path using the slash separator
[ "Untokenize", "back", "into", "an", "URL", "path", "using", "the", "slash", "separator" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/path_processor.go#L53-L63
24,751
emicklei/go-restful
web_service.go
compilePathExpression
func (w *WebService) compilePathExpression() { compiled, err := newPathExpression(w.rootPath) if err != nil { log.Printf("invalid path:%s because:%v", w.rootPath, err) os.Exit(1) } w.pathExpr = compiled }
go
func (w *WebService) compilePathExpression() { compiled, err := newPathExpression(w.rootPath) if err != nil { log.Printf("invalid path:%s because:%v", w.rootPath, err) os.Exit(1) } w.pathExpr = compiled }
[ "func", "(", "w", "*", "WebService", ")", "compilePathExpression", "(", ")", "{", "compiled", ",", "err", ":=", "newPathExpression", "(", "w", ".", "rootPath", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "w",...
// compilePathExpression ensures that the path is compiled into a RegEx for those routers that need it.
[ "compilePathExpression", "ensures", "that", "the", "path", "is", "compiled", "into", "a", "RegEx", "for", "those", "routers", "that", "need", "it", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/web_service.go#L60-L67
24,752
emicklei/go-restful
web_service.go
ApiVersion
func (w *WebService) ApiVersion(apiVersion string) *WebService { w.apiVersion = apiVersion return w }
go
func (w *WebService) ApiVersion(apiVersion string) *WebService { w.apiVersion = apiVersion return w }
[ "func", "(", "w", "*", "WebService", ")", "ApiVersion", "(", "apiVersion", "string", ")", "*", "WebService", "{", "w", ".", "apiVersion", "=", "apiVersion", "\n", "return", "w", "\n", "}" ]
// ApiVersion sets the API version for documentation purposes.
[ "ApiVersion", "sets", "the", "API", "version", "for", "documentation", "purposes", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/web_service.go#L70-L73
24,753
emicklei/go-restful
web_service.go
Path
func (w *WebService) Path(root string) *WebService { w.rootPath = root if len(w.rootPath) == 0 { w.rootPath = "/" } w.compilePathExpression() return w }
go
func (w *WebService) Path(root string) *WebService { w.rootPath = root if len(w.rootPath) == 0 { w.rootPath = "/" } w.compilePathExpression() return w }
[ "func", "(", "w", "*", "WebService", ")", "Path", "(", "root", "string", ")", "*", "WebService", "{", "w", ".", "rootPath", "=", "root", "\n", "if", "len", "(", "w", ".", "rootPath", ")", "==", "0", "{", "w", ".", "rootPath", "=", "\"", "\"", "...
// Path specifies the root URL template path of the WebService. // All Routes will be relative to this path.
[ "Path", "specifies", "the", "root", "URL", "template", "path", "of", "the", "WebService", ".", "All", "Routes", "will", "be", "relative", "to", "this", "path", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/web_service.go#L80-L87
24,754
emicklei/go-restful
web_service.go
Param
func (w *WebService) Param(parameter *Parameter) *WebService { if w.pathParameters == nil { w.pathParameters = []*Parameter{} } w.pathParameters = append(w.pathParameters, parameter) return w }
go
func (w *WebService) Param(parameter *Parameter) *WebService { if w.pathParameters == nil { w.pathParameters = []*Parameter{} } w.pathParameters = append(w.pathParameters, parameter) return w }
[ "func", "(", "w", "*", "WebService", ")", "Param", "(", "parameter", "*", "Parameter", ")", "*", "WebService", "{", "if", "w", ".", "pathParameters", "==", "nil", "{", "w", ".", "pathParameters", "=", "[", "]", "*", "Parameter", "{", "}", "\n", "}", ...
// Param adds a PathParameter to document parameters used in the root path.
[ "Param", "adds", "a", "PathParameter", "to", "document", "parameters", "used", "in", "the", "root", "path", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/web_service.go#L90-L96
24,755
emicklei/go-restful
web_service.go
Route
func (w *WebService) Route(builder *RouteBuilder) *WebService { w.routesLock.Lock() defer w.routesLock.Unlock() builder.copyDefaults(w.produces, w.consumes) w.routes = append(w.routes, builder.Build()) return w }
go
func (w *WebService) Route(builder *RouteBuilder) *WebService { w.routesLock.Lock() defer w.routesLock.Unlock() builder.copyDefaults(w.produces, w.consumes) w.routes = append(w.routes, builder.Build()) return w }
[ "func", "(", "w", "*", "WebService", ")", "Route", "(", "builder", "*", "RouteBuilder", ")", "*", "WebService", "{", "w", ".", "routesLock", ".", "Lock", "(", ")", "\n", "defer", "w", ".", "routesLock", ".", "Unlock", "(", ")", "\n", "builder", ".", ...
// Route creates a new Route using the RouteBuilder and add to the ordered list of Routes.
[ "Route", "creates", "a", "new", "Route", "using", "the", "RouteBuilder", "and", "add", "to", "the", "ordered", "list", "of", "Routes", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/web_service.go#L169-L175
24,756
emicklei/go-restful
web_service.go
RemoveRoute
func (w *WebService) RemoveRoute(path, method string) error { if !w.dynamicRoutes { return errors.New("dynamic routes are not enabled.") } w.routesLock.Lock() defer w.routesLock.Unlock() newRoutes := make([]Route, (len(w.routes) - 1)) current := 0 for ix := range w.routes { if w.routes[ix].Method == method &...
go
func (w *WebService) RemoveRoute(path, method string) error { if !w.dynamicRoutes { return errors.New("dynamic routes are not enabled.") } w.routesLock.Lock() defer w.routesLock.Unlock() newRoutes := make([]Route, (len(w.routes) - 1)) current := 0 for ix := range w.routes { if w.routes[ix].Method == method &...
[ "func", "(", "w", "*", "WebService", ")", "RemoveRoute", "(", "path", ",", "method", "string", ")", "error", "{", "if", "!", "w", ".", "dynamicRoutes", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "w", ".", "routesLoc...
// RemoveRoute removes the specified route, looks for something that matches 'path' and 'method'
[ "RemoveRoute", "removes", "the", "specified", "route", "looks", "for", "something", "that", "matches", "path", "and", "method" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/web_service.go#L178-L195
24,757
emicklei/go-restful
web_service.go
Method
func (w *WebService) Method(httpMethod string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method(httpMethod) }
go
func (w *WebService) Method(httpMethod string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method(httpMethod) }
[ "func", "(", "w", "*", "WebService", ")", "Method", "(", "httpMethod", "string", ")", "*", "RouteBuilder", "{", "return", "new", "(", "RouteBuilder", ")", ".", "typeNameHandler", "(", "w", ".", "typeNameHandleFunc", ")", ".", "servicePath", "(", "w", ".", ...
// Method creates a new RouteBuilder and initialize its http method
[ "Method", "creates", "a", "new", "RouteBuilder", "and", "initialize", "its", "http", "method" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/web_service.go#L198-L200
24,758
emicklei/go-restful
web_service.go
Produces
func (w *WebService) Produces(contentTypes ...string) *WebService { w.produces = contentTypes return w }
go
func (w *WebService) Produces(contentTypes ...string) *WebService { w.produces = contentTypes return w }
[ "func", "(", "w", "*", "WebService", ")", "Produces", "(", "contentTypes", "...", "string", ")", "*", "WebService", "{", "w", ".", "produces", "=", "contentTypes", "\n", "return", "w", "\n", "}" ]
// Produces specifies that this WebService can produce one or more MIME types. // Http requests must have one of these values set for the Accept header.
[ "Produces", "specifies", "that", "this", "WebService", "can", "produce", "one", "or", "more", "MIME", "types", ".", "Http", "requests", "must", "have", "one", "of", "these", "values", "set", "for", "the", "Accept", "header", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/web_service.go#L204-L207
24,759
emicklei/go-restful
web_service.go
Consumes
func (w *WebService) Consumes(accepts ...string) *WebService { w.consumes = accepts return w }
go
func (w *WebService) Consumes(accepts ...string) *WebService { w.consumes = accepts return w }
[ "func", "(", "w", "*", "WebService", ")", "Consumes", "(", "accepts", "...", "string", ")", "*", "WebService", "{", "w", ".", "consumes", "=", "accepts", "\n", "return", "w", "\n", "}" ]
// Consumes specifies that this WebService can consume one or more MIME types. // Http requests must have one of these values set for the Content-Type header.
[ "Consumes", "specifies", "that", "this", "WebService", "can", "consume", "one", "or", "more", "MIME", "types", ".", "Http", "requests", "must", "have", "one", "of", "these", "values", "set", "for", "the", "Content", "-", "Type", "header", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/web_service.go#L211-L214
24,760
emicklei/go-restful
web_service.go
Routes
func (w *WebService) Routes() []Route { if !w.dynamicRoutes { return w.routes } // Make a copy of the array to prevent concurrency problems w.routesLock.RLock() defer w.routesLock.RUnlock() result := make([]Route, len(w.routes)) for ix := range w.routes { result[ix] = w.routes[ix] } return result }
go
func (w *WebService) Routes() []Route { if !w.dynamicRoutes { return w.routes } // Make a copy of the array to prevent concurrency problems w.routesLock.RLock() defer w.routesLock.RUnlock() result := make([]Route, len(w.routes)) for ix := range w.routes { result[ix] = w.routes[ix] } return result }
[ "func", "(", "w", "*", "WebService", ")", "Routes", "(", ")", "[", "]", "Route", "{", "if", "!", "w", ".", "dynamicRoutes", "{", "return", "w", ".", "routes", "\n", "}", "\n", "// Make a copy of the array to prevent concurrency problems", "w", ".", "routesLo...
// Routes returns the Routes associated with this WebService
[ "Routes", "returns", "the", "Routes", "associated", "with", "this", "WebService" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/web_service.go#L217-L229
24,761
emicklei/go-restful
web_service.go
Filter
func (w *WebService) Filter(filter FilterFunction) *WebService { w.filters = append(w.filters, filter) return w }
go
func (w *WebService) Filter(filter FilterFunction) *WebService { w.filters = append(w.filters, filter) return w }
[ "func", "(", "w", "*", "WebService", ")", "Filter", "(", "filter", "FilterFunction", ")", "*", "WebService", "{", "w", ".", "filters", "=", "append", "(", "w", ".", "filters", ",", "filter", ")", "\n", "return", "w", "\n", "}" ]
// Filter adds a filter function to the chain of filters applicable to all its Routes
[ "Filter", "adds", "a", "filter", "function", "to", "the", "chain", "of", "filters", "applicable", "to", "all", "its", "Routes" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/web_service.go#L242-L245
24,762
emicklei/go-restful
web_service.go
Doc
func (w *WebService) Doc(plainText string) *WebService { w.documentation = plainText return w }
go
func (w *WebService) Doc(plainText string) *WebService { w.documentation = plainText return w }
[ "func", "(", "w", "*", "WebService", ")", "Doc", "(", "plainText", "string", ")", "*", "WebService", "{", "w", ".", "documentation", "=", "plainText", "\n", "return", "w", "\n", "}" ]
// Doc is used to set the documentation of this service.
[ "Doc", "is", "used", "to", "set", "the", "documentation", "of", "this", "service", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/web_service.go#L248-L251
24,763
emicklei/go-restful
parameter.go
Required
func (p *Parameter) Required(required bool) *Parameter { p.data.Required = required return p }
go
func (p *Parameter) Required(required bool) *Parameter { p.data.Required = required return p }
[ "func", "(", "p", "*", "Parameter", ")", "Required", "(", "required", "bool", ")", "*", "Parameter", "{", "p", ".", "data", ".", "Required", "=", "required", "\n", "return", "p", "\n", "}" ]
// Required sets the required field and returns the receiver
[ "Required", "sets", "the", "required", "field", "and", "returns", "the", "receiver" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/parameter.go#L98-L101
24,764
emicklei/go-restful
parameter.go
AllowMultiple
func (p *Parameter) AllowMultiple(multiple bool) *Parameter { p.data.AllowMultiple = multiple return p }
go
func (p *Parameter) AllowMultiple(multiple bool) *Parameter { p.data.AllowMultiple = multiple return p }
[ "func", "(", "p", "*", "Parameter", ")", "AllowMultiple", "(", "multiple", "bool", ")", "*", "Parameter", "{", "p", ".", "data", ".", "AllowMultiple", "=", "multiple", "\n", "return", "p", "\n", "}" ]
// AllowMultiple sets the allowMultiple field and returns the receiver
[ "AllowMultiple", "sets", "the", "allowMultiple", "field", "and", "returns", "the", "receiver" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/parameter.go#L104-L107
24,765
emicklei/go-restful
parameter.go
AllowableValues
func (p *Parameter) AllowableValues(values map[string]string) *Parameter { p.data.AllowableValues = values return p }
go
func (p *Parameter) AllowableValues(values map[string]string) *Parameter { p.data.AllowableValues = values return p }
[ "func", "(", "p", "*", "Parameter", ")", "AllowableValues", "(", "values", "map", "[", "string", "]", "string", ")", "*", "Parameter", "{", "p", ".", "data", ".", "AllowableValues", "=", "values", "\n", "return", "p", "\n", "}" ]
// AllowableValues sets the allowableValues field and returns the receiver
[ "AllowableValues", "sets", "the", "allowableValues", "field", "and", "returns", "the", "receiver" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/parameter.go#L110-L113
24,766
emicklei/go-restful
parameter.go
DataType
func (p *Parameter) DataType(typeName string) *Parameter { p.data.DataType = typeName return p }
go
func (p *Parameter) DataType(typeName string) *Parameter { p.data.DataType = typeName return p }
[ "func", "(", "p", "*", "Parameter", ")", "DataType", "(", "typeName", "string", ")", "*", "Parameter", "{", "p", ".", "data", ".", "DataType", "=", "typeName", "\n", "return", "p", "\n", "}" ]
// DataType sets the dataType field and returns the receiver
[ "DataType", "sets", "the", "dataType", "field", "and", "returns", "the", "receiver" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/parameter.go#L116-L119
24,767
emicklei/go-restful
parameter.go
DataFormat
func (p *Parameter) DataFormat(formatName string) *Parameter { p.data.DataFormat = formatName return p }
go
func (p *Parameter) DataFormat(formatName string) *Parameter { p.data.DataFormat = formatName return p }
[ "func", "(", "p", "*", "Parameter", ")", "DataFormat", "(", "formatName", "string", ")", "*", "Parameter", "{", "p", ".", "data", ".", "DataFormat", "=", "formatName", "\n", "return", "p", "\n", "}" ]
// DataFormat sets the dataFormat field for Swagger UI
[ "DataFormat", "sets", "the", "dataFormat", "field", "for", "Swagger", "UI" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/parameter.go#L122-L125
24,768
emicklei/go-restful
parameter.go
DefaultValue
func (p *Parameter) DefaultValue(stringRepresentation string) *Parameter { p.data.DefaultValue = stringRepresentation return p }
go
func (p *Parameter) DefaultValue(stringRepresentation string) *Parameter { p.data.DefaultValue = stringRepresentation return p }
[ "func", "(", "p", "*", "Parameter", ")", "DefaultValue", "(", "stringRepresentation", "string", ")", "*", "Parameter", "{", "p", ".", "data", ".", "DefaultValue", "=", "stringRepresentation", "\n", "return", "p", "\n", "}" ]
// DefaultValue sets the default value field and returns the receiver
[ "DefaultValue", "sets", "the", "default", "value", "field", "and", "returns", "the", "receiver" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/parameter.go#L128-L131
24,769
emicklei/go-restful
parameter.go
Description
func (p *Parameter) Description(doc string) *Parameter { p.data.Description = doc return p }
go
func (p *Parameter) Description(doc string) *Parameter { p.data.Description = doc return p }
[ "func", "(", "p", "*", "Parameter", ")", "Description", "(", "doc", "string", ")", "*", "Parameter", "{", "p", ".", "data", ".", "Description", "=", "doc", "\n", "return", "p", "\n", "}" ]
// Description sets the description value field and returns the receiver
[ "Description", "sets", "the", "description", "value", "field", "and", "returns", "the", "receiver" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/parameter.go#L134-L137
24,770
emicklei/go-restful
parameter.go
CollectionFormat
func (p *Parameter) CollectionFormat(format CollectionFormat) *Parameter { p.data.CollectionFormat = format.String() return p }
go
func (p *Parameter) CollectionFormat(format CollectionFormat) *Parameter { p.data.CollectionFormat = format.String() return p }
[ "func", "(", "p", "*", "Parameter", ")", "CollectionFormat", "(", "format", "CollectionFormat", ")", "*", "Parameter", "{", "p", ".", "data", ".", "CollectionFormat", "=", "format", ".", "String", "(", ")", "\n", "return", "p", "\n", "}" ]
// CollectionFormat sets the collection format for an array type
[ "CollectionFormat", "sets", "the", "collection", "format", "for", "an", "array", "type" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/parameter.go#L140-L143
24,771
emicklei/go-restful
response.go
NewResponse
func NewResponse(httpWriter http.ResponseWriter) *Response { hijacker, _ := httpWriter.(http.Hijacker) return &Response{ResponseWriter: httpWriter, routeProduces: []string{}, statusCode: http.StatusOK, prettyPrint: PrettyPrintResponses, hijacker: hijacker} }
go
func NewResponse(httpWriter http.ResponseWriter) *Response { hijacker, _ := httpWriter.(http.Hijacker) return &Response{ResponseWriter: httpWriter, routeProduces: []string{}, statusCode: http.StatusOK, prettyPrint: PrettyPrintResponses, hijacker: hijacker} }
[ "func", "NewResponse", "(", "httpWriter", "http", ".", "ResponseWriter", ")", "*", "Response", "{", "hijacker", ",", "_", ":=", "httpWriter", ".", "(", "http", ".", "Hijacker", ")", "\n", "return", "&", "Response", "{", "ResponseWriter", ":", "httpWriter", ...
// NewResponse creates a new response based on a http ResponseWriter.
[ "NewResponse", "creates", "a", "new", "response", "based", "on", "a", "http", "ResponseWriter", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/response.go#L34-L37
24,772
emicklei/go-restful
response.go
Hijack
func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error) { if r.hijacker == nil { return nil, nil, errors.New("http.Hijacker not implemented by underlying http.ResponseWriter") } return r.hijacker.Hijack() }
go
func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error) { if r.hijacker == nil { return nil, nil, errors.New("http.Hijacker not implemented by underlying http.ResponseWriter") } return r.hijacker.Hijack() }
[ "func", "(", "r", "*", "Response", ")", "Hijack", "(", ")", "(", "net", ".", "Conn", ",", "*", "bufio", ".", "ReadWriter", ",", "error", ")", "{", "if", "r", ".", "hijacker", "==", "nil", "{", "return", "nil", ",", "nil", ",", "errors", ".", "N...
// Hijack implements the http.Hijacker interface. This expands // the Response to fulfill http.Hijacker if the underlying // http.ResponseWriter supports it.
[ "Hijack", "implements", "the", "http", ".", "Hijacker", "interface", ".", "This", "expands", "the", "Response", "to", "fulfill", "http", ".", "Hijacker", "if", "the", "underlying", "http", ".", "ResponseWriter", "supports", "it", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/response.go#L58-L63
24,773
emicklei/go-restful
response.go
WriteError
func (r *Response) WriteError(httpStatus int, err error) error { r.err = err return r.WriteErrorString(httpStatus, err.Error()) }
go
func (r *Response) WriteError(httpStatus int, err error) error { r.err = err return r.WriteErrorString(httpStatus, err.Error()) }
[ "func", "(", "r", "*", "Response", ")", "WriteError", "(", "httpStatus", "int", ",", "err", "error", ")", "error", "{", "r", ".", "err", "=", "err", "\n", "return", "r", ".", "WriteErrorString", "(", "httpStatus", ",", "err", ".", "Error", "(", ")", ...
// WriteError write the http status and the error string on the response.
[ "WriteError", "write", "the", "http", "status", "and", "the", "error", "string", "on", "the", "response", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/response.go#L178-L181
24,774
emicklei/go-restful
response.go
WriteServiceError
func (r *Response) WriteServiceError(httpStatus int, err ServiceError) error { r.err = err return r.WriteHeaderAndEntity(httpStatus, err) }
go
func (r *Response) WriteServiceError(httpStatus int, err ServiceError) error { r.err = err return r.WriteHeaderAndEntity(httpStatus, err) }
[ "func", "(", "r", "*", "Response", ")", "WriteServiceError", "(", "httpStatus", "int", ",", "err", "ServiceError", ")", "error", "{", "r", ".", "err", "=", "err", "\n", "return", "r", ".", "WriteHeaderAndEntity", "(", "httpStatus", ",", "err", ")", "\n",...
// WriteServiceError is a convenience method for a responding with a status and a ServiceError
[ "WriteServiceError", "is", "a", "convenience", "method", "for", "a", "responding", "with", "a", "status", "and", "a", "ServiceError" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/response.go#L184-L187
24,775
emicklei/go-restful
response.go
WriteErrorString
func (r *Response) WriteErrorString(httpStatus int, errorReason string) error { if r.err == nil { // if not called from WriteError r.err = errors.New(errorReason) } r.WriteHeader(httpStatus) if _, err := r.Write([]byte(errorReason)); err != nil { return err } return nil }
go
func (r *Response) WriteErrorString(httpStatus int, errorReason string) error { if r.err == nil { // if not called from WriteError r.err = errors.New(errorReason) } r.WriteHeader(httpStatus) if _, err := r.Write([]byte(errorReason)); err != nil { return err } return nil }
[ "func", "(", "r", "*", "Response", ")", "WriteErrorString", "(", "httpStatus", "int", ",", "errorReason", "string", ")", "error", "{", "if", "r", ".", "err", "==", "nil", "{", "// if not called from WriteError", "r", ".", "err", "=", "errors", ".", "New", ...
// WriteErrorString is a convenience method for an error status with the actual error
[ "WriteErrorString", "is", "a", "convenience", "method", "for", "an", "error", "status", "with", "the", "actual", "error" ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/response.go#L190-L200
24,776
emicklei/go-restful
response.go
Flush
func (r *Response) Flush() { if f, ok := r.ResponseWriter.(http.Flusher); ok { f.Flush() } else if trace { traceLogger.Printf("ResponseWriter %v doesn't support Flush", r) } }
go
func (r *Response) Flush() { if f, ok := r.ResponseWriter.(http.Flusher); ok { f.Flush() } else if trace { traceLogger.Printf("ResponseWriter %v doesn't support Flush", r) } }
[ "func", "(", "r", "*", "Response", ")", "Flush", "(", ")", "{", "if", "f", ",", "ok", ":=", "r", ".", "ResponseWriter", ".", "(", "http", ".", "Flusher", ")", ";", "ok", "{", "f", ".", "Flush", "(", ")", "\n", "}", "else", "if", "trace", "{",...
// Flush implements http.Flusher interface, which sends any buffered data to the client.
[ "Flush", "implements", "http", ".", "Flusher", "interface", "which", "sends", "any", "buffered", "data", "to", "the", "client", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/response.go#L203-L209
24,777
emicklei/go-restful
response.go
WriteHeader
func (r *Response) WriteHeader(httpStatus int) { r.statusCode = httpStatus r.ResponseWriter.WriteHeader(httpStatus) }
go
func (r *Response) WriteHeader(httpStatus int) { r.statusCode = httpStatus r.ResponseWriter.WriteHeader(httpStatus) }
[ "func", "(", "r", "*", "Response", ")", "WriteHeader", "(", "httpStatus", "int", ")", "{", "r", ".", "statusCode", "=", "httpStatus", "\n", "r", ".", "ResponseWriter", ".", "WriteHeader", "(", "httpStatus", ")", "\n", "}" ]
// WriteHeader is overridden to remember the Status Code that has been written. // Changes to the Header of the response have no effect after this.
[ "WriteHeader", "is", "overridden", "to", "remember", "the", "Status", "Code", "that", "has", "been", "written", ".", "Changes", "to", "the", "Header", "of", "the", "response", "have", "no", "effect", "after", "this", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/response.go#L213-L216
24,778
emicklei/go-restful
response.go
StatusCode
func (r Response) StatusCode() int { if 0 == r.statusCode { // no status code has been written yet; assume OK return http.StatusOK } return r.statusCode }
go
func (r Response) StatusCode() int { if 0 == r.statusCode { // no status code has been written yet; assume OK return http.StatusOK } return r.statusCode }
[ "func", "(", "r", "Response", ")", "StatusCode", "(", ")", "int", "{", "if", "0", "==", "r", ".", "statusCode", "{", "// no status code has been written yet; assume OK", "return", "http", ".", "StatusOK", "\n", "}", "\n", "return", "r", ".", "statusCode", "\...
// StatusCode returns the code that has been written using WriteHeader.
[ "StatusCode", "returns", "the", "code", "that", "has", "been", "written", "using", "WriteHeader", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/response.go#L219-L225
24,779
emicklei/go-restful
response.go
Write
func (r *Response) Write(bytes []byte) (int, error) { written, err := r.ResponseWriter.Write(bytes) r.contentLength += written return written, err }
go
func (r *Response) Write(bytes []byte) (int, error) { written, err := r.ResponseWriter.Write(bytes) r.contentLength += written return written, err }
[ "func", "(", "r", "*", "Response", ")", "Write", "(", "bytes", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "written", ",", "err", ":=", "r", ".", "ResponseWriter", ".", "Write", "(", "bytes", ")", "\n", "r", ".", "contentLength", "...
// Write writes the data to the connection as part of an HTTP reply. // Write is part of http.ResponseWriter interface.
[ "Write", "writes", "the", "data", "to", "the", "connection", "as", "part", "of", "an", "HTTP", "reply", ".", "Write", "is", "part", "of", "http", ".", "ResponseWriter", "interface", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/response.go#L229-L233
24,780
emicklei/go-restful
mime.go
insertMime
func insertMime(l []mime, e mime) []mime { for i, each := range l { // if current mime has lower quality then insert before if e.quality > each.quality { left := append([]mime{}, l[0:i]...) return append(append(left, e), l[i:]...) } } return append(l, e) }
go
func insertMime(l []mime, e mime) []mime { for i, each := range l { // if current mime has lower quality then insert before if e.quality > each.quality { left := append([]mime{}, l[0:i]...) return append(append(left, e), l[i:]...) } } return append(l, e) }
[ "func", "insertMime", "(", "l", "[", "]", "mime", ",", "e", "mime", ")", "[", "]", "mime", "{", "for", "i", ",", "each", ":=", "range", "l", "{", "// if current mime has lower quality then insert before", "if", "e", ".", "quality", ">", "each", ".", "qua...
// insertMime adds a mime to a list and keeps it sorted by quality.
[ "insertMime", "adds", "a", "mime", "to", "a", "list", "and", "keeps", "it", "sorted", "by", "quality", "." ]
d2b8501d30f1b2c552dafdb21e3434bbafdaa124
https://github.com/emicklei/go-restful/blob/d2b8501d30f1b2c552dafdb21e3434bbafdaa124/mime.go#L14-L23
24,781
davecgh/go-spew
spew/bypass.go
flagField
func flagField(v *reflect.Value) *flag { return (*flag)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + flagValOffset)) }
go
func flagField(v *reflect.Value) *flag { return (*flag)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + flagValOffset)) }
[ "func", "flagField", "(", "v", "*", "reflect", ".", "Value", ")", "*", "flag", "{", "return", "(", "*", "flag", ")", "(", "unsafe", ".", "Pointer", "(", "uintptr", "(", "unsafe", ".", "Pointer", "(", "v", ")", ")", "+", "flagValOffset", ")", ")", ...
// flagField returns a pointer to the flag field of a reflect.Value.
[ "flagField", "returns", "a", "pointer", "to", "the", "flag", "field", "of", "a", "reflect", ".", "Value", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/bypass.go#L80-L82
24,782
davecgh/go-spew
spew/bypass.go
init
func init() { field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") if !ok { panic("reflect.Value has no flag field") } if field.Type.Kind() != reflect.TypeOf(flag(0)).Kind() { panic("reflect.Value flag field has changed kind") } type t0 int var t struct { A t0 // t0 will have flagEmbedRO set....
go
func init() { field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") if !ok { panic("reflect.Value has no flag field") } if field.Type.Kind() != reflect.TypeOf(flag(0)).Kind() { panic("reflect.Value flag field has changed kind") } type t0 int var t struct { A t0 // t0 will have flagEmbedRO set....
[ "func", "init", "(", ")", "{", "field", ",", "ok", ":=", "reflect", ".", "TypeOf", "(", "reflect", ".", "Value", "{", "}", ")", ".", "FieldByName", "(", "\"", "\"", ")", "\n", "if", "!", "ok", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\...
// Sanity checks against future reflect package changes // to the type or semantics of the Value.flag field.
[ "Sanity", "checks", "against", "future", "reflect", "package", "changes", "to", "the", "type", "or", "semantics", "of", "the", "Value", ".", "flag", "field", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/bypass.go#L105-L145
24,783
davecgh/go-spew
spew/format.go
buildDefaultFormat
func (f *formatState) buildDefaultFormat() (format string) { buf := bytes.NewBuffer(percentBytes) for _, flag := range supportedFlags { if f.fs.Flag(int(flag)) { buf.WriteRune(flag) } } buf.WriteRune('v') format = buf.String() return format }
go
func (f *formatState) buildDefaultFormat() (format string) { buf := bytes.NewBuffer(percentBytes) for _, flag := range supportedFlags { if f.fs.Flag(int(flag)) { buf.WriteRune(flag) } } buf.WriteRune('v') format = buf.String() return format }
[ "func", "(", "f", "*", "formatState", ")", "buildDefaultFormat", "(", ")", "(", "format", "string", ")", "{", "buf", ":=", "bytes", ".", "NewBuffer", "(", "percentBytes", ")", "\n\n", "for", "_", ",", "flag", ":=", "range", "supportedFlags", "{", "if", ...
// buildDefaultFormat recreates the original format string without precision // and width information to pass in to fmt.Sprintf in the case of an // unrecognized type. Unless new types are added to the language, this // function won't ever be called.
[ "buildDefaultFormat", "recreates", "the", "original", "format", "string", "without", "precision", "and", "width", "information", "to", "pass", "in", "to", "fmt", ".", "Sprintf", "in", "the", "case", "of", "an", "unrecognized", "type", ".", "Unless", "new", "ty...
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/format.go#L47-L60
24,784
davecgh/go-spew
spew/format.go
constructOrigFormat
func (f *formatState) constructOrigFormat(verb rune) (format string) { buf := bytes.NewBuffer(percentBytes) for _, flag := range supportedFlags { if f.fs.Flag(int(flag)) { buf.WriteRune(flag) } } if width, ok := f.fs.Width(); ok { buf.WriteString(strconv.Itoa(width)) } if precision, ok := f.fs.Precisi...
go
func (f *formatState) constructOrigFormat(verb rune) (format string) { buf := bytes.NewBuffer(percentBytes) for _, flag := range supportedFlags { if f.fs.Flag(int(flag)) { buf.WriteRune(flag) } } if width, ok := f.fs.Width(); ok { buf.WriteString(strconv.Itoa(width)) } if precision, ok := f.fs.Precisi...
[ "func", "(", "f", "*", "formatState", ")", "constructOrigFormat", "(", "verb", "rune", ")", "(", "format", "string", ")", "{", "buf", ":=", "bytes", ".", "NewBuffer", "(", "percentBytes", ")", "\n\n", "for", "_", ",", "flag", ":=", "range", "supportedFla...
// constructOrigFormat recreates the original format string including precision // and width information to pass along to the standard fmt package. This allows // automatic deferral of all format strings this package doesn't support.
[ "constructOrigFormat", "recreates", "the", "original", "format", "string", "including", "precision", "and", "width", "information", "to", "pass", "along", "to", "the", "standard", "fmt", "package", ".", "This", "allows", "automatic", "deferral", "of", "all", "form...
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/format.go#L65-L87
24,785
davecgh/go-spew
spew/format.go
unpackValue
func (f *formatState) unpackValue(v reflect.Value) reflect.Value { if v.Kind() == reflect.Interface { f.ignoreNextType = false if !v.IsNil() { v = v.Elem() } } return v }
go
func (f *formatState) unpackValue(v reflect.Value) reflect.Value { if v.Kind() == reflect.Interface { f.ignoreNextType = false if !v.IsNil() { v = v.Elem() } } return v }
[ "func", "(", "f", "*", "formatState", ")", "unpackValue", "(", "v", "reflect", ".", "Value", ")", "reflect", ".", "Value", "{", "if", "v", ".", "Kind", "(", ")", "==", "reflect", ".", "Interface", "{", "f", ".", "ignoreNextType", "=", "false", "\n", ...
// unpackValue returns values inside of non-nil interfaces when possible and // ensures that types for values which have been unpacked from an interface // are displayed when the show types flag is also set. // This is useful for data types like structs, arrays, slices, and maps which // can contain varying types packe...
[ "unpackValue", "returns", "values", "inside", "of", "non", "-", "nil", "interfaces", "when", "possible", "and", "ensures", "that", "types", "for", "values", "which", "have", "been", "unpacked", "from", "an", "interface", "are", "displayed", "when", "the", "sho...
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/format.go#L94-L102
24,786
davecgh/go-spew
spew/format.go
formatPtr
func (f *formatState) formatPtr(v reflect.Value) { // Display nil if top level pointer is nil. showTypes := f.fs.Flag('#') if v.IsNil() && (!showTypes || f.ignoreNextType) { f.fs.Write(nilAngleBytes) return } // Remove pointers at or below the current depth from map used to detect // circular refs. for k, d...
go
func (f *formatState) formatPtr(v reflect.Value) { // Display nil if top level pointer is nil. showTypes := f.fs.Flag('#') if v.IsNil() && (!showTypes || f.ignoreNextType) { f.fs.Write(nilAngleBytes) return } // Remove pointers at or below the current depth from map used to detect // circular refs. for k, d...
[ "func", "(", "f", "*", "formatState", ")", "formatPtr", "(", "v", "reflect", ".", "Value", ")", "{", "// Display nil if top level pointer is nil.", "showTypes", ":=", "f", ".", "fs", ".", "Flag", "(", "'#'", ")", "\n", "if", "v", ".", "IsNil", "(", ")", ...
// formatPtr handles formatting of pointers by indirecting them as necessary.
[ "formatPtr", "handles", "formatting", "of", "pointers", "by", "indirecting", "them", "as", "necessary", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/format.go#L105-L195
24,787
davecgh/go-spew
spew/format.go
Format
func (f *formatState) Format(fs fmt.State, verb rune) { f.fs = fs // Use standard formatting for verbs that are not v. if verb != 'v' { format := f.constructOrigFormat(verb) fmt.Fprintf(fs, format, f.value) return } if f.value == nil { if fs.Flag('#') { fs.Write(interfaceBytes) } fs.Write(nilAngle...
go
func (f *formatState) Format(fs fmt.State, verb rune) { f.fs = fs // Use standard formatting for verbs that are not v. if verb != 'v' { format := f.constructOrigFormat(verb) fmt.Fprintf(fs, format, f.value) return } if f.value == nil { if fs.Flag('#') { fs.Write(interfaceBytes) } fs.Write(nilAngle...
[ "func", "(", "f", "*", "formatState", ")", "Format", "(", "fs", "fmt", ".", "State", ",", "verb", "rune", ")", "{", "f", ".", "fs", "=", "fs", "\n\n", "// Use standard formatting for verbs that are not v.", "if", "verb", "!=", "'v'", "{", "format", ":=", ...
// Format satisfies the fmt.Formatter interface. See NewFormatter for usage // details.
[ "Format", "satisfies", "the", "fmt", ".", "Formatter", "interface", ".", "See", "NewFormatter", "for", "usage", "details", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/format.go#L371-L390
24,788
davecgh/go-spew
spew/format.go
newFormatter
func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter { fs := &formatState{value: v, cs: cs} fs.pointers = make(map[uintptr]int) return fs }
go
func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter { fs := &formatState{value: v, cs: cs} fs.pointers = make(map[uintptr]int) return fs }
[ "func", "newFormatter", "(", "cs", "*", "ConfigState", ",", "v", "interface", "{", "}", ")", "fmt", ".", "Formatter", "{", "fs", ":=", "&", "formatState", "{", "value", ":", "v", ",", "cs", ":", "cs", "}", "\n", "fs", ".", "pointers", "=", "make", ...
// newFormatter is a helper function to consolidate the logic from the various // public methods which take varying config states.
[ "newFormatter", "is", "a", "helper", "function", "to", "consolidate", "the", "logic", "from", "the", "various", "public", "methods", "which", "take", "varying", "config", "states", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/format.go#L394-L398
24,789
davecgh/go-spew
spew/dump.go
indent
func (d *dumpState) indent() { if d.ignoreNextIndent { d.ignoreNextIndent = false return } d.w.Write(bytes.Repeat([]byte(d.cs.Indent), d.depth)) }
go
func (d *dumpState) indent() { if d.ignoreNextIndent { d.ignoreNextIndent = false return } d.w.Write(bytes.Repeat([]byte(d.cs.Indent), d.depth)) }
[ "func", "(", "d", "*", "dumpState", ")", "indent", "(", ")", "{", "if", "d", ".", "ignoreNextIndent", "{", "d", ".", "ignoreNextIndent", "=", "false", "\n", "return", "\n", "}", "\n", "d", ".", "w", ".", "Write", "(", "bytes", ".", "Repeat", "(", ...
// indent performs indentation according to the depth level and cs.Indent // option.
[ "indent", "performs", "indentation", "according", "to", "the", "depth", "level", "and", "cs", ".", "Indent", "option", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/dump.go#L62-L68
24,790
davecgh/go-spew
spew/dump.go
unpackValue
func (d *dumpState) unpackValue(v reflect.Value) reflect.Value { if v.Kind() == reflect.Interface && !v.IsNil() { v = v.Elem() } return v }
go
func (d *dumpState) unpackValue(v reflect.Value) reflect.Value { if v.Kind() == reflect.Interface && !v.IsNil() { v = v.Elem() } return v }
[ "func", "(", "d", "*", "dumpState", ")", "unpackValue", "(", "v", "reflect", ".", "Value", ")", "reflect", ".", "Value", "{", "if", "v", ".", "Kind", "(", ")", "==", "reflect", ".", "Interface", "&&", "!", "v", ".", "IsNil", "(", ")", "{", "v", ...
// unpackValue returns values inside of non-nil interfaces when possible. // This is useful for data types like structs, arrays, slices, and maps which // can contain varying types packed inside an interface.
[ "unpackValue", "returns", "values", "inside", "of", "non", "-", "nil", "interfaces", "when", "possible", ".", "This", "is", "useful", "for", "data", "types", "like", "structs", "arrays", "slices", "and", "maps", "which", "can", "contain", "varying", "types", ...
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/dump.go#L73-L78
24,791
davecgh/go-spew
spew/dump.go
dumpPtr
func (d *dumpState) dumpPtr(v reflect.Value) { // Remove pointers at or below the current depth from map used to detect // circular refs. for k, depth := range d.pointers { if depth >= d.depth { delete(d.pointers, k) } } // Keep list of all dereferenced pointers to show later. pointerChain := make([]uintp...
go
func (d *dumpState) dumpPtr(v reflect.Value) { // Remove pointers at or below the current depth from map used to detect // circular refs. for k, depth := range d.pointers { if depth >= d.depth { delete(d.pointers, k) } } // Keep list of all dereferenced pointers to show later. pointerChain := make([]uintp...
[ "func", "(", "d", "*", "dumpState", ")", "dumpPtr", "(", "v", "reflect", ".", "Value", ")", "{", "// Remove pointers at or below the current depth from map used to detect", "// circular refs.", "for", "k", ",", "depth", ":=", "range", "d", ".", "pointers", "{", "i...
// dumpPtr handles formatting of pointers by indirecting them as necessary.
[ "dumpPtr", "handles", "formatting", "of", "pointers", "by", "indirecting", "them", "as", "necessary", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/dump.go#L81-L157
24,792
davecgh/go-spew
spew/dump.go
fdump
func fdump(cs *ConfigState, w io.Writer, a ...interface{}) { for _, arg := range a { if arg == nil { w.Write(interfaceBytes) w.Write(spaceBytes) w.Write(nilAngleBytes) w.Write(newlineBytes) continue } d := dumpState{w: w, cs: cs} d.pointers = make(map[uintptr]int) d.dump(reflect.ValueOf(arg))...
go
func fdump(cs *ConfigState, w io.Writer, a ...interface{}) { for _, arg := range a { if arg == nil { w.Write(interfaceBytes) w.Write(spaceBytes) w.Write(nilAngleBytes) w.Write(newlineBytes) continue } d := dumpState{w: w, cs: cs} d.pointers = make(map[uintptr]int) d.dump(reflect.ValueOf(arg))...
[ "func", "fdump", "(", "cs", "*", "ConfigState", ",", "w", "io", ".", "Writer", ",", "a", "...", "interface", "{", "}", ")", "{", "for", "_", ",", "arg", ":=", "range", "a", "{", "if", "arg", "==", "nil", "{", "w", ".", "Write", "(", "interfaceB...
// fdump is a helper function to consolidate the logic from the various public // methods which take varying writers and config states.
[ "fdump", "is", "a", "helper", "function", "to", "consolidate", "the", "logic", "from", "the", "various", "public", "methods", "which", "take", "varying", "writers", "and", "config", "states", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/dump.go#L453-L468
24,793
davecgh/go-spew
spew/dump.go
Sdump
func Sdump(a ...interface{}) string { var buf bytes.Buffer fdump(&Config, &buf, a...) return buf.String() }
go
func Sdump(a ...interface{}) string { var buf bytes.Buffer fdump(&Config, &buf, a...) return buf.String() }
[ "func", "Sdump", "(", "a", "...", "interface", "{", "}", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "fdump", "(", "&", "Config", ",", "&", "buf", ",", "a", "...", ")", "\n", "return", "buf", ".", "String", "(", ")", "\n", "...
// Sdump returns a string with the passed arguments formatted exactly the same // as Dump.
[ "Sdump", "returns", "a", "string", "with", "the", "passed", "arguments", "formatted", "exactly", "the", "same", "as", "Dump", "." ]
d8f796af33cc11cb798c1aaeb27a4ebc5099927d
https://github.com/davecgh/go-spew/blob/d8f796af33cc11cb798c1aaeb27a4ebc5099927d/spew/dump.go#L478-L482
24,794
jackc/pgx
pgtype/uuid.go
parseUUID
func parseUUID(src string) (dst [16]byte, err error) { if len(src) < 36 { return dst, errors.Errorf("cannot parse UUID %v", src) } src = src[0:8] + src[9:13] + src[14:18] + src[19:23] + src[24:] buf, err := hex.DecodeString(src) if err != nil { return dst, err } copy(dst[:], buf) return dst, err }
go
func parseUUID(src string) (dst [16]byte, err error) { if len(src) < 36 { return dst, errors.Errorf("cannot parse UUID %v", src) } src = src[0:8] + src[9:13] + src[14:18] + src[19:23] + src[24:] buf, err := hex.DecodeString(src) if err != nil { return dst, err } copy(dst[:], buf) return dst, err }
[ "func", "parseUUID", "(", "src", "string", ")", "(", "dst", "[", "16", "]", "byte", ",", "err", "error", ")", "{", "if", "len", "(", "src", ")", "<", "36", "{", "return", "dst", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "src", ")", ...
// parseUUID converts a string UUID in standard form to a byte array.
[ "parseUUID", "converts", "a", "string", "UUID", "in", "standard", "form", "to", "a", "byte", "array", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/uuid.go#L89-L101
24,795
jackc/pgx
pgtype/uuid.go
encodeUUID
func encodeUUID(src [16]byte) string { return fmt.Sprintf("%x-%x-%x-%x-%x", src[0:4], src[4:6], src[6:8], src[8:10], src[10:16]) }
go
func encodeUUID(src [16]byte) string { return fmt.Sprintf("%x-%x-%x-%x-%x", src[0:4], src[4:6], src[6:8], src[8:10], src[10:16]) }
[ "func", "encodeUUID", "(", "src", "[", "16", "]", "byte", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "src", "[", "0", ":", "4", "]", ",", "src", "[", "4", ":", "6", "]", ",", "src", "[", "6", ":", "8", "]", ...
// encodeUUID converts a uuid byte array to UUID standard string form.
[ "encodeUUID", "converts", "a", "uuid", "byte", "array", "to", "UUID", "standard", "string", "form", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/uuid.go#L104-L106
24,796
jackc/pgx
pgtype/pgtype.go
DeepCopy
func (ci *ConnInfo) DeepCopy() *ConnInfo { ci2 := &ConnInfo{ oidToDataType: make(map[OID]*DataType, len(ci.oidToDataType)), nameToDataType: make(map[string]*DataType, len(ci.nameToDataType)), reflectTypeToDataType: make(map[reflect.Type]*DataType, len(ci.reflectTypeToDataType)), } for _, dt := ...
go
func (ci *ConnInfo) DeepCopy() *ConnInfo { ci2 := &ConnInfo{ oidToDataType: make(map[OID]*DataType, len(ci.oidToDataType)), nameToDataType: make(map[string]*DataType, len(ci.nameToDataType)), reflectTypeToDataType: make(map[reflect.Type]*DataType, len(ci.reflectTypeToDataType)), } for _, dt := ...
[ "func", "(", "ci", "*", "ConnInfo", ")", "DeepCopy", "(", ")", "*", "ConnInfo", "{", "ci2", ":=", "&", "ConnInfo", "{", "oidToDataType", ":", "make", "(", "map", "[", "OID", "]", "*", "DataType", ",", "len", "(", "ci", ".", "oidToDataType", ")", ")...
// DeepCopy makes a deep copy of the ConnInfo.
[ "DeepCopy", "makes", "a", "deep", "copy", "of", "the", "ConnInfo", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/pgtype.go#L192-L208
24,797
jackc/pgx
pgtype/timestamp.go
Set
func (dst *Timestamp) Set(src interface{}) error { if src == nil { *dst = Timestamp{Status: Null} return nil } switch value := src.(type) { case time.Time: *dst = Timestamp{Time: time.Date(value.Year(), value.Month(), value.Day(), value.Hour(), value.Minute(), value.Second(), value.Nanosecond(), time.UTC), S...
go
func (dst *Timestamp) Set(src interface{}) error { if src == nil { *dst = Timestamp{Status: Null} return nil } switch value := src.(type) { case time.Time: *dst = Timestamp{Time: time.Date(value.Year(), value.Month(), value.Day(), value.Hour(), value.Minute(), value.Second(), value.Nanosecond(), time.UTC), S...
[ "func", "(", "dst", "*", "Timestamp", ")", "Set", "(", "src", "interface", "{", "}", ")", "error", "{", "if", "src", "==", "nil", "{", "*", "dst", "=", "Timestamp", "{", "Status", ":", "Null", "}", "\n", "return", "nil", "\n", "}", "\n\n", "switc...
// Set converts src into a Timestamp and stores in dst. If src is a // time.Time in a non-UTC time zone, the time zone is discarded.
[ "Set", "converts", "src", "into", "a", "Timestamp", "and", "stores", "in", "dst", ".", "If", "src", "is", "a", "time", ".", "Time", "in", "a", "non", "-", "UTC", "time", "zone", "the", "time", "zone", "is", "discarded", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/timestamp.go#L27-L44
24,798
jackc/pgx
pgtype/timestamp.go
DecodeText
func (dst *Timestamp) DecodeText(ci *ConnInfo, src []byte) error { if src == nil { *dst = Timestamp{Status: Null} return nil } sbuf := string(src) switch sbuf { case "infinity": *dst = Timestamp{Status: Present, InfinityModifier: Infinity} case "-infinity": *dst = Timestamp{Status: Present, InfinityModif...
go
func (dst *Timestamp) DecodeText(ci *ConnInfo, src []byte) error { if src == nil { *dst = Timestamp{Status: Null} return nil } sbuf := string(src) switch sbuf { case "infinity": *dst = Timestamp{Status: Present, InfinityModifier: Infinity} case "-infinity": *dst = Timestamp{Status: Present, InfinityModif...
[ "func", "(", "dst", "*", "Timestamp", ")", "DecodeText", "(", "ci", "*", "ConnInfo", ",", "src", "[", "]", "byte", ")", "error", "{", "if", "src", "==", "nil", "{", "*", "dst", "=", "Timestamp", "{", "Status", ":", "Null", "}", "\n", "return", "n...
// DecodeText decodes from src into dst. The decoded time is considered to // be in UTC.
[ "DecodeText", "decodes", "from", "src", "into", "dst", ".", "The", "decoded", "time", "is", "considered", "to", "be", "in", "UTC", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/timestamp.go#L84-L106
24,799
jackc/pgx
pgtype/timestamp.go
EncodeText
func (src *Timestamp) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) { switch src.Status { case Null: return nil, nil case Undefined: return nil, errUndefined } if src.Time.Location() != time.UTC { return nil, errors.Errorf("cannot encode non-UTC time into timestamp") } var s string switch src.Inf...
go
func (src *Timestamp) EncodeText(ci *ConnInfo, buf []byte) ([]byte, error) { switch src.Status { case Null: return nil, nil case Undefined: return nil, errUndefined } if src.Time.Location() != time.UTC { return nil, errors.Errorf("cannot encode non-UTC time into timestamp") } var s string switch src.Inf...
[ "func", "(", "src", "*", "Timestamp", ")", "EncodeText", "(", "ci", "*", "ConnInfo", ",", "buf", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "switch", "src", ".", "Status", "{", "case", "Null", ":", "return", "nil", ",",...
// EncodeText writes the text encoding of src into w. If src.Time is not in // the UTC time zone it returns an error.
[ "EncodeText", "writes", "the", "text", "encoding", "of", "src", "into", "w", ".", "If", "src", ".", "Time", "is", "not", "in", "the", "UTC", "time", "zone", "it", "returns", "an", "error", "." ]
25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc
https://github.com/jackc/pgx/blob/25c2375fd84652ac32aa0ecc9a6b872a4ab25cdc/pgtype/timestamp.go#L138-L161