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
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
148,000 | coocood/freecache | cache.go | Get | func (cache *Cache) Get(key []byte) (value []byte, err error) {
hashVal := hashFunc(key)
segID := hashVal & segmentAndOpVal
cache.locks[segID].Lock()
value, _, err = cache.segments[segID].get(key, nil, hashVal)
cache.locks[segID].Unlock()
return
} | go | func (cache *Cache) Get(key []byte) (value []byte, err error) {
hashVal := hashFunc(key)
segID := hashVal & segmentAndOpVal
cache.locks[segID].Lock()
value, _, err = cache.segments[segID].get(key, nil, hashVal)
cache.locks[segID].Unlock()
return
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"Get",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"value",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"hashVal",
":=",
"hashFunc",
"(",
"key",
")",
"\n",
"segID",
":=",
"hashVal",
"&",
"segmentAndOpVal",
"\n",
"cache",
".",
"locks",
"[",
"segID",
"]",
".",
"Lock",
"(",
")",
"\n",
"value",
",",
"_",
",",
"err",
"=",
"cache",
".",
"segments",
"[",
"segID",
"]",
".",
"get",
"(",
"key",
",",
"nil",
",",
"hashVal",
")",
"\n",
"cache",
".",
"locks",
"[",
"segID",
"]",
".",
"Unlock",
"(",
")",
"\n",
"return",
"\n",
"}"
] | // Get returns the value or not found error. | [
"Get",
"returns",
"the",
"value",
"or",
"not",
"found",
"error",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L59-L66 |
148,001 | coocood/freecache | cache.go | GetWithExpiration | func (cache *Cache) GetWithExpiration(key []byte) (value []byte, expireAt uint32, err error) {
hashVal := hashFunc(key)
segID := hashVal & segmentAndOpVal
cache.locks[segID].Lock()
value, expireAt, err = cache.segments[segID].get(key, nil, hashVal)
cache.locks[segID].Unlock()
return
} | go | func (cache *Cache) GetWithExpiration(key []byte) (value []byte, expireAt uint32, err error) {
hashVal := hashFunc(key)
segID := hashVal & segmentAndOpVal
cache.locks[segID].Lock()
value, expireAt, err = cache.segments[segID].get(key, nil, hashVal)
cache.locks[segID].Unlock()
return
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"GetWithExpiration",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"value",
"[",
"]",
"byte",
",",
"expireAt",
"uint32",
",",
"err",
"error",
")",
"{",
"hashVal",
":=",
"hashFunc",
"(",
"key",
")",
"\n",
"segID",
":=",
"hashVal",
"&",
"segmentAndOpVal",
"\n",
"cache",
".",
"locks",
"[",
"segID",
"]",
".",
"Lock",
"(",
")",
"\n",
"value",
",",
"expireAt",
",",
"err",
"=",
"cache",
".",
"segments",
"[",
"segID",
"]",
".",
"get",
"(",
"key",
",",
"nil",
",",
"hashVal",
")",
"\n",
"cache",
".",
"locks",
"[",
"segID",
"]",
".",
"Unlock",
"(",
")",
"\n",
"return",
"\n",
"}"
] | // GetWithExpiration returns the value with expiration or not found error. | [
"GetWithExpiration",
"returns",
"the",
"value",
"with",
"expiration",
"or",
"not",
"found",
"error",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L80-L87 |
148,002 | coocood/freecache | cache.go | TTL | func (cache *Cache) TTL(key []byte) (timeLeft uint32, err error) {
hashVal := hashFunc(key)
segID := hashVal & segmentAndOpVal
cache.locks[segID].Lock()
timeLeft, err = cache.segments[segID].ttl(key, hashVal)
cache.locks[segID].Unlock()
return
} | go | func (cache *Cache) TTL(key []byte) (timeLeft uint32, err error) {
hashVal := hashFunc(key)
segID := hashVal & segmentAndOpVal
cache.locks[segID].Lock()
timeLeft, err = cache.segments[segID].ttl(key, hashVal)
cache.locks[segID].Unlock()
return
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"TTL",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"timeLeft",
"uint32",
",",
"err",
"error",
")",
"{",
"hashVal",
":=",
"hashFunc",
"(",
"key",
")",
"\n",
"segID",
":=",
"hashVal",
"&",
"segmentAndOpVal",
"\n",
"cache",
".",
"locks",
"[",
"segID",
"]",
".",
"Lock",
"(",
")",
"\n",
"timeLeft",
",",
"err",
"=",
"cache",
".",
"segments",
"[",
"segID",
"]",
".",
"ttl",
"(",
"key",
",",
"hashVal",
")",
"\n",
"cache",
".",
"locks",
"[",
"segID",
"]",
".",
"Unlock",
"(",
")",
"\n",
"return",
"\n",
"}"
] | // TTL returns the TTL time left for a given key or a not found error. | [
"TTL",
"returns",
"the",
"TTL",
"time",
"left",
"for",
"a",
"given",
"key",
"or",
"a",
"not",
"found",
"error",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L90-L97 |
148,003 | coocood/freecache | cache.go | Del | func (cache *Cache) Del(key []byte) (affected bool) {
hashVal := hashFunc(key)
segID := hashVal & segmentAndOpVal
cache.locks[segID].Lock()
affected = cache.segments[segID].del(key, hashVal)
cache.locks[segID].Unlock()
return
} | go | func (cache *Cache) Del(key []byte) (affected bool) {
hashVal := hashFunc(key)
segID := hashVal & segmentAndOpVal
cache.locks[segID].Lock()
affected = cache.segments[segID].del(key, hashVal)
cache.locks[segID].Unlock()
return
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"Del",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"affected",
"bool",
")",
"{",
"hashVal",
":=",
"hashFunc",
"(",
"key",
")",
"\n",
"segID",
":=",
"hashVal",
"&",
"segmentAndOpVal",
"\n",
"cache",
".",
"locks",
"[",
"segID",
"]",
".",
"Lock",
"(",
")",
"\n",
"affected",
"=",
"cache",
".",
"segments",
"[",
"segID",
"]",
".",
"del",
"(",
"key",
",",
"hashVal",
")",
"\n",
"cache",
".",
"locks",
"[",
"segID",
"]",
".",
"Unlock",
"(",
")",
"\n",
"return",
"\n",
"}"
] | // Del deletes an item in the cache by key and returns true or false if a delete occurred. | [
"Del",
"deletes",
"an",
"item",
"in",
"the",
"cache",
"by",
"key",
"and",
"returns",
"true",
"or",
"false",
"if",
"a",
"delete",
"occurred",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L100-L107 |
148,004 | coocood/freecache | cache.go | SetInt | func (cache *Cache) SetInt(key int64, value []byte, expireSeconds int) (err error) {
var bKey [8]byte
binary.LittleEndian.PutUint64(bKey[:], uint64(key))
return cache.Set(bKey[:], value, expireSeconds)
} | go | func (cache *Cache) SetInt(key int64, value []byte, expireSeconds int) (err error) {
var bKey [8]byte
binary.LittleEndian.PutUint64(bKey[:], uint64(key))
return cache.Set(bKey[:], value, expireSeconds)
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"SetInt",
"(",
"key",
"int64",
",",
"value",
"[",
"]",
"byte",
",",
"expireSeconds",
"int",
")",
"(",
"err",
"error",
")",
"{",
"var",
"bKey",
"[",
"8",
"]",
"byte",
"\n",
"binary",
".",
"LittleEndian",
".",
"PutUint64",
"(",
"bKey",
"[",
":",
"]",
",",
"uint64",
"(",
"key",
")",
")",
"\n",
"return",
"cache",
".",
"Set",
"(",
"bKey",
"[",
":",
"]",
",",
"value",
",",
"expireSeconds",
")",
"\n",
"}"
] | // SetInt stores in integer value in the cache. | [
"SetInt",
"stores",
"in",
"integer",
"value",
"in",
"the",
"cache",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L110-L114 |
148,005 | coocood/freecache | cache.go | GetInt | func (cache *Cache) GetInt(key int64) (value []byte, err error) {
var bKey [8]byte
binary.LittleEndian.PutUint64(bKey[:], uint64(key))
return cache.Get(bKey[:])
} | go | func (cache *Cache) GetInt(key int64) (value []byte, err error) {
var bKey [8]byte
binary.LittleEndian.PutUint64(bKey[:], uint64(key))
return cache.Get(bKey[:])
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"GetInt",
"(",
"key",
"int64",
")",
"(",
"value",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"bKey",
"[",
"8",
"]",
"byte",
"\n",
"binary",
".",
"LittleEndian",
".",
"PutUint64",
"(",
"bKey",
"[",
":",
"]",
",",
"uint64",
"(",
"key",
")",
")",
"\n",
"return",
"cache",
".",
"Get",
"(",
"bKey",
"[",
":",
"]",
")",
"\n",
"}"
] | // GetInt returns the value for an integer within the cache or a not found error. | [
"GetInt",
"returns",
"the",
"value",
"for",
"an",
"integer",
"within",
"the",
"cache",
"or",
"a",
"not",
"found",
"error",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L117-L121 |
148,006 | coocood/freecache | cache.go | GetIntWithExpiration | func (cache *Cache) GetIntWithExpiration(key int64) (value []byte, expireAt uint32, err error) {
var bKey [8]byte
binary.LittleEndian.PutUint64(bKey[:], uint64(key))
return cache.GetWithExpiration(bKey[:])
} | go | func (cache *Cache) GetIntWithExpiration(key int64) (value []byte, expireAt uint32, err error) {
var bKey [8]byte
binary.LittleEndian.PutUint64(bKey[:], uint64(key))
return cache.GetWithExpiration(bKey[:])
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"GetIntWithExpiration",
"(",
"key",
"int64",
")",
"(",
"value",
"[",
"]",
"byte",
",",
"expireAt",
"uint32",
",",
"err",
"error",
")",
"{",
"var",
"bKey",
"[",
"8",
"]",
"byte",
"\n",
"binary",
".",
"LittleEndian",
".",
"PutUint64",
"(",
"bKey",
"[",
":",
"]",
",",
"uint64",
"(",
"key",
")",
")",
"\n",
"return",
"cache",
".",
"GetWithExpiration",
"(",
"bKey",
"[",
":",
"]",
")",
"\n",
"}"
] | // GetIntWithExpiration returns the value and expiration or a not found error. | [
"GetIntWithExpiration",
"returns",
"the",
"value",
"and",
"expiration",
"or",
"a",
"not",
"found",
"error",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L124-L128 |
148,007 | coocood/freecache | cache.go | DelInt | func (cache *Cache) DelInt(key int64) (affected bool) {
var bKey [8]byte
binary.LittleEndian.PutUint64(bKey[:], uint64(key))
return cache.Del(bKey[:])
} | go | func (cache *Cache) DelInt(key int64) (affected bool) {
var bKey [8]byte
binary.LittleEndian.PutUint64(bKey[:], uint64(key))
return cache.Del(bKey[:])
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"DelInt",
"(",
"key",
"int64",
")",
"(",
"affected",
"bool",
")",
"{",
"var",
"bKey",
"[",
"8",
"]",
"byte",
"\n",
"binary",
".",
"LittleEndian",
".",
"PutUint64",
"(",
"bKey",
"[",
":",
"]",
",",
"uint64",
"(",
"key",
")",
")",
"\n",
"return",
"cache",
".",
"Del",
"(",
"bKey",
"[",
":",
"]",
")",
"\n",
"}"
] | // DelInt deletes an item in the cache by int key and returns true or false if a delete occurred. | [
"DelInt",
"deletes",
"an",
"item",
"in",
"the",
"cache",
"by",
"int",
"key",
"and",
"returns",
"true",
"or",
"false",
"if",
"a",
"delete",
"occurred",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L131-L135 |
148,008 | coocood/freecache | cache.go | EvacuateCount | func (cache *Cache) EvacuateCount() (count int64) {
for i := range cache.segments {
count += atomic.LoadInt64(&cache.segments[i].totalEvacuate)
}
return
} | go | func (cache *Cache) EvacuateCount() (count int64) {
for i := range cache.segments {
count += atomic.LoadInt64(&cache.segments[i].totalEvacuate)
}
return
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"EvacuateCount",
"(",
")",
"(",
"count",
"int64",
")",
"{",
"for",
"i",
":=",
"range",
"cache",
".",
"segments",
"{",
"count",
"+=",
"atomic",
".",
"LoadInt64",
"(",
"&",
"cache",
".",
"segments",
"[",
"i",
"]",
".",
"totalEvacuate",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // EvacuateCount is a metric indicating the number of times an eviction occurred. | [
"EvacuateCount",
"is",
"a",
"metric",
"indicating",
"the",
"number",
"of",
"times",
"an",
"eviction",
"occurred",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L138-L143 |
148,009 | coocood/freecache | cache.go | ExpiredCount | func (cache *Cache) ExpiredCount() (count int64) {
for i := range cache.segments {
count += atomic.LoadInt64(&cache.segments[i].totalExpired)
}
return
} | go | func (cache *Cache) ExpiredCount() (count int64) {
for i := range cache.segments {
count += atomic.LoadInt64(&cache.segments[i].totalExpired)
}
return
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"ExpiredCount",
"(",
")",
"(",
"count",
"int64",
")",
"{",
"for",
"i",
":=",
"range",
"cache",
".",
"segments",
"{",
"count",
"+=",
"atomic",
".",
"LoadInt64",
"(",
"&",
"cache",
".",
"segments",
"[",
"i",
"]",
".",
"totalExpired",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // ExpiredCount is a metric indicating the number of times an expire occurred. | [
"ExpiredCount",
"is",
"a",
"metric",
"indicating",
"the",
"number",
"of",
"times",
"an",
"expire",
"occurred",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L146-L151 |
148,010 | coocood/freecache | cache.go | EntryCount | func (cache *Cache) EntryCount() (entryCount int64) {
for i := range cache.segments {
entryCount += atomic.LoadInt64(&cache.segments[i].entryCount)
}
return
} | go | func (cache *Cache) EntryCount() (entryCount int64) {
for i := range cache.segments {
entryCount += atomic.LoadInt64(&cache.segments[i].entryCount)
}
return
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"EntryCount",
"(",
")",
"(",
"entryCount",
"int64",
")",
"{",
"for",
"i",
":=",
"range",
"cache",
".",
"segments",
"{",
"entryCount",
"+=",
"atomic",
".",
"LoadInt64",
"(",
"&",
"cache",
".",
"segments",
"[",
"i",
"]",
".",
"entryCount",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // EntryCount returns the number of items currently in the cache. | [
"EntryCount",
"returns",
"the",
"number",
"of",
"items",
"currently",
"in",
"the",
"cache",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L154-L159 |
148,011 | coocood/freecache | cache.go | AverageAccessTime | func (cache *Cache) AverageAccessTime() int64 {
var entryCount, totalTime int64
for i := range cache.segments {
totalTime += atomic.LoadInt64(&cache.segments[i].totalTime)
entryCount += atomic.LoadInt64(&cache.segments[i].totalCount)
}
if entryCount == 0 {
return 0
} else {
return totalTime / entryCount
}
} | go | func (cache *Cache) AverageAccessTime() int64 {
var entryCount, totalTime int64
for i := range cache.segments {
totalTime += atomic.LoadInt64(&cache.segments[i].totalTime)
entryCount += atomic.LoadInt64(&cache.segments[i].totalCount)
}
if entryCount == 0 {
return 0
} else {
return totalTime / entryCount
}
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"AverageAccessTime",
"(",
")",
"int64",
"{",
"var",
"entryCount",
",",
"totalTime",
"int64",
"\n",
"for",
"i",
":=",
"range",
"cache",
".",
"segments",
"{",
"totalTime",
"+=",
"atomic",
".",
"LoadInt64",
"(",
"&",
"cache",
".",
"segments",
"[",
"i",
"]",
".",
"totalTime",
")",
"\n",
"entryCount",
"+=",
"atomic",
".",
"LoadInt64",
"(",
"&",
"cache",
".",
"segments",
"[",
"i",
"]",
".",
"totalCount",
")",
"\n",
"}",
"\n",
"if",
"entryCount",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"else",
"{",
"return",
"totalTime",
"/",
"entryCount",
"\n",
"}",
"\n",
"}"
] | // AverageAccessTime returns the average unix timestamp when a entry being accessed.
// Entries have greater access time will be evacuated when it
// is about to be overwritten by new value. | [
"AverageAccessTime",
"returns",
"the",
"average",
"unix",
"timestamp",
"when",
"a",
"entry",
"being",
"accessed",
".",
"Entries",
"have",
"greater",
"access",
"time",
"will",
"be",
"evacuated",
"when",
"it",
"is",
"about",
"to",
"be",
"overwritten",
"by",
"new",
"value",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L164-L175 |
148,012 | coocood/freecache | cache.go | HitCount | func (cache *Cache) HitCount() (count int64) {
for i := range cache.segments {
count += atomic.LoadInt64(&cache.segments[i].hitCount)
}
return
} | go | func (cache *Cache) HitCount() (count int64) {
for i := range cache.segments {
count += atomic.LoadInt64(&cache.segments[i].hitCount)
}
return
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"HitCount",
"(",
")",
"(",
"count",
"int64",
")",
"{",
"for",
"i",
":=",
"range",
"cache",
".",
"segments",
"{",
"count",
"+=",
"atomic",
".",
"LoadInt64",
"(",
"&",
"cache",
".",
"segments",
"[",
"i",
"]",
".",
"hitCount",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // HitCount is a metric that returns number of times a key was found in the cache. | [
"HitCount",
"is",
"a",
"metric",
"that",
"returns",
"number",
"of",
"times",
"a",
"key",
"was",
"found",
"in",
"the",
"cache",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L178-L183 |
148,013 | coocood/freecache | cache.go | MissCount | func (cache *Cache) MissCount() (count int64) {
for i := range cache.segments {
count += atomic.LoadInt64(&cache.segments[i].missCount)
}
return
} | go | func (cache *Cache) MissCount() (count int64) {
for i := range cache.segments {
count += atomic.LoadInt64(&cache.segments[i].missCount)
}
return
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"MissCount",
"(",
")",
"(",
"count",
"int64",
")",
"{",
"for",
"i",
":=",
"range",
"cache",
".",
"segments",
"{",
"count",
"+=",
"atomic",
".",
"LoadInt64",
"(",
"&",
"cache",
".",
"segments",
"[",
"i",
"]",
".",
"missCount",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // MissCount is a metric that returns the number of times a miss occurred in the cache. | [
"MissCount",
"is",
"a",
"metric",
"that",
"returns",
"the",
"number",
"of",
"times",
"a",
"miss",
"occurred",
"in",
"the",
"cache",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L186-L191 |
148,014 | coocood/freecache | cache.go | HitRate | func (cache *Cache) HitRate() float64 {
hitCount, missCount := cache.HitCount(), cache.MissCount()
lookupCount := hitCount + missCount
if lookupCount == 0 {
return 0
} else {
return float64(hitCount) / float64(lookupCount)
}
} | go | func (cache *Cache) HitRate() float64 {
hitCount, missCount := cache.HitCount(), cache.MissCount()
lookupCount := hitCount + missCount
if lookupCount == 0 {
return 0
} else {
return float64(hitCount) / float64(lookupCount)
}
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"HitRate",
"(",
")",
"float64",
"{",
"hitCount",
",",
"missCount",
":=",
"cache",
".",
"HitCount",
"(",
")",
",",
"cache",
".",
"MissCount",
"(",
")",
"\n",
"lookupCount",
":=",
"hitCount",
"+",
"missCount",
"\n",
"if",
"lookupCount",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"else",
"{",
"return",
"float64",
"(",
"hitCount",
")",
"/",
"float64",
"(",
"lookupCount",
")",
"\n",
"}",
"\n",
"}"
] | // HitRate is the ratio of hits over lookups. | [
"HitRate",
"is",
"the",
"ratio",
"of",
"hits",
"over",
"lookups",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L199-L207 |
148,015 | coocood/freecache | cache.go | OverwriteCount | func (cache *Cache) OverwriteCount() (overwriteCount int64) {
for i := range cache.segments {
overwriteCount += atomic.LoadInt64(&cache.segments[i].overwrites)
}
return
} | go | func (cache *Cache) OverwriteCount() (overwriteCount int64) {
for i := range cache.segments {
overwriteCount += atomic.LoadInt64(&cache.segments[i].overwrites)
}
return
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"OverwriteCount",
"(",
")",
"(",
"overwriteCount",
"int64",
")",
"{",
"for",
"i",
":=",
"range",
"cache",
".",
"segments",
"{",
"overwriteCount",
"+=",
"atomic",
".",
"LoadInt64",
"(",
"&",
"cache",
".",
"segments",
"[",
"i",
"]",
".",
"overwrites",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // OverwriteCount indicates the number of times entries have been overriden. | [
"OverwriteCount",
"indicates",
"the",
"number",
"of",
"times",
"entries",
"have",
"been",
"overriden",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L210-L215 |
148,016 | coocood/freecache | cache.go | ResetStatistics | func (cache *Cache) ResetStatistics() {
for i := range cache.segments {
cache.locks[i].Lock()
cache.segments[i].resetStatistics()
cache.locks[i].Unlock()
}
} | go | func (cache *Cache) ResetStatistics() {
for i := range cache.segments {
cache.locks[i].Lock()
cache.segments[i].resetStatistics()
cache.locks[i].Unlock()
}
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"ResetStatistics",
"(",
")",
"{",
"for",
"i",
":=",
"range",
"cache",
".",
"segments",
"{",
"cache",
".",
"locks",
"[",
"i",
"]",
".",
"Lock",
"(",
")",
"\n",
"cache",
".",
"segments",
"[",
"i",
"]",
".",
"resetStatistics",
"(",
")",
"\n",
"cache",
".",
"locks",
"[",
"i",
"]",
".",
"Unlock",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // ResetStatistics refreshes the current state of the statistics. | [
"ResetStatistics",
"refreshes",
"the",
"current",
"state",
"of",
"the",
"statistics",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/cache.go#L227-L233 |
148,017 | coocood/freecache | ringbuf.go | Dump | func (rb *RingBuf) Dump() []byte {
dump := make([]byte, len(rb.data))
copy(dump, rb.data)
return dump
} | go | func (rb *RingBuf) Dump() []byte {
dump := make([]byte, len(rb.data))
copy(dump, rb.data)
return dump
} | [
"func",
"(",
"rb",
"*",
"RingBuf",
")",
"Dump",
"(",
")",
"[",
"]",
"byte",
"{",
"dump",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"rb",
".",
"data",
")",
")",
"\n",
"copy",
"(",
"dump",
",",
"rb",
".",
"data",
")",
"\n",
"return",
"dump",
"\n",
"}"
] | // Create a copy of the buffer. | [
"Create",
"a",
"copy",
"of",
"the",
"buffer",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/ringbuf.go#L31-L35 |
148,018 | coocood/freecache | ringbuf.go | Evacuate | func (rb *RingBuf) Evacuate(off int64, length int) (newOff int64) {
if off+int64(length) > rb.end || off < rb.begin {
return -1
}
var readOff int
if rb.end-rb.begin < int64(len(rb.data)) {
readOff = int(off - rb.begin)
} else {
readOff = rb.index + int(off-rb.begin)
}
if readOff >= len(rb.data) {
readOff -= len(rb.data)
}
if readOff == rb.index {
// no copy evacuate
rb.index += length
if rb.index >= len(rb.data) {
rb.index -= len(rb.data)
}
} else if readOff < rb.index {
var n = copy(rb.data[rb.index:], rb.data[readOff:readOff+length])
rb.index += n
if rb.index == len(rb.data) {
rb.index = copy(rb.data, rb.data[readOff+n:readOff+length])
}
} else {
var readEnd = readOff + length
var n int
if readEnd <= len(rb.data) {
n = copy(rb.data[rb.index:], rb.data[readOff:readEnd])
rb.index += n
} else {
n = copy(rb.data[rb.index:], rb.data[readOff:])
rb.index += n
var tail = length - n
n = copy(rb.data[rb.index:], rb.data[:tail])
rb.index += n
if rb.index == len(rb.data) {
rb.index = copy(rb.data, rb.data[n:tail])
}
}
}
newOff = rb.end
rb.end += int64(length)
if rb.begin < rb.end-int64(len(rb.data)) {
rb.begin = rb.end - int64(len(rb.data))
}
return
} | go | func (rb *RingBuf) Evacuate(off int64, length int) (newOff int64) {
if off+int64(length) > rb.end || off < rb.begin {
return -1
}
var readOff int
if rb.end-rb.begin < int64(len(rb.data)) {
readOff = int(off - rb.begin)
} else {
readOff = rb.index + int(off-rb.begin)
}
if readOff >= len(rb.data) {
readOff -= len(rb.data)
}
if readOff == rb.index {
// no copy evacuate
rb.index += length
if rb.index >= len(rb.data) {
rb.index -= len(rb.data)
}
} else if readOff < rb.index {
var n = copy(rb.data[rb.index:], rb.data[readOff:readOff+length])
rb.index += n
if rb.index == len(rb.data) {
rb.index = copy(rb.data, rb.data[readOff+n:readOff+length])
}
} else {
var readEnd = readOff + length
var n int
if readEnd <= len(rb.data) {
n = copy(rb.data[rb.index:], rb.data[readOff:readEnd])
rb.index += n
} else {
n = copy(rb.data[rb.index:], rb.data[readOff:])
rb.index += n
var tail = length - n
n = copy(rb.data[rb.index:], rb.data[:tail])
rb.index += n
if rb.index == len(rb.data) {
rb.index = copy(rb.data, rb.data[n:tail])
}
}
}
newOff = rb.end
rb.end += int64(length)
if rb.begin < rb.end-int64(len(rb.data)) {
rb.begin = rb.end - int64(len(rb.data))
}
return
} | [
"func",
"(",
"rb",
"*",
"RingBuf",
")",
"Evacuate",
"(",
"off",
"int64",
",",
"length",
"int",
")",
"(",
"newOff",
"int64",
")",
"{",
"if",
"off",
"+",
"int64",
"(",
"length",
")",
">",
"rb",
".",
"end",
"||",
"off",
"<",
"rb",
".",
"begin",
"{",
"return",
"-",
"1",
"\n",
"}",
"\n",
"var",
"readOff",
"int",
"\n",
"if",
"rb",
".",
"end",
"-",
"rb",
".",
"begin",
"<",
"int64",
"(",
"len",
"(",
"rb",
".",
"data",
")",
")",
"{",
"readOff",
"=",
"int",
"(",
"off",
"-",
"rb",
".",
"begin",
")",
"\n",
"}",
"else",
"{",
"readOff",
"=",
"rb",
".",
"index",
"+",
"int",
"(",
"off",
"-",
"rb",
".",
"begin",
")",
"\n",
"}",
"\n",
"if",
"readOff",
">=",
"len",
"(",
"rb",
".",
"data",
")",
"{",
"readOff",
"-=",
"len",
"(",
"rb",
".",
"data",
")",
"\n",
"}",
"\n\n",
"if",
"readOff",
"==",
"rb",
".",
"index",
"{",
"// no copy evacuate",
"rb",
".",
"index",
"+=",
"length",
"\n",
"if",
"rb",
".",
"index",
">=",
"len",
"(",
"rb",
".",
"data",
")",
"{",
"rb",
".",
"index",
"-=",
"len",
"(",
"rb",
".",
"data",
")",
"\n",
"}",
"\n",
"}",
"else",
"if",
"readOff",
"<",
"rb",
".",
"index",
"{",
"var",
"n",
"=",
"copy",
"(",
"rb",
".",
"data",
"[",
"rb",
".",
"index",
":",
"]",
",",
"rb",
".",
"data",
"[",
"readOff",
":",
"readOff",
"+",
"length",
"]",
")",
"\n",
"rb",
".",
"index",
"+=",
"n",
"\n",
"if",
"rb",
".",
"index",
"==",
"len",
"(",
"rb",
".",
"data",
")",
"{",
"rb",
".",
"index",
"=",
"copy",
"(",
"rb",
".",
"data",
",",
"rb",
".",
"data",
"[",
"readOff",
"+",
"n",
":",
"readOff",
"+",
"length",
"]",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"var",
"readEnd",
"=",
"readOff",
"+",
"length",
"\n",
"var",
"n",
"int",
"\n",
"if",
"readEnd",
"<=",
"len",
"(",
"rb",
".",
"data",
")",
"{",
"n",
"=",
"copy",
"(",
"rb",
".",
"data",
"[",
"rb",
".",
"index",
":",
"]",
",",
"rb",
".",
"data",
"[",
"readOff",
":",
"readEnd",
"]",
")",
"\n",
"rb",
".",
"index",
"+=",
"n",
"\n",
"}",
"else",
"{",
"n",
"=",
"copy",
"(",
"rb",
".",
"data",
"[",
"rb",
".",
"index",
":",
"]",
",",
"rb",
".",
"data",
"[",
"readOff",
":",
"]",
")",
"\n",
"rb",
".",
"index",
"+=",
"n",
"\n",
"var",
"tail",
"=",
"length",
"-",
"n",
"\n",
"n",
"=",
"copy",
"(",
"rb",
".",
"data",
"[",
"rb",
".",
"index",
":",
"]",
",",
"rb",
".",
"data",
"[",
":",
"tail",
"]",
")",
"\n",
"rb",
".",
"index",
"+=",
"n",
"\n",
"if",
"rb",
".",
"index",
"==",
"len",
"(",
"rb",
".",
"data",
")",
"{",
"rb",
".",
"index",
"=",
"copy",
"(",
"rb",
".",
"data",
",",
"rb",
".",
"data",
"[",
"n",
":",
"tail",
"]",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"newOff",
"=",
"rb",
".",
"end",
"\n",
"rb",
".",
"end",
"+=",
"int64",
"(",
"length",
")",
"\n",
"if",
"rb",
".",
"begin",
"<",
"rb",
".",
"end",
"-",
"int64",
"(",
"len",
"(",
"rb",
".",
"data",
")",
")",
"{",
"rb",
".",
"begin",
"=",
"rb",
".",
"end",
"-",
"int64",
"(",
"len",
"(",
"rb",
".",
"data",
")",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // Evacuate read the data at off, then write it to the the data stream,
// Keep it from being overwritten by new data. | [
"Evacuate",
"read",
"the",
"data",
"at",
"off",
"then",
"write",
"it",
"to",
"the",
"the",
"data",
"stream",
"Keep",
"it",
"from",
"being",
"overwritten",
"by",
"new",
"data",
"."
] | 142b9e1225b0ecdbe420d8fe6cef33f268670c42 | https://github.com/coocood/freecache/blob/142b9e1225b0ecdbe420d8fe6cef33f268670c42/ringbuf.go#L158-L207 |
148,019 | huandu/facebook | paging_result.go | Previous | func (pr *PagingResult) Previous() (noMore bool, err error) {
if !pr.HasPrevious() {
noMore = true
return
}
return pr.navigate(&pr.previous)
} | go | func (pr *PagingResult) Previous() (noMore bool, err error) {
if !pr.HasPrevious() {
noMore = true
return
}
return pr.navigate(&pr.previous)
} | [
"func",
"(",
"pr",
"*",
"PagingResult",
")",
"Previous",
"(",
")",
"(",
"noMore",
"bool",
",",
"err",
"error",
")",
"{",
"if",
"!",
"pr",
".",
"HasPrevious",
"(",
")",
"{",
"noMore",
"=",
"true",
"\n",
"return",
"\n",
"}",
"\n\n",
"return",
"pr",
".",
"navigate",
"(",
"&",
"pr",
".",
"previous",
")",
"\n",
"}"
] | // Previous reads previous page. | [
"Previous",
"reads",
"previous",
"page",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/paging_result.go#L64-L71 |
148,020 | huandu/facebook | paging_result.go | Next | func (pr *PagingResult) Next() (noMore bool, err error) {
if !pr.HasNext() {
noMore = true
return
}
return pr.navigate(&pr.next)
} | go | func (pr *PagingResult) Next() (noMore bool, err error) {
if !pr.HasNext() {
noMore = true
return
}
return pr.navigate(&pr.next)
} | [
"func",
"(",
"pr",
"*",
"PagingResult",
")",
"Next",
"(",
")",
"(",
"noMore",
"bool",
",",
"err",
"error",
")",
"{",
"if",
"!",
"pr",
".",
"HasNext",
"(",
")",
"{",
"noMore",
"=",
"true",
"\n",
"return",
"\n",
"}",
"\n\n",
"return",
"pr",
".",
"navigate",
"(",
"&",
"pr",
".",
"next",
")",
"\n",
"}"
] | // Next reads next page. | [
"Next",
"reads",
"next",
"page",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/paging_result.go#L74-L81 |
148,021 | huandu/facebook | filedata.go | Data | func Data(filename string, source io.Reader) *BinaryData {
return &BinaryData{
Filename: filename,
Source: source,
}
} | go | func Data(filename string, source io.Reader) *BinaryData {
return &BinaryData{
Filename: filename,
Source: source,
}
} | [
"func",
"Data",
"(",
"filename",
"string",
",",
"source",
"io",
".",
"Reader",
")",
"*",
"BinaryData",
"{",
"return",
"&",
"BinaryData",
"{",
"Filename",
":",
"filename",
",",
"Source",
":",
"source",
",",
"}",
"\n",
"}"
] | // Data creates new binary data holder. | [
"Data",
"creates",
"new",
"binary",
"data",
"holder",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/filedata.go#L29-L34 |
148,022 | huandu/facebook | filedata.go | DataWithContentType | func DataWithContentType(filename string, source io.Reader, contentType string) *BinaryData {
return &BinaryData{
Filename: filename,
Source: source,
ContentType: contentType,
}
} | go | func DataWithContentType(filename string, source io.Reader, contentType string) *BinaryData {
return &BinaryData{
Filename: filename,
Source: source,
ContentType: contentType,
}
} | [
"func",
"DataWithContentType",
"(",
"filename",
"string",
",",
"source",
"io",
".",
"Reader",
",",
"contentType",
"string",
")",
"*",
"BinaryData",
"{",
"return",
"&",
"BinaryData",
"{",
"Filename",
":",
"filename",
",",
"Source",
":",
"source",
",",
"ContentType",
":",
"contentType",
",",
"}",
"\n",
"}"
] | // DataWithContentType creates new binary data holder with arbitrary content type. | [
"DataWithContentType",
"creates",
"new",
"binary",
"data",
"holder",
"with",
"arbitrary",
"content",
"type",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/filedata.go#L37-L43 |
148,023 | huandu/facebook | filedata.go | FileAlias | func FileAlias(filename, path string) *BinaryFile {
return &BinaryFile{
Filename: filename,
Path: path,
}
} | go | func FileAlias(filename, path string) *BinaryFile {
return &BinaryFile{
Filename: filename,
Path: path,
}
} | [
"func",
"FileAlias",
"(",
"filename",
",",
"path",
"string",
")",
"*",
"BinaryFile",
"{",
"return",
"&",
"BinaryFile",
"{",
"Filename",
":",
"filename",
",",
"Path",
":",
"path",
",",
"}",
"\n",
"}"
] | // FileAlias creates a binary file holder and specific a different path for reading. | [
"FileAlias",
"creates",
"a",
"binary",
"file",
"holder",
"and",
"specific",
"a",
"different",
"path",
"for",
"reading",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/filedata.go#L53-L58 |
148,024 | huandu/facebook | filedata.go | FileAliasWithContentType | func FileAliasWithContentType(filename, path, contentType string) *BinaryFile {
if path == "" {
path = filename
}
return &BinaryFile{
Filename: filename,
Path: path,
ContentType: contentType,
}
} | go | func FileAliasWithContentType(filename, path, contentType string) *BinaryFile {
if path == "" {
path = filename
}
return &BinaryFile{
Filename: filename,
Path: path,
ContentType: contentType,
}
} | [
"func",
"FileAliasWithContentType",
"(",
"filename",
",",
"path",
",",
"contentType",
"string",
")",
"*",
"BinaryFile",
"{",
"if",
"path",
"==",
"\"",
"\"",
"{",
"path",
"=",
"filename",
"\n",
"}",
"\n\n",
"return",
"&",
"BinaryFile",
"{",
"Filename",
":",
"filename",
",",
"Path",
":",
"path",
",",
"ContentType",
":",
"contentType",
",",
"}",
"\n",
"}"
] | // FileAliasWithContentType creates a new binary file holder with arbitrary content type. | [
"FileAliasWithContentType",
"creates",
"a",
"new",
"binary",
"file",
"holder",
"with",
"arbitrary",
"content",
"type",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/filedata.go#L61-L71 |
148,025 | huandu/facebook | app.go | New | func New(appID, appSecret string) *App {
return &App{
AppId: appID,
AppSecret: appSecret,
}
} | go | func New(appID, appSecret string) *App {
return &App{
AppId: appID,
AppSecret: appSecret,
}
} | [
"func",
"New",
"(",
"appID",
",",
"appSecret",
"string",
")",
"*",
"App",
"{",
"return",
"&",
"App",
"{",
"AppId",
":",
"appID",
",",
"AppSecret",
":",
"appSecret",
",",
"}",
"\n",
"}"
] | // New creates a new App and sets app id and secret. | [
"New",
"creates",
"a",
"new",
"App",
"and",
"sets",
"app",
"id",
"and",
"secret",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/app.go#L36-L41 |
148,026 | huandu/facebook | app.go | ParseSignedRequest | func (app *App) ParseSignedRequest(signedRequest string) (res Result, err error) {
strs := strings.SplitN(signedRequest, ".", 2)
if len(strs) != 2 {
err = fmt.Errorf("invalid signed request format")
return
}
sig, e1 := base64.RawURLEncoding.DecodeString(strs[0])
if e1 != nil {
err = fmt.Errorf("fail to decode signed request sig with error %v", e1)
return
}
payload, e2 := base64.RawURLEncoding.DecodeString(strs[1])
if e2 != nil {
err = fmt.Errorf("fail to decode signed request payload with error is %v", e2)
return
}
err = json.Unmarshal(payload, &res)
if err != nil {
err = fmt.Errorf("signed request payload is not a valid json string with error %v", err)
return
}
var hashMethod string
err = res.DecodeField("algorithm", &hashMethod)
if err != nil {
err = fmt.Errorf("signed request payload doesn't contains a valid 'algorithm' field")
return
}
hashMethod = strings.ToUpper(hashMethod)
if hashMethod != "HMAC-SHA256" {
err = fmt.Errorf("signed request payload uses an unknown HMAC method; expect 'HMAC-SHA256' but actual is '%v'", hashMethod)
return
}
hash := hmac.New(sha256.New, []byte(app.AppSecret))
hash.Write([]byte(strs[1])) // note: here uses the payload base64 string, not decoded bytes
expectedSig := hash.Sum(nil)
if !hmac.Equal(sig, expectedSig) {
err = fmt.Errorf("bad signed request signiture")
return
}
return
} | go | func (app *App) ParseSignedRequest(signedRequest string) (res Result, err error) {
strs := strings.SplitN(signedRequest, ".", 2)
if len(strs) != 2 {
err = fmt.Errorf("invalid signed request format")
return
}
sig, e1 := base64.RawURLEncoding.DecodeString(strs[0])
if e1 != nil {
err = fmt.Errorf("fail to decode signed request sig with error %v", e1)
return
}
payload, e2 := base64.RawURLEncoding.DecodeString(strs[1])
if e2 != nil {
err = fmt.Errorf("fail to decode signed request payload with error is %v", e2)
return
}
err = json.Unmarshal(payload, &res)
if err != nil {
err = fmt.Errorf("signed request payload is not a valid json string with error %v", err)
return
}
var hashMethod string
err = res.DecodeField("algorithm", &hashMethod)
if err != nil {
err = fmt.Errorf("signed request payload doesn't contains a valid 'algorithm' field")
return
}
hashMethod = strings.ToUpper(hashMethod)
if hashMethod != "HMAC-SHA256" {
err = fmt.Errorf("signed request payload uses an unknown HMAC method; expect 'HMAC-SHA256' but actual is '%v'", hashMethod)
return
}
hash := hmac.New(sha256.New, []byte(app.AppSecret))
hash.Write([]byte(strs[1])) // note: here uses the payload base64 string, not decoded bytes
expectedSig := hash.Sum(nil)
if !hmac.Equal(sig, expectedSig) {
err = fmt.Errorf("bad signed request signiture")
return
}
return
} | [
"func",
"(",
"app",
"*",
"App",
")",
"ParseSignedRequest",
"(",
"signedRequest",
"string",
")",
"(",
"res",
"Result",
",",
"err",
"error",
")",
"{",
"strs",
":=",
"strings",
".",
"SplitN",
"(",
"signedRequest",
",",
"\"",
"\"",
",",
"2",
")",
"\n\n",
"if",
"len",
"(",
"strs",
")",
"!=",
"2",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"sig",
",",
"e1",
":=",
"base64",
".",
"RawURLEncoding",
".",
"DecodeString",
"(",
"strs",
"[",
"0",
"]",
")",
"\n\n",
"if",
"e1",
"!=",
"nil",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"e1",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"payload",
",",
"e2",
":=",
"base64",
".",
"RawURLEncoding",
".",
"DecodeString",
"(",
"strs",
"[",
"1",
"]",
")",
"\n\n",
"if",
"e2",
"!=",
"nil",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"e2",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"payload",
",",
"&",
"res",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"var",
"hashMethod",
"string",
"\n",
"err",
"=",
"res",
".",
"DecodeField",
"(",
"\"",
"\"",
",",
"&",
"hashMethod",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"hashMethod",
"=",
"strings",
".",
"ToUpper",
"(",
"hashMethod",
")",
"\n\n",
"if",
"hashMethod",
"!=",
"\"",
"\"",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"hashMethod",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"hash",
":=",
"hmac",
".",
"New",
"(",
"sha256",
".",
"New",
",",
"[",
"]",
"byte",
"(",
"app",
".",
"AppSecret",
")",
")",
"\n",
"hash",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"strs",
"[",
"1",
"]",
")",
")",
"// note: here uses the payload base64 string, not decoded bytes",
"\n",
"expectedSig",
":=",
"hash",
".",
"Sum",
"(",
"nil",
")",
"\n\n",
"if",
"!",
"hmac",
".",
"Equal",
"(",
"sig",
",",
"expectedSig",
")",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] | // ParseSignedRequest parses signed request. | [
"ParseSignedRequest",
"parses",
"signed",
"request",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/app.go#L49-L103 |
148,027 | huandu/facebook | app.go | ExchangeToken | func (app *App) ExchangeToken(accessToken string) (token string, expires int, err error) {
if accessToken == "" {
err = fmt.Errorf("short lived accessToken is empty")
return
}
var res Result
res, err = defaultSession.sendOauthRequest("/oauth/access_token", Params{
"grant_type": "fb_exchange_token",
"client_id": app.AppId,
"client_secret": app.AppSecret,
"fb_exchange_token": accessToken,
})
if err != nil {
err = fmt.Errorf("fail to parse facebook response with error %v", err)
return
}
err = res.DecodeField("access_token", &token)
if err != nil {
return
}
expiresKey := "expires_in"
if _, ok := res["expires"]; ok {
expiresKey = "expires"
}
if _, ok := res[expiresKey]; ok {
err = res.DecodeField(expiresKey, &expires)
}
return
} | go | func (app *App) ExchangeToken(accessToken string) (token string, expires int, err error) {
if accessToken == "" {
err = fmt.Errorf("short lived accessToken is empty")
return
}
var res Result
res, err = defaultSession.sendOauthRequest("/oauth/access_token", Params{
"grant_type": "fb_exchange_token",
"client_id": app.AppId,
"client_secret": app.AppSecret,
"fb_exchange_token": accessToken,
})
if err != nil {
err = fmt.Errorf("fail to parse facebook response with error %v", err)
return
}
err = res.DecodeField("access_token", &token)
if err != nil {
return
}
expiresKey := "expires_in"
if _, ok := res["expires"]; ok {
expiresKey = "expires"
}
if _, ok := res[expiresKey]; ok {
err = res.DecodeField(expiresKey, &expires)
}
return
} | [
"func",
"(",
"app",
"*",
"App",
")",
"ExchangeToken",
"(",
"accessToken",
"string",
")",
"(",
"token",
"string",
",",
"expires",
"int",
",",
"err",
"error",
")",
"{",
"if",
"accessToken",
"==",
"\"",
"\"",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"var",
"res",
"Result",
"\n",
"res",
",",
"err",
"=",
"defaultSession",
".",
"sendOauthRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
":",
"\"",
"\"",
",",
"\"",
"\"",
":",
"app",
".",
"AppId",
",",
"\"",
"\"",
":",
"app",
".",
"AppSecret",
",",
"\"",
"\"",
":",
"accessToken",
",",
"}",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"err",
"=",
"res",
".",
"DecodeField",
"(",
"\"",
"\"",
",",
"&",
"token",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"expiresKey",
":=",
"\"",
"\"",
"\n\n",
"if",
"_",
",",
"ok",
":=",
"res",
"[",
"\"",
"\"",
"]",
";",
"ok",
"{",
"expiresKey",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"if",
"_",
",",
"ok",
":=",
"res",
"[",
"expiresKey",
"]",
";",
"ok",
"{",
"err",
"=",
"res",
".",
"DecodeField",
"(",
"expiresKey",
",",
"&",
"expires",
")",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] | // ExchangeToken exchanges a short-lived access token to a long-lived access token.
// Return new access token and its expires time. | [
"ExchangeToken",
"exchanges",
"a",
"short",
"-",
"lived",
"access",
"token",
"to",
"a",
"long",
"-",
"lived",
"access",
"token",
".",
"Return",
"new",
"access",
"token",
"and",
"its",
"expires",
"time",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/app.go#L168-L204 |
148,028 | huandu/facebook | app.go | GetCode | func (app *App) GetCode(accessToken string) (code string, err error) {
if accessToken == "" {
err = fmt.Errorf("long lived accessToken is empty")
return
}
var res Result
res, err = defaultSession.sendOauthRequest("/oauth/client_code", Params{
"client_id": app.AppId,
"client_secret": app.AppSecret,
"redirect_uri": app.RedirectUri,
"access_token": accessToken,
})
if err != nil {
err = fmt.Errorf("fail to get code from facebook with error %v", err)
return
}
err = res.DecodeField("code", &code)
return
} | go | func (app *App) GetCode(accessToken string) (code string, err error) {
if accessToken == "" {
err = fmt.Errorf("long lived accessToken is empty")
return
}
var res Result
res, err = defaultSession.sendOauthRequest("/oauth/client_code", Params{
"client_id": app.AppId,
"client_secret": app.AppSecret,
"redirect_uri": app.RedirectUri,
"access_token": accessToken,
})
if err != nil {
err = fmt.Errorf("fail to get code from facebook with error %v", err)
return
}
err = res.DecodeField("code", &code)
return
} | [
"func",
"(",
"app",
"*",
"App",
")",
"GetCode",
"(",
"accessToken",
"string",
")",
"(",
"code",
"string",
",",
"err",
"error",
")",
"{",
"if",
"accessToken",
"==",
"\"",
"\"",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"var",
"res",
"Result",
"\n",
"res",
",",
"err",
"=",
"defaultSession",
".",
"sendOauthRequest",
"(",
"\"",
"\"",
",",
"Params",
"{",
"\"",
"\"",
":",
"app",
".",
"AppId",
",",
"\"",
"\"",
":",
"app",
".",
"AppSecret",
",",
"\"",
"\"",
":",
"app",
".",
"RedirectUri",
",",
"\"",
"\"",
":",
"accessToken",
",",
"}",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"err",
"=",
"res",
".",
"DecodeField",
"(",
"\"",
"\"",
",",
"&",
"code",
")",
"\n",
"return",
"\n",
"}"
] | // GetCode gets code from a long lived access token.
// Return the code retrieved from facebook. | [
"GetCode",
"gets",
"code",
"from",
"a",
"long",
"lived",
"access",
"token",
".",
"Return",
"the",
"code",
"retrieved",
"from",
"facebook",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/app.go#L208-L229 |
148,029 | huandu/facebook | app.go | Session | func (app *App) Session(accessToken string) *Session {
return &Session{
accessToken: accessToken,
app: app,
enableAppsecretProof: app.EnableAppsecretProof,
}
} | go | func (app *App) Session(accessToken string) *Session {
return &Session{
accessToken: accessToken,
app: app,
enableAppsecretProof: app.EnableAppsecretProof,
}
} | [
"func",
"(",
"app",
"*",
"App",
")",
"Session",
"(",
"accessToken",
"string",
")",
"*",
"Session",
"{",
"return",
"&",
"Session",
"{",
"accessToken",
":",
"accessToken",
",",
"app",
":",
"app",
",",
"enableAppsecretProof",
":",
"app",
".",
"EnableAppsecretProof",
",",
"}",
"\n",
"}"
] | // Session creates a session based on current App setting. | [
"Session",
"creates",
"a",
"session",
"based",
"on",
"current",
"App",
"setting",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/app.go#L232-L238 |
148,030 | huandu/facebook | app.go | SessionFromSignedRequest | func (app *App) SessionFromSignedRequest(signedRequest string) (session *Session, err error) {
var res Result
res, err = app.ParseSignedRequest(signedRequest)
if err != nil {
return
}
var id, token string
res.DecodeField("user_id", &id) // it's ok without user id.
err = res.DecodeField("oauth_token", &token)
if err == nil {
session = &Session{
accessToken: token,
app: app,
id: id,
enableAppsecretProof: app.EnableAppsecretProof,
}
return
}
// cannot get "oauth_token"? try to get "code".
err = res.DecodeField("code", &token)
if err != nil {
// no code? no way to continue.
err = fmt.Errorf("cannot find 'oauth_token' and 'code'; unable to continue")
return
}
token, err = app.ParseCode(token)
if err != nil {
return
}
session = &Session{
accessToken: token,
app: app,
id: id,
enableAppsecretProof: app.EnableAppsecretProof,
}
return
} | go | func (app *App) SessionFromSignedRequest(signedRequest string) (session *Session, err error) {
var res Result
res, err = app.ParseSignedRequest(signedRequest)
if err != nil {
return
}
var id, token string
res.DecodeField("user_id", &id) // it's ok without user id.
err = res.DecodeField("oauth_token", &token)
if err == nil {
session = &Session{
accessToken: token,
app: app,
id: id,
enableAppsecretProof: app.EnableAppsecretProof,
}
return
}
// cannot get "oauth_token"? try to get "code".
err = res.DecodeField("code", &token)
if err != nil {
// no code? no way to continue.
err = fmt.Errorf("cannot find 'oauth_token' and 'code'; unable to continue")
return
}
token, err = app.ParseCode(token)
if err != nil {
return
}
session = &Session{
accessToken: token,
app: app,
id: id,
enableAppsecretProof: app.EnableAppsecretProof,
}
return
} | [
"func",
"(",
"app",
"*",
"App",
")",
"SessionFromSignedRequest",
"(",
"signedRequest",
"string",
")",
"(",
"session",
"*",
"Session",
",",
"err",
"error",
")",
"{",
"var",
"res",
"Result",
"\n\n",
"res",
",",
"err",
"=",
"app",
".",
"ParseSignedRequest",
"(",
"signedRequest",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"var",
"id",
",",
"token",
"string",
"\n\n",
"res",
".",
"DecodeField",
"(",
"\"",
"\"",
",",
"&",
"id",
")",
"// it's ok without user id.",
"\n",
"err",
"=",
"res",
".",
"DecodeField",
"(",
"\"",
"\"",
",",
"&",
"token",
")",
"\n\n",
"if",
"err",
"==",
"nil",
"{",
"session",
"=",
"&",
"Session",
"{",
"accessToken",
":",
"token",
",",
"app",
":",
"app",
",",
"id",
":",
"id",
",",
"enableAppsecretProof",
":",
"app",
".",
"EnableAppsecretProof",
",",
"}",
"\n",
"return",
"\n",
"}",
"\n\n",
"// cannot get \"oauth_token\"? try to get \"code\".",
"err",
"=",
"res",
".",
"DecodeField",
"(",
"\"",
"\"",
",",
"&",
"token",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"// no code? no way to continue.",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"token",
",",
"err",
"=",
"app",
".",
"ParseCode",
"(",
"token",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"session",
"=",
"&",
"Session",
"{",
"accessToken",
":",
"token",
",",
"app",
":",
"app",
",",
"id",
":",
"id",
",",
"enableAppsecretProof",
":",
"app",
".",
"EnableAppsecretProof",
",",
"}",
"\n",
"return",
"\n",
"}"
] | // SessionFromSignedRequest creates a session from a signed request.
// If signed request contains a code, it will automatically use this code
// to exchange a valid access token. | [
"SessionFromSignedRequest",
"creates",
"a",
"session",
"from",
"a",
"signed",
"request",
".",
"If",
"signed",
"request",
"contains",
"a",
"code",
"it",
"will",
"automatically",
"use",
"this",
"code",
"to",
"exchange",
"a",
"valid",
"access",
"token",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/app.go#L243-L289 |
148,031 | huandu/facebook | session.go | Api | func (session *Session) Api(path string, method Method, params Params) (Result, error) {
return session.graph(path, method, params)
} | go | func (session *Session) Api(path string, method Method, params Params) (Result, error) {
return session.graph(path, method, params)
} | [
"func",
"(",
"session",
"*",
"Session",
")",
"Api",
"(",
"path",
"string",
",",
"method",
"Method",
",",
"params",
"Params",
")",
"(",
"Result",
",",
"error",
")",
"{",
"return",
"session",
".",
"graph",
"(",
"path",
",",
"method",
",",
"params",
")",
"\n",
"}"
] | // Api makes a facebook graph api call.
//
// If session access token is set, "access_token" in params will be set to the token value.
//
// Returns facebook graph api call result.
// If facebook returns error in response, returns error details in res and set err. | [
"Api",
"makes",
"a",
"facebook",
"graph",
"api",
"call",
".",
"If",
"session",
"access",
"token",
"is",
"set",
"access_token",
"in",
"params",
"will",
"be",
"set",
"to",
"the",
"token",
"value",
".",
"Returns",
"facebook",
"graph",
"api",
"call",
"result",
".",
"If",
"facebook",
"returns",
"error",
"in",
"response",
"returns",
"error",
"details",
"in",
"res",
"and",
"set",
"err",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/session.go#L84-L86 |
148,032 | huandu/facebook | session.go | User | func (session *Session) User() (id string, err error) {
if session.id != "" {
id = session.id
return
}
if session.accessToken == "" && session.HttpClient == nil {
err = fmt.Errorf("access token is not set")
return
}
var result Result
result, err = session.Api("/me", GET, Params{"fields": "id"})
if err != nil {
return
}
err = result.DecodeField("id", &id)
if err != nil {
return
}
return
} | go | func (session *Session) User() (id string, err error) {
if session.id != "" {
id = session.id
return
}
if session.accessToken == "" && session.HttpClient == nil {
err = fmt.Errorf("access token is not set")
return
}
var result Result
result, err = session.Api("/me", GET, Params{"fields": "id"})
if err != nil {
return
}
err = result.DecodeField("id", &id)
if err != nil {
return
}
return
} | [
"func",
"(",
"session",
"*",
"Session",
")",
"User",
"(",
")",
"(",
"id",
"string",
",",
"err",
"error",
")",
"{",
"if",
"session",
".",
"id",
"!=",
"\"",
"\"",
"{",
"id",
"=",
"session",
".",
"id",
"\n",
"return",
"\n",
"}",
"\n\n",
"if",
"session",
".",
"accessToken",
"==",
"\"",
"\"",
"&&",
"session",
".",
"HttpClient",
"==",
"nil",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"var",
"result",
"Result",
"\n",
"result",
",",
"err",
"=",
"session",
".",
"Api",
"(",
"\"",
"\"",
",",
"GET",
",",
"Params",
"{",
"\"",
"\"",
":",
"\"",
"\"",
"}",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"err",
"=",
"result",
".",
"DecodeField",
"(",
"\"",
"\"",
",",
"&",
"id",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] | // User gets current user id from access token.
//
// Returns error if access token is not set or invalid.
//
// It's a standard way to validate a facebook access token. | [
"User",
"gets",
"current",
"user",
"id",
"from",
"access",
"token",
".",
"Returns",
"error",
"if",
"access",
"token",
"is",
"not",
"set",
"or",
"invalid",
".",
"It",
"s",
"a",
"standard",
"way",
"to",
"validate",
"a",
"facebook",
"access",
"token",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/session.go#L163-L188 |
148,033 | huandu/facebook | session.go | Validate | func (session *Session) Validate() (err error) {
if session.accessToken == "" && session.HttpClient == nil {
err = fmt.Errorf("access token is not set")
return
}
var result Result
result, err = session.Api("/me", GET, Params{"fields": "id"})
if err != nil {
return
}
if f := result.Get("id"); f == nil {
err = fmt.Errorf("invalid access token")
return
}
return
} | go | func (session *Session) Validate() (err error) {
if session.accessToken == "" && session.HttpClient == nil {
err = fmt.Errorf("access token is not set")
return
}
var result Result
result, err = session.Api("/me", GET, Params{"fields": "id"})
if err != nil {
return
}
if f := result.Get("id"); f == nil {
err = fmt.Errorf("invalid access token")
return
}
return
} | [
"func",
"(",
"session",
"*",
"Session",
")",
"Validate",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"session",
".",
"accessToken",
"==",
"\"",
"\"",
"&&",
"session",
".",
"HttpClient",
"==",
"nil",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"var",
"result",
"Result",
"\n",
"result",
",",
"err",
"=",
"session",
".",
"Api",
"(",
"\"",
"\"",
",",
"GET",
",",
"Params",
"{",
"\"",
"\"",
":",
"\"",
"\"",
"}",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
"f",
":=",
"result",
".",
"Get",
"(",
"\"",
"\"",
")",
";",
"f",
"==",
"nil",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] | // Validate validates Session access token.
// Returns nil if access token is valid. | [
"Validate",
"validates",
"Session",
"access",
"token",
".",
"Returns",
"nil",
"if",
"access",
"token",
"is",
"valid",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/session.go#L192-L211 |
148,034 | huandu/facebook | session.go | SetAccessToken | func (session *Session) SetAccessToken(token string) {
if token != session.accessToken {
session.id = ""
session.accessToken = token
session.appsecretProof = ""
}
} | go | func (session *Session) SetAccessToken(token string) {
if token != session.accessToken {
session.id = ""
session.accessToken = token
session.appsecretProof = ""
}
} | [
"func",
"(",
"session",
"*",
"Session",
")",
"SetAccessToken",
"(",
"token",
"string",
")",
"{",
"if",
"token",
"!=",
"session",
".",
"accessToken",
"{",
"session",
".",
"id",
"=",
"\"",
"\"",
"\n",
"session",
".",
"accessToken",
"=",
"token",
"\n",
"session",
".",
"appsecretProof",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"}"
] | // SetAccessToken sets a new access token. | [
"SetAccessToken",
"sets",
"a",
"new",
"access",
"token",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/session.go#L263-L269 |
148,035 | huandu/facebook | session.go | AppsecretProof | func (session *Session) AppsecretProof() string {
if !session.enableAppsecretProof {
return ""
}
if session.accessToken == "" || session.app == nil {
return ""
}
if session.appsecretProof == "" {
hash := hmac.New(sha256.New, []byte(session.app.AppSecret))
hash.Write([]byte(session.accessToken))
session.appsecretProof = hex.EncodeToString(hash.Sum(nil))
}
return session.appsecretProof
} | go | func (session *Session) AppsecretProof() string {
if !session.enableAppsecretProof {
return ""
}
if session.accessToken == "" || session.app == nil {
return ""
}
if session.appsecretProof == "" {
hash := hmac.New(sha256.New, []byte(session.app.AppSecret))
hash.Write([]byte(session.accessToken))
session.appsecretProof = hex.EncodeToString(hash.Sum(nil))
}
return session.appsecretProof
} | [
"func",
"(",
"session",
"*",
"Session",
")",
"AppsecretProof",
"(",
")",
"string",
"{",
"if",
"!",
"session",
".",
"enableAppsecretProof",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"if",
"session",
".",
"accessToken",
"==",
"\"",
"\"",
"||",
"session",
".",
"app",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"if",
"session",
".",
"appsecretProof",
"==",
"\"",
"\"",
"{",
"hash",
":=",
"hmac",
".",
"New",
"(",
"sha256",
".",
"New",
",",
"[",
"]",
"byte",
"(",
"session",
".",
"app",
".",
"AppSecret",
")",
")",
"\n",
"hash",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"session",
".",
"accessToken",
")",
")",
"\n",
"session",
".",
"appsecretProof",
"=",
"hex",
".",
"EncodeToString",
"(",
"hash",
".",
"Sum",
"(",
"nil",
")",
")",
"\n",
"}",
"\n\n",
"return",
"session",
".",
"appsecretProof",
"\n",
"}"
] | // AppsecretProof checks appsecret proof is enabled or not. | [
"AppsecretProof",
"checks",
"appsecret",
"proof",
"is",
"enabled",
"or",
"not",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/session.go#L272-L288 |
148,036 | huandu/facebook | session.go | EnableAppsecretProof | func (session *Session) EnableAppsecretProof(enabled bool) error {
if session.app == nil {
return fmt.Errorf("cannot change appsecret proof status without an associated App")
}
if session.enableAppsecretProof != enabled {
session.enableAppsecretProof = enabled
// reset pre-calculated proof here to give caller a way to do so in some rare case,
// e.g. associated app's secret is changed.
session.appsecretProof = ""
}
return nil
} | go | func (session *Session) EnableAppsecretProof(enabled bool) error {
if session.app == nil {
return fmt.Errorf("cannot change appsecret proof status without an associated App")
}
if session.enableAppsecretProof != enabled {
session.enableAppsecretProof = enabled
// reset pre-calculated proof here to give caller a way to do so in some rare case,
// e.g. associated app's secret is changed.
session.appsecretProof = ""
}
return nil
} | [
"func",
"(",
"session",
"*",
"Session",
")",
"EnableAppsecretProof",
"(",
"enabled",
"bool",
")",
"error",
"{",
"if",
"session",
".",
"app",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"session",
".",
"enableAppsecretProof",
"!=",
"enabled",
"{",
"session",
".",
"enableAppsecretProof",
"=",
"enabled",
"\n\n",
"// reset pre-calculated proof here to give caller a way to do so in some rare case,",
"// e.g. associated app's secret is changed.",
"session",
".",
"appsecretProof",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // EnableAppsecretProof enables or disable appsecret proof status.
// Returns error if there is no App associated with this Session. | [
"EnableAppsecretProof",
"enables",
"or",
"disable",
"appsecret",
"proof",
"status",
".",
"Returns",
"error",
"if",
"there",
"is",
"no",
"App",
"associated",
"with",
"this",
"Session",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/session.go#L292-L306 |
148,037 | huandu/facebook | session.go | Debug | func (session *Session) Debug() DebugMode {
if session.debug != DEBUG_OFF {
return session.debug
}
return Debug
} | go | func (session *Session) Debug() DebugMode {
if session.debug != DEBUG_OFF {
return session.debug
}
return Debug
} | [
"func",
"(",
"session",
"*",
"Session",
")",
"Debug",
"(",
")",
"DebugMode",
"{",
"if",
"session",
".",
"debug",
"!=",
"DEBUG_OFF",
"{",
"return",
"session",
".",
"debug",
"\n",
"}",
"\n\n",
"return",
"Debug",
"\n",
"}"
] | // Debug returns current debug mode. | [
"Debug",
"returns",
"current",
"debug",
"mode",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/session.go#L314-L320 |
148,038 | huandu/facebook | session.go | SetDebug | func (session *Session) SetDebug(debug DebugMode) DebugMode {
old := session.debug
session.debug = debug
return old
} | go | func (session *Session) SetDebug(debug DebugMode) DebugMode {
old := session.debug
session.debug = debug
return old
} | [
"func",
"(",
"session",
"*",
"Session",
")",
"SetDebug",
"(",
"debug",
"DebugMode",
")",
"DebugMode",
"{",
"old",
":=",
"session",
".",
"debug",
"\n",
"session",
".",
"debug",
"=",
"debug",
"\n",
"return",
"old",
"\n",
"}"
] | // SetDebug updates per session debug mode and returns old mode.
// If per session debug mode is DEBUG_OFF, session will use global
// Debug mode. | [
"SetDebug",
"updates",
"per",
"session",
"debug",
"mode",
"and",
"returns",
"old",
"mode",
".",
"If",
"per",
"session",
"debug",
"mode",
"is",
"DEBUG_OFF",
"session",
"will",
"use",
"global",
"Debug",
"mode",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/session.go#L325-L329 |
148,039 | huandu/facebook | session.go | WithContext | func (session *Session) WithContext(ctx context.Context) *Session {
s := *session
s.context = ctx
return &s
} | go | func (session *Session) WithContext(ctx context.Context) *Session {
s := *session
s.context = ctx
return &s
} | [
"func",
"(",
"session",
"*",
"Session",
")",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"Session",
"{",
"s",
":=",
"*",
"session",
"\n",
"s",
".",
"context",
"=",
"ctx",
"\n",
"return",
"&",
"s",
"\n",
"}"
] | // WithContext returns a shallow copy of session with its context changed to ctx.
// The provided ctx must be non-nil. | [
"WithContext",
"returns",
"a",
"shallow",
"copy",
"of",
"session",
"with",
"its",
"context",
"changed",
"to",
"ctx",
".",
"The",
"provided",
"ctx",
"must",
"be",
"non",
"-",
"nil",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/session.go#L656-L660 |
148,040 | huandu/facebook | result.go | MakeResult | func MakeResult(jsonBytes []byte) (Result, error) {
res := Result{}
err := makeResult(jsonBytes, &res)
if err != nil {
return nil, err
}
// facebook may return an error
return res, res.Err()
} | go | func MakeResult(jsonBytes []byte) (Result, error) {
res := Result{}
err := makeResult(jsonBytes, &res)
if err != nil {
return nil, err
}
// facebook may return an error
return res, res.Err()
} | [
"func",
"MakeResult",
"(",
"jsonBytes",
"[",
"]",
"byte",
")",
"(",
"Result",
",",
"error",
")",
"{",
"res",
":=",
"Result",
"{",
"}",
"\n",
"err",
":=",
"makeResult",
"(",
"jsonBytes",
",",
"&",
"res",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"// facebook may return an error",
"return",
"res",
",",
"res",
".",
"Err",
"(",
")",
"\n",
"}"
] | // MakeResult makes a Result from facebook Graph API response. | [
"MakeResult",
"makes",
"a",
"Result",
"from",
"facebook",
"Graph",
"API",
"response",
"."
] | 2d3753b3eead5325f72a52b940da5d36ed611aa4 | https://github.com/huandu/facebook/blob/2d3753b3eead5325f72a52b940da5d36ed611aa4/result.go#L129-L139 |
148,041 | alecthomas/kingpin | app.go | New | func New(name, help string) *Application {
a := &Application{
Name: name,
Help: help,
errorWriter: os.Stderr, // Left for backwards compatibility purposes.
usageWriter: os.Stderr,
usageTemplate: DefaultUsageTemplate,
terminate: os.Exit,
}
a.flagGroup = newFlagGroup()
a.argGroup = newArgGroup()
a.cmdGroup = newCmdGroup(a)
a.HelpFlag = a.Flag("help", "Show context-sensitive help (also try --help-long and --help-man).")
a.HelpFlag.Bool()
a.Flag("help-long", "Generate long help.").Hidden().PreAction(a.generateLongHelp).Bool()
a.Flag("help-man", "Generate a man page.").Hidden().PreAction(a.generateManPage).Bool()
a.Flag("completion-bash", "Output possible completions for the given args.").Hidden().BoolVar(&a.completion)
a.Flag("completion-script-bash", "Generate completion script for bash.").Hidden().PreAction(a.generateBashCompletionScript).Bool()
a.Flag("completion-script-zsh", "Generate completion script for ZSH.").Hidden().PreAction(a.generateZSHCompletionScript).Bool()
return a
} | go | func New(name, help string) *Application {
a := &Application{
Name: name,
Help: help,
errorWriter: os.Stderr, // Left for backwards compatibility purposes.
usageWriter: os.Stderr,
usageTemplate: DefaultUsageTemplate,
terminate: os.Exit,
}
a.flagGroup = newFlagGroup()
a.argGroup = newArgGroup()
a.cmdGroup = newCmdGroup(a)
a.HelpFlag = a.Flag("help", "Show context-sensitive help (also try --help-long and --help-man).")
a.HelpFlag.Bool()
a.Flag("help-long", "Generate long help.").Hidden().PreAction(a.generateLongHelp).Bool()
a.Flag("help-man", "Generate a man page.").Hidden().PreAction(a.generateManPage).Bool()
a.Flag("completion-bash", "Output possible completions for the given args.").Hidden().BoolVar(&a.completion)
a.Flag("completion-script-bash", "Generate completion script for bash.").Hidden().PreAction(a.generateBashCompletionScript).Bool()
a.Flag("completion-script-zsh", "Generate completion script for ZSH.").Hidden().PreAction(a.generateZSHCompletionScript).Bool()
return a
} | [
"func",
"New",
"(",
"name",
",",
"help",
"string",
")",
"*",
"Application",
"{",
"a",
":=",
"&",
"Application",
"{",
"Name",
":",
"name",
",",
"Help",
":",
"help",
",",
"errorWriter",
":",
"os",
".",
"Stderr",
",",
"// Left for backwards compatibility purposes.",
"usageWriter",
":",
"os",
".",
"Stderr",
",",
"usageTemplate",
":",
"DefaultUsageTemplate",
",",
"terminate",
":",
"os",
".",
"Exit",
",",
"}",
"\n",
"a",
".",
"flagGroup",
"=",
"newFlagGroup",
"(",
")",
"\n",
"a",
".",
"argGroup",
"=",
"newArgGroup",
"(",
")",
"\n",
"a",
".",
"cmdGroup",
"=",
"newCmdGroup",
"(",
"a",
")",
"\n",
"a",
".",
"HelpFlag",
"=",
"a",
".",
"Flag",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"a",
".",
"HelpFlag",
".",
"Bool",
"(",
")",
"\n",
"a",
".",
"Flag",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
".",
"Hidden",
"(",
")",
".",
"PreAction",
"(",
"a",
".",
"generateLongHelp",
")",
".",
"Bool",
"(",
")",
"\n",
"a",
".",
"Flag",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
".",
"Hidden",
"(",
")",
".",
"PreAction",
"(",
"a",
".",
"generateManPage",
")",
".",
"Bool",
"(",
")",
"\n",
"a",
".",
"Flag",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
".",
"Hidden",
"(",
")",
".",
"BoolVar",
"(",
"&",
"a",
".",
"completion",
")",
"\n",
"a",
".",
"Flag",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
".",
"Hidden",
"(",
")",
".",
"PreAction",
"(",
"a",
".",
"generateBashCompletionScript",
")",
".",
"Bool",
"(",
")",
"\n",
"a",
".",
"Flag",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
".",
"Hidden",
"(",
")",
".",
"PreAction",
"(",
"a",
".",
"generateZSHCompletionScript",
")",
".",
"Bool",
"(",
")",
"\n\n",
"return",
"a",
"\n",
"}"
] | // New creates a new Kingpin application instance. | [
"New",
"creates",
"a",
"new",
"Kingpin",
"application",
"instance",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/app.go#L50-L71 |
148,042 | alecthomas/kingpin | app.go | ErrorWriter | func (a *Application) ErrorWriter(w io.Writer) *Application {
a.errorWriter = w
return a
} | go | func (a *Application) ErrorWriter(w io.Writer) *Application {
a.errorWriter = w
return a
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"ErrorWriter",
"(",
"w",
"io",
".",
"Writer",
")",
"*",
"Application",
"{",
"a",
".",
"errorWriter",
"=",
"w",
"\n",
"return",
"a",
"\n",
"}"
] | // ErrorWriter sets the io.Writer to use for errors. | [
"ErrorWriter",
"sets",
"the",
"io",
".",
"Writer",
"to",
"use",
"for",
"errors",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/app.go#L138-L141 |
148,043 | alecthomas/kingpin | app.go | UsageWriter | func (a *Application) UsageWriter(w io.Writer) *Application {
a.usageWriter = w
return a
} | go | func (a *Application) UsageWriter(w io.Writer) *Application {
a.usageWriter = w
return a
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"UsageWriter",
"(",
"w",
"io",
".",
"Writer",
")",
"*",
"Application",
"{",
"a",
".",
"usageWriter",
"=",
"w",
"\n",
"return",
"a",
"\n",
"}"
] | // UsageWriter sets the io.Writer to use for errors. | [
"UsageWriter",
"sets",
"the",
"io",
".",
"Writer",
"to",
"use",
"for",
"errors",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/app.go#L144-L147 |
148,044 | alecthomas/kingpin | app.go | UsageTemplate | func (a *Application) UsageTemplate(template string) *Application {
a.usageTemplate = template
return a
} | go | func (a *Application) UsageTemplate(template string) *Application {
a.usageTemplate = template
return a
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"UsageTemplate",
"(",
"template",
"string",
")",
"*",
"Application",
"{",
"a",
".",
"usageTemplate",
"=",
"template",
"\n",
"return",
"a",
"\n",
"}"
] | // UsageTemplate specifies the text template to use when displaying usage
// information. The default is UsageTemplate. | [
"UsageTemplate",
"specifies",
"the",
"text",
"template",
"to",
"use",
"when",
"displaying",
"usage",
"information",
".",
"The",
"default",
"is",
"UsageTemplate",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/app.go#L151-L154 |
148,045 | alecthomas/kingpin | app.go | ParseContext | func (a *Application) ParseContext(args []string) (*ParseContext, error) {
return a.parseContext(false, args)
} | go | func (a *Application) ParseContext(args []string) (*ParseContext, error) {
return a.parseContext(false, args)
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"ParseContext",
"(",
"args",
"[",
"]",
"string",
")",
"(",
"*",
"ParseContext",
",",
"error",
")",
"{",
"return",
"a",
".",
"parseContext",
"(",
"false",
",",
"args",
")",
"\n",
"}"
] | // ParseContext parses the given command line and returns the fully populated
// ParseContext. | [
"ParseContext",
"parses",
"the",
"given",
"command",
"line",
"and",
"returns",
"the",
"fully",
"populated",
"ParseContext",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/app.go#L164-L166 |
148,046 | alecthomas/kingpin | app.go | Parse | func (a *Application) Parse(args []string) (command string, err error) {
context, parseErr := a.ParseContext(args)
selected := []string{}
var setValuesErr error
if context == nil {
// Since we do not throw error immediately, there could be a case
// where a context returns nil. Protect against that.
return "", parseErr
}
if err = a.setDefaults(context); err != nil {
return "", err
}
selected, setValuesErr = a.setValues(context)
if err = a.applyPreActions(context, !a.completion); err != nil {
return "", err
}
if a.completion {
a.generateBashCompletion(context)
a.terminate(0)
} else {
if parseErr != nil {
return "", parseErr
}
a.maybeHelp(context)
if !context.EOL() {
return "", fmt.Errorf("unexpected argument '%s'", context.Peek())
}
if setValuesErr != nil {
return "", setValuesErr
}
command, err = a.execute(context, selected)
if err == ErrCommandNotSpecified {
a.writeUsage(context, nil)
}
}
return command, err
} | go | func (a *Application) Parse(args []string) (command string, err error) {
context, parseErr := a.ParseContext(args)
selected := []string{}
var setValuesErr error
if context == nil {
// Since we do not throw error immediately, there could be a case
// where a context returns nil. Protect against that.
return "", parseErr
}
if err = a.setDefaults(context); err != nil {
return "", err
}
selected, setValuesErr = a.setValues(context)
if err = a.applyPreActions(context, !a.completion); err != nil {
return "", err
}
if a.completion {
a.generateBashCompletion(context)
a.terminate(0)
} else {
if parseErr != nil {
return "", parseErr
}
a.maybeHelp(context)
if !context.EOL() {
return "", fmt.Errorf("unexpected argument '%s'", context.Peek())
}
if setValuesErr != nil {
return "", setValuesErr
}
command, err = a.execute(context, selected)
if err == ErrCommandNotSpecified {
a.writeUsage(context, nil)
}
}
return command, err
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"Parse",
"(",
"args",
"[",
"]",
"string",
")",
"(",
"command",
"string",
",",
"err",
"error",
")",
"{",
"context",
",",
"parseErr",
":=",
"a",
".",
"ParseContext",
"(",
"args",
")",
"\n",
"selected",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"var",
"setValuesErr",
"error",
"\n\n",
"if",
"context",
"==",
"nil",
"{",
"// Since we do not throw error immediately, there could be a case",
"// where a context returns nil. Protect against that.",
"return",
"\"",
"\"",
",",
"parseErr",
"\n",
"}",
"\n\n",
"if",
"err",
"=",
"a",
".",
"setDefaults",
"(",
"context",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"selected",
",",
"setValuesErr",
"=",
"a",
".",
"setValues",
"(",
"context",
")",
"\n\n",
"if",
"err",
"=",
"a",
".",
"applyPreActions",
"(",
"context",
",",
"!",
"a",
".",
"completion",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"a",
".",
"completion",
"{",
"a",
".",
"generateBashCompletion",
"(",
"context",
")",
"\n",
"a",
".",
"terminate",
"(",
"0",
")",
"\n",
"}",
"else",
"{",
"if",
"parseErr",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"parseErr",
"\n",
"}",
"\n\n",
"a",
".",
"maybeHelp",
"(",
"context",
")",
"\n",
"if",
"!",
"context",
".",
"EOL",
"(",
")",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"context",
".",
"Peek",
"(",
")",
")",
"\n",
"}",
"\n\n",
"if",
"setValuesErr",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"setValuesErr",
"\n",
"}",
"\n\n",
"command",
",",
"err",
"=",
"a",
".",
"execute",
"(",
"context",
",",
"selected",
")",
"\n",
"if",
"err",
"==",
"ErrCommandNotSpecified",
"{",
"a",
".",
"writeUsage",
"(",
"context",
",",
"nil",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"command",
",",
"err",
"\n",
"}"
] | // Parse parses command-line arguments. It returns the selected command and an
// error. The selected command will be a space separated subcommand, if
// subcommands have been configured.
//
// This will populate all flag and argument values, call all callbacks, and so
// on. | [
"Parse",
"parses",
"command",
"-",
"line",
"arguments",
".",
"It",
"returns",
"the",
"selected",
"command",
"and",
"an",
"error",
".",
"The",
"selected",
"command",
"will",
"be",
"a",
"space",
"separated",
"subcommand",
"if",
"subcommands",
"have",
"been",
"configured",
".",
"This",
"will",
"populate",
"all",
"flag",
"and",
"argument",
"values",
"call",
"all",
"callbacks",
"and",
"so",
"on",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/app.go#L183-L228 |
148,047 | alecthomas/kingpin | app.go | Author | func (a *Application) Author(author string) *Application {
a.author = author
return a
} | go | func (a *Application) Author(author string) *Application {
a.author = author
return a
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"Author",
"(",
"author",
"string",
")",
"*",
"Application",
"{",
"a",
".",
"author",
"=",
"author",
"\n",
"return",
"a",
"\n",
"}"
] | // Author sets the author output by some help templates. | [
"Author",
"sets",
"the",
"author",
"output",
"by",
"some",
"help",
"templates",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/app.go#L267-L270 |
148,048 | alecthomas/kingpin | app.go | PreAction | func (a *Application) PreAction(action Action) *Application {
a.addPreAction(action)
return a
} | go | func (a *Application) PreAction(action Action) *Application {
a.addPreAction(action)
return a
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"PreAction",
"(",
"action",
"Action",
")",
"*",
"Application",
"{",
"a",
".",
"addPreAction",
"(",
"action",
")",
"\n",
"return",
"a",
"\n",
"}"
] | // Action called after parsing completes but before validation and execution. | [
"Action",
"called",
"after",
"parsing",
"completes",
"but",
"before",
"validation",
"and",
"execution",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/app.go#L283-L286 |
148,049 | alecthomas/kingpin | app.go | Command | func (a *Application) Command(name, help string) *CmdClause {
return a.addCommand(name, help)
} | go | func (a *Application) Command(name, help string) *CmdClause {
return a.addCommand(name, help)
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"Command",
"(",
"name",
",",
"help",
"string",
")",
"*",
"CmdClause",
"{",
"return",
"a",
".",
"addCommand",
"(",
"name",
",",
"help",
")",
"\n",
"}"
] | // Command adds a new top-level command. | [
"Command",
"adds",
"a",
"new",
"top",
"-",
"level",
"command",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/app.go#L289-L291 |
148,050 | alecthomas/kingpin | app.go | checkDuplicateFlags | func checkDuplicateFlags(current *CmdClause, flagGroups []*flagGroup) error {
// Check for duplicates.
for _, flags := range flagGroups {
for _, flag := range current.flagOrder {
if flag.shorthand != 0 {
if _, ok := flags.short[string(flag.shorthand)]; ok {
return fmt.Errorf("duplicate short flag -%c", flag.shorthand)
}
}
if _, ok := flags.long[flag.name]; ok {
return fmt.Errorf("duplicate long flag --%s", flag.name)
}
}
}
flagGroups = append(flagGroups, current.flagGroup)
// Check subcommands.
for _, subcmd := range current.commandOrder {
if err := checkDuplicateFlags(subcmd, flagGroups); err != nil {
return err
}
}
return nil
} | go | func checkDuplicateFlags(current *CmdClause, flagGroups []*flagGroup) error {
// Check for duplicates.
for _, flags := range flagGroups {
for _, flag := range current.flagOrder {
if flag.shorthand != 0 {
if _, ok := flags.short[string(flag.shorthand)]; ok {
return fmt.Errorf("duplicate short flag -%c", flag.shorthand)
}
}
if _, ok := flags.long[flag.name]; ok {
return fmt.Errorf("duplicate long flag --%s", flag.name)
}
}
}
flagGroups = append(flagGroups, current.flagGroup)
// Check subcommands.
for _, subcmd := range current.commandOrder {
if err := checkDuplicateFlags(subcmd, flagGroups); err != nil {
return err
}
}
return nil
} | [
"func",
"checkDuplicateFlags",
"(",
"current",
"*",
"CmdClause",
",",
"flagGroups",
"[",
"]",
"*",
"flagGroup",
")",
"error",
"{",
"// Check for duplicates.",
"for",
"_",
",",
"flags",
":=",
"range",
"flagGroups",
"{",
"for",
"_",
",",
"flag",
":=",
"range",
"current",
".",
"flagOrder",
"{",
"if",
"flag",
".",
"shorthand",
"!=",
"0",
"{",
"if",
"_",
",",
"ok",
":=",
"flags",
".",
"short",
"[",
"string",
"(",
"flag",
".",
"shorthand",
")",
"]",
";",
"ok",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"flag",
".",
"shorthand",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"_",
",",
"ok",
":=",
"flags",
".",
"long",
"[",
"flag",
".",
"name",
"]",
";",
"ok",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"flag",
".",
"name",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"flagGroups",
"=",
"append",
"(",
"flagGroups",
",",
"current",
".",
"flagGroup",
")",
"\n",
"// Check subcommands.",
"for",
"_",
",",
"subcmd",
":=",
"range",
"current",
".",
"commandOrder",
"{",
"if",
"err",
":=",
"checkDuplicateFlags",
"(",
"subcmd",
",",
"flagGroups",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Recursively check commands for duplicate flags. | [
"Recursively",
"check",
"commands",
"for",
"duplicate",
"flags",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/app.go#L355-L377 |
148,051 | alecthomas/kingpin | app.go | Fatalf | func (a *Application) Fatalf(format string, args ...interface{}) {
a.Errorf(format, args...)
a.terminate(1)
} | go | func (a *Application) Fatalf(format string, args ...interface{}) {
a.Errorf(format, args...)
a.terminate(1)
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"Fatalf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"a",
".",
"Errorf",
"(",
"format",
",",
"args",
"...",
")",
"\n",
"a",
".",
"terminate",
"(",
"1",
")",
"\n",
"}"
] | // Fatalf writes a formatted error to w then terminates with exit status 1. | [
"Fatalf",
"writes",
"a",
"formatted",
"error",
"to",
"w",
"then",
"terminates",
"with",
"exit",
"status",
"1",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/app.go#L571-L574 |
148,052 | alecthomas/kingpin | app.go | FatalUsage | func (a *Application) FatalUsage(format string, args ...interface{}) {
a.Errorf(format, args...)
// Force usage to go to error output.
a.usageWriter = a.errorWriter
a.Usage([]string{})
a.terminate(1)
} | go | func (a *Application) FatalUsage(format string, args ...interface{}) {
a.Errorf(format, args...)
// Force usage to go to error output.
a.usageWriter = a.errorWriter
a.Usage([]string{})
a.terminate(1)
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"FatalUsage",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"a",
".",
"Errorf",
"(",
"format",
",",
"args",
"...",
")",
"\n",
"// Force usage to go to error output.",
"a",
".",
"usageWriter",
"=",
"a",
".",
"errorWriter",
"\n",
"a",
".",
"Usage",
"(",
"[",
"]",
"string",
"{",
"}",
")",
"\n",
"a",
".",
"terminate",
"(",
"1",
")",
"\n",
"}"
] | // FatalUsage prints an error message followed by usage information, then
// exits with a non-zero status. | [
"FatalUsage",
"prints",
"an",
"error",
"message",
"followed",
"by",
"usage",
"information",
"then",
"exits",
"with",
"a",
"non",
"-",
"zero",
"status",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/app.go#L578-L584 |
148,053 | alecthomas/kingpin | app.go | FatalUsageContext | func (a *Application) FatalUsageContext(context *ParseContext, format string, args ...interface{}) {
a.Errorf(format, args...)
if err := a.UsageForContext(context); err != nil {
panic(err)
}
a.terminate(1)
} | go | func (a *Application) FatalUsageContext(context *ParseContext, format string, args ...interface{}) {
a.Errorf(format, args...)
if err := a.UsageForContext(context); err != nil {
panic(err)
}
a.terminate(1)
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"FatalUsageContext",
"(",
"context",
"*",
"ParseContext",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"a",
".",
"Errorf",
"(",
"format",
",",
"args",
"...",
")",
"\n",
"if",
"err",
":=",
"a",
".",
"UsageForContext",
"(",
"context",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"a",
".",
"terminate",
"(",
"1",
")",
"\n",
"}"
] | // FatalUsageContext writes a printf formatted error message to w, then usage
// information for the given ParseContext, before exiting. | [
"FatalUsageContext",
"writes",
"a",
"printf",
"formatted",
"error",
"message",
"to",
"w",
"then",
"usage",
"information",
"for",
"the",
"given",
"ParseContext",
"before",
"exiting",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/app.go#L588-L594 |
148,054 | alecthomas/kingpin | app.go | FatalIfError | func (a *Application) FatalIfError(err error, format string, args ...interface{}) {
if err != nil {
prefix := ""
if format != "" {
prefix = fmt.Sprintf(format, args...) + ": "
}
a.Errorf(prefix+"%s", err)
a.terminate(1)
}
} | go | func (a *Application) FatalIfError(err error, format string, args ...interface{}) {
if err != nil {
prefix := ""
if format != "" {
prefix = fmt.Sprintf(format, args...) + ": "
}
a.Errorf(prefix+"%s", err)
a.terminate(1)
}
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"FatalIfError",
"(",
"err",
"error",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"prefix",
":=",
"\"",
"\"",
"\n",
"if",
"format",
"!=",
"\"",
"\"",
"{",
"prefix",
"=",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
"+",
"\"",
"\"",
"\n",
"}",
"\n",
"a",
".",
"Errorf",
"(",
"prefix",
"+",
"\"",
"\"",
",",
"err",
")",
"\n",
"a",
".",
"terminate",
"(",
"1",
")",
"\n",
"}",
"\n",
"}"
] | // FatalIfError prints an error and exits if err is not nil. The error is printed
// with the given formatted string, if any. | [
"FatalIfError",
"prints",
"an",
"error",
"and",
"exits",
"if",
"err",
"is",
"not",
"nil",
".",
"The",
"error",
"is",
"printed",
"with",
"the",
"given",
"formatted",
"string",
"if",
"any",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/app.go#L598-L607 |
148,055 | alecthomas/kingpin | flags.go | Flag | func (f *flagGroup) Flag(name, help string) *FlagClause {
flag := newFlag(name, help)
f.long[name] = flag
f.flagOrder = append(f.flagOrder, flag)
return flag
} | go | func (f *flagGroup) Flag(name, help string) *FlagClause {
flag := newFlag(name, help)
f.long[name] = flag
f.flagOrder = append(f.flagOrder, flag)
return flag
} | [
"func",
"(",
"f",
"*",
"flagGroup",
")",
"Flag",
"(",
"name",
",",
"help",
"string",
")",
"*",
"FlagClause",
"{",
"flag",
":=",
"newFlag",
"(",
"name",
",",
"help",
")",
"\n",
"f",
".",
"long",
"[",
"name",
"]",
"=",
"flag",
"\n",
"f",
".",
"flagOrder",
"=",
"append",
"(",
"f",
".",
"flagOrder",
",",
"flag",
")",
"\n",
"return",
"flag",
"\n",
"}"
] | // Flag defines a new flag with the given long name and help. | [
"Flag",
"defines",
"a",
"new",
"flag",
"with",
"the",
"given",
"long",
"name",
"and",
"help",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/flags.go#L30-L35 |
148,056 | alecthomas/kingpin | flags.go | Action | func (f *FlagClause) Action(action Action) *FlagClause {
f.addAction(action)
return f
} | go | func (f *FlagClause) Action(action Action) *FlagClause {
f.addAction(action)
return f
} | [
"func",
"(",
"f",
"*",
"FlagClause",
")",
"Action",
"(",
"action",
"Action",
")",
"*",
"FlagClause",
"{",
"f",
".",
"addAction",
"(",
"action",
")",
"\n",
"return",
"f",
"\n",
"}"
] | // Dispatch to the given function after the flag is parsed and validated. | [
"Dispatch",
"to",
"the",
"given",
"function",
"after",
"the",
"flag",
"is",
"parsed",
"and",
"validated",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/flags.go#L220-L223 |
148,057 | alecthomas/kingpin | flags.go | IsSetByUser | func (f *FlagClause) IsSetByUser(setByUser *bool) *FlagClause {
if setByUser != nil {
*setByUser = false
}
f.setByUser = setByUser
return f
} | go | func (f *FlagClause) IsSetByUser(setByUser *bool) *FlagClause {
if setByUser != nil {
*setByUser = false
}
f.setByUser = setByUser
return f
} | [
"func",
"(",
"f",
"*",
"FlagClause",
")",
"IsSetByUser",
"(",
"setByUser",
"*",
"bool",
")",
"*",
"FlagClause",
"{",
"if",
"setByUser",
"!=",
"nil",
"{",
"*",
"setByUser",
"=",
"false",
"\n",
"}",
"\n",
"f",
".",
"setByUser",
"=",
"setByUser",
"\n",
"return",
"f",
"\n",
"}"
] | // IsSetByUser let to know if the flag was set by the user | [
"IsSetByUser",
"let",
"to",
"know",
"if",
"the",
"flag",
"was",
"set",
"by",
"the",
"user"
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/flags.go#L259-L265 |
148,058 | alecthomas/kingpin | flags.go | Short | func (f *FlagClause) Short(name rune) *FlagClause {
f.shorthand = name
return f
} | go | func (f *FlagClause) Short(name rune) *FlagClause {
f.shorthand = name
return f
} | [
"func",
"(",
"f",
"*",
"FlagClause",
")",
"Short",
"(",
"name",
"rune",
")",
"*",
"FlagClause",
"{",
"f",
".",
"shorthand",
"=",
"name",
"\n",
"return",
"f",
"\n",
"}"
] | // Short sets the short flag name. | [
"Short",
"sets",
"the",
"short",
"flag",
"name",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/flags.go#L316-L319 |
148,059 | alecthomas/kingpin | flags.go | Bool | func (f *FlagClause) Bool() (target *bool) {
target = new(bool)
f.SetValue(newBoolValue(target))
return
} | go | func (f *FlagClause) Bool() (target *bool) {
target = new(bool)
f.SetValue(newBoolValue(target))
return
} | [
"func",
"(",
"f",
"*",
"FlagClause",
")",
"Bool",
"(",
")",
"(",
"target",
"*",
"bool",
")",
"{",
"target",
"=",
"new",
"(",
"bool",
")",
"\n",
"f",
".",
"SetValue",
"(",
"newBoolValue",
"(",
"target",
")",
")",
"\n",
"return",
"\n",
"}"
] | // Bool makes this flag a boolean flag. | [
"Bool",
"makes",
"this",
"flag",
"a",
"boolean",
"flag",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/flags.go#L322-L326 |
148,060 | alecthomas/kingpin | parsers.go | Bytes | func (p *parserMixin) Bytes() (target *units.Base2Bytes) {
target = new(units.Base2Bytes)
p.BytesVar(target)
return
} | go | func (p *parserMixin) Bytes() (target *units.Base2Bytes) {
target = new(units.Base2Bytes)
p.BytesVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Bytes",
"(",
")",
"(",
"target",
"*",
"units",
".",
"Base2Bytes",
")",
"{",
"target",
"=",
"new",
"(",
"units",
".",
"Base2Bytes",
")",
"\n",
"p",
".",
"BytesVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Bytes parses numeric byte units. eg. 1.5KB | [
"Bytes",
"parses",
"numeric",
"byte",
"units",
".",
"eg",
".",
"1",
".",
"5KB"
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/parsers.go#L40-L44 |
148,061 | alecthomas/kingpin | parsers.go | ExistingFile | func (p *parserMixin) ExistingFile() (target *string) {
target = new(string)
p.ExistingFileVar(target)
return
} | go | func (p *parserMixin) ExistingFile() (target *string) {
target = new(string)
p.ExistingFileVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"ExistingFile",
"(",
")",
"(",
"target",
"*",
"string",
")",
"{",
"target",
"=",
"new",
"(",
"string",
")",
"\n",
"p",
".",
"ExistingFileVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // ExistingFile sets the parser to one that requires and returns an existing file. | [
"ExistingFile",
"sets",
"the",
"parser",
"to",
"one",
"that",
"requires",
"and",
"returns",
"an",
"existing",
"file",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/parsers.go#L66-L70 |
148,062 | alecthomas/kingpin | parsers.go | ExistingDir | func (p *parserMixin) ExistingDir() (target *string) {
target = new(string)
p.ExistingDirVar(target)
return
} | go | func (p *parserMixin) ExistingDir() (target *string) {
target = new(string)
p.ExistingDirVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"ExistingDir",
"(",
")",
"(",
"target",
"*",
"string",
")",
"{",
"target",
"=",
"new",
"(",
"string",
")",
"\n",
"p",
".",
"ExistingDirVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // ExistingDir sets the parser to one that requires and returns an existing directory. | [
"ExistingDir",
"sets",
"the",
"parser",
"to",
"one",
"that",
"requires",
"and",
"returns",
"an",
"existing",
"directory",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/parsers.go#L73-L77 |
148,063 | alecthomas/kingpin | parsers.go | ExistingFileOrDir | func (p *parserMixin) ExistingFileOrDir() (target *string) {
target = new(string)
p.ExistingFileOrDirVar(target)
return
} | go | func (p *parserMixin) ExistingFileOrDir() (target *string) {
target = new(string)
p.ExistingFileOrDirVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"ExistingFileOrDir",
"(",
")",
"(",
"target",
"*",
"string",
")",
"{",
"target",
"=",
"new",
"(",
"string",
")",
"\n",
"p",
".",
"ExistingFileOrDirVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // ExistingFileOrDir sets the parser to one that requires and returns an existing file OR directory. | [
"ExistingFileOrDir",
"sets",
"the",
"parser",
"to",
"one",
"that",
"requires",
"and",
"returns",
"an",
"existing",
"file",
"OR",
"directory",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/parsers.go#L80-L84 |
148,064 | alecthomas/kingpin | parsers.go | File | func (p *parserMixin) File() (target **os.File) {
target = new(*os.File)
p.FileVar(target)
return
} | go | func (p *parserMixin) File() (target **os.File) {
target = new(*os.File)
p.FileVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"File",
"(",
")",
"(",
"target",
"*",
"*",
"os",
".",
"File",
")",
"{",
"target",
"=",
"new",
"(",
"*",
"os",
".",
"File",
")",
"\n",
"p",
".",
"FileVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // File returns an os.File against an existing file. | [
"File",
"returns",
"an",
"os",
".",
"File",
"against",
"an",
"existing",
"file",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/parsers.go#L87-L91 |
148,065 | alecthomas/kingpin | parsers.go | BytesVar | func (p *parserMixin) BytesVar(target *units.Base2Bytes) {
p.SetValue(newBytesValue(target))
} | go | func (p *parserMixin) BytesVar(target *units.Base2Bytes) {
p.SetValue(newBytesValue(target))
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"BytesVar",
"(",
"target",
"*",
"units",
".",
"Base2Bytes",
")",
"{",
"p",
".",
"SetValue",
"(",
"newBytesValue",
"(",
"target",
")",
")",
"\n",
"}"
] | // BytesVar parses numeric byte units. eg. 1.5KB | [
"BytesVar",
"parses",
"numeric",
"byte",
"units",
".",
"eg",
".",
"1",
".",
"5KB"
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/parsers.go#L128-L130 |
148,066 | alecthomas/kingpin | parsers.go | FileVar | func (p *parserMixin) FileVar(target **os.File) {
p.SetValue(newFileValue(target, os.O_RDONLY, 0))
} | go | func (p *parserMixin) FileVar(target **os.File) {
p.SetValue(newFileValue(target, os.O_RDONLY, 0))
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"FileVar",
"(",
"target",
"*",
"*",
"os",
".",
"File",
")",
"{",
"p",
".",
"SetValue",
"(",
"newFileValue",
"(",
"target",
",",
"os",
".",
"O_RDONLY",
",",
"0",
")",
")",
"\n",
"}"
] | // FileVar opens an existing file. | [
"FileVar",
"opens",
"an",
"existing",
"file",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/parsers.go#L153-L155 |
148,067 | alecthomas/kingpin | parsers.go | URLList | func (p *parserMixin) URLList() (target *[]*url.URL) {
target = new([]*url.URL)
p.URLListVar(target)
return
} | go | func (p *parserMixin) URLList() (target *[]*url.URL) {
target = new([]*url.URL)
p.URLListVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"URLList",
"(",
")",
"(",
"target",
"*",
"[",
"]",
"*",
"url",
".",
"URL",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"*",
"url",
".",
"URL",
")",
"\n",
"p",
".",
"URLListVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // URLList provides a parsed list of url.URL values. | [
"URLList",
"provides",
"a",
"parsed",
"list",
"of",
"url",
".",
"URL",
"values",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/parsers.go#L168-L172 |
148,068 | alecthomas/kingpin | parsers.go | URLListVar | func (p *parserMixin) URLListVar(target *[]*url.URL) {
p.SetValue(newURLListValue(target))
} | go | func (p *parserMixin) URLListVar(target *[]*url.URL) {
p.SetValue(newURLListValue(target))
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"URLListVar",
"(",
"target",
"*",
"[",
"]",
"*",
"url",
".",
"URL",
")",
"{",
"p",
".",
"SetValue",
"(",
"newURLListValue",
"(",
"target",
")",
")",
"\n",
"}"
] | // URLListVar provides a parsed list of url.URL values. | [
"URLListVar",
"provides",
"a",
"parsed",
"list",
"of",
"url",
".",
"URL",
"values",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/parsers.go#L175-L177 |
148,069 | alecthomas/kingpin | parsers.go | Enum | func (p *parserMixin) Enum(options ...string) (target *string) {
target = new(string)
p.EnumVar(target, options...)
return
} | go | func (p *parserMixin) Enum(options ...string) (target *string) {
target = new(string)
p.EnumVar(target, options...)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Enum",
"(",
"options",
"...",
"string",
")",
"(",
"target",
"*",
"string",
")",
"{",
"target",
"=",
"new",
"(",
"string",
")",
"\n",
"p",
".",
"EnumVar",
"(",
"target",
",",
"options",
"...",
")",
"\n",
"return",
"\n",
"}"
] | // Enum allows a value from a set of options. | [
"Enum",
"allows",
"a",
"value",
"from",
"a",
"set",
"of",
"options",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/parsers.go#L180-L184 |
148,070 | alecthomas/kingpin | parsers.go | Enums | func (p *parserMixin) Enums(options ...string) (target *[]string) {
target = new([]string)
p.EnumsVar(target, options...)
return
} | go | func (p *parserMixin) Enums(options ...string) (target *[]string) {
target = new([]string)
p.EnumsVar(target, options...)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Enums",
"(",
"options",
"...",
"string",
")",
"(",
"target",
"*",
"[",
"]",
"string",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"string",
")",
"\n",
"p",
".",
"EnumsVar",
"(",
"target",
",",
"options",
"...",
")",
"\n",
"return",
"\n",
"}"
] | // Enums allows a set of values from a set of options. | [
"Enums",
"allows",
"a",
"set",
"of",
"values",
"from",
"a",
"set",
"of",
"options",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/parsers.go#L192-L196 |
148,071 | alecthomas/kingpin | parsers.go | Counter | func (p *parserMixin) Counter() (target *int) {
target = new(int)
p.CounterVar(target)
return
} | go | func (p *parserMixin) Counter() (target *int) {
target = new(int)
p.CounterVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Counter",
"(",
")",
"(",
"target",
"*",
"int",
")",
"{",
"target",
"=",
"new",
"(",
"int",
")",
"\n",
"p",
".",
"CounterVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // A Counter increments a number each time it is encountered. | [
"A",
"Counter",
"increments",
"a",
"number",
"each",
"time",
"it",
"is",
"encountered",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/parsers.go#L204-L208 |
148,072 | alecthomas/kingpin | values_generated.go | Bool | func (p *parserMixin) Bool() (target *bool) {
target = new(bool)
p.BoolVar(target)
return
} | go | func (p *parserMixin) Bool() (target *bool) {
target = new(bool)
p.BoolVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Bool",
"(",
")",
"(",
"target",
"*",
"bool",
")",
"{",
"target",
"=",
"new",
"(",
"bool",
")",
"\n",
"p",
".",
"BoolVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Bool parses the next command-line value as bool. | [
"Bool",
"parses",
"the",
"next",
"command",
"-",
"line",
"value",
"as",
"bool",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L34-L38 |
148,073 | alecthomas/kingpin | values_generated.go | BoolList | func (p *parserMixin) BoolList() (target *[]bool) {
target = new([]bool)
p.BoolListVar(target)
return
} | go | func (p *parserMixin) BoolList() (target *[]bool) {
target = new([]bool)
p.BoolListVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"BoolList",
"(",
")",
"(",
"target",
"*",
"[",
"]",
"bool",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"bool",
")",
"\n",
"p",
".",
"BoolListVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // BoolList accumulates bool values into a slice. | [
"BoolList",
"accumulates",
"bool",
"values",
"into",
"a",
"slice",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L45-L49 |
148,074 | alecthomas/kingpin | values_generated.go | String | func (p *parserMixin) String() (target *string) {
target = new(string)
p.StringVar(target)
return
} | go | func (p *parserMixin) String() (target *string) {
target = new(string)
p.StringVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"String",
"(",
")",
"(",
"target",
"*",
"string",
")",
"{",
"target",
"=",
"new",
"(",
"string",
")",
"\n",
"p",
".",
"StringVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // String parses the next command-line value as string. | [
"String",
"parses",
"the",
"next",
"command",
"-",
"line",
"value",
"as",
"string",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L77-L81 |
148,075 | alecthomas/kingpin | values_generated.go | Strings | func (p *parserMixin) Strings() (target *[]string) {
target = new([]string)
p.StringsVar(target)
return
} | go | func (p *parserMixin) Strings() (target *[]string) {
target = new([]string)
p.StringsVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Strings",
"(",
")",
"(",
"target",
"*",
"[",
"]",
"string",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"string",
")",
"\n",
"p",
".",
"StringsVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Strings accumulates string values into a slice. | [
"Strings",
"accumulates",
"string",
"values",
"into",
"a",
"slice",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L88-L92 |
148,076 | alecthomas/kingpin | values_generated.go | Uint | func (p *parserMixin) Uint() (target *uint) {
target = new(uint)
p.UintVar(target)
return
} | go | func (p *parserMixin) Uint() (target *uint) {
target = new(uint)
p.UintVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Uint",
"(",
")",
"(",
"target",
"*",
"uint",
")",
"{",
"target",
"=",
"new",
"(",
"uint",
")",
"\n",
"p",
".",
"UintVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Uint parses the next command-line value as uint. | [
"Uint",
"parses",
"the",
"next",
"command",
"-",
"line",
"value",
"as",
"uint",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L120-L124 |
148,077 | alecthomas/kingpin | values_generated.go | Uints | func (p *parserMixin) Uints() (target *[]uint) {
target = new([]uint)
p.UintsVar(target)
return
} | go | func (p *parserMixin) Uints() (target *[]uint) {
target = new([]uint)
p.UintsVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Uints",
"(",
")",
"(",
"target",
"*",
"[",
"]",
"uint",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"uint",
")",
"\n",
"p",
".",
"UintsVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Uints accumulates uint values into a slice. | [
"Uints",
"accumulates",
"uint",
"values",
"into",
"a",
"slice",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L131-L135 |
148,078 | alecthomas/kingpin | values_generated.go | Uint8 | func (p *parserMixin) Uint8() (target *uint8) {
target = new(uint8)
p.Uint8Var(target)
return
} | go | func (p *parserMixin) Uint8() (target *uint8) {
target = new(uint8)
p.Uint8Var(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Uint8",
"(",
")",
"(",
"target",
"*",
"uint8",
")",
"{",
"target",
"=",
"new",
"(",
"uint8",
")",
"\n",
"p",
".",
"Uint8Var",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Uint8 parses the next command-line value as uint8. | [
"Uint8",
"parses",
"the",
"next",
"command",
"-",
"line",
"value",
"as",
"uint8",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L163-L167 |
148,079 | alecthomas/kingpin | values_generated.go | Uint8List | func (p *parserMixin) Uint8List() (target *[]uint8) {
target = new([]uint8)
p.Uint8ListVar(target)
return
} | go | func (p *parserMixin) Uint8List() (target *[]uint8) {
target = new([]uint8)
p.Uint8ListVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Uint8List",
"(",
")",
"(",
"target",
"*",
"[",
"]",
"uint8",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"uint8",
")",
"\n",
"p",
".",
"Uint8ListVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Uint8List accumulates uint8 values into a slice. | [
"Uint8List",
"accumulates",
"uint8",
"values",
"into",
"a",
"slice",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L174-L178 |
148,080 | alecthomas/kingpin | values_generated.go | Uint16 | func (p *parserMixin) Uint16() (target *uint16) {
target = new(uint16)
p.Uint16Var(target)
return
} | go | func (p *parserMixin) Uint16() (target *uint16) {
target = new(uint16)
p.Uint16Var(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Uint16",
"(",
")",
"(",
"target",
"*",
"uint16",
")",
"{",
"target",
"=",
"new",
"(",
"uint16",
")",
"\n",
"p",
".",
"Uint16Var",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Uint16 parses the next command-line value as uint16. | [
"Uint16",
"parses",
"the",
"next",
"command",
"-",
"line",
"value",
"as",
"uint16",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L206-L210 |
148,081 | alecthomas/kingpin | values_generated.go | Uint16List | func (p *parserMixin) Uint16List() (target *[]uint16) {
target = new([]uint16)
p.Uint16ListVar(target)
return
} | go | func (p *parserMixin) Uint16List() (target *[]uint16) {
target = new([]uint16)
p.Uint16ListVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Uint16List",
"(",
")",
"(",
"target",
"*",
"[",
"]",
"uint16",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"uint16",
")",
"\n",
"p",
".",
"Uint16ListVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Uint16List accumulates uint16 values into a slice. | [
"Uint16List",
"accumulates",
"uint16",
"values",
"into",
"a",
"slice",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L217-L221 |
148,082 | alecthomas/kingpin | values_generated.go | Uint32 | func (p *parserMixin) Uint32() (target *uint32) {
target = new(uint32)
p.Uint32Var(target)
return
} | go | func (p *parserMixin) Uint32() (target *uint32) {
target = new(uint32)
p.Uint32Var(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Uint32",
"(",
")",
"(",
"target",
"*",
"uint32",
")",
"{",
"target",
"=",
"new",
"(",
"uint32",
")",
"\n",
"p",
".",
"Uint32Var",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Uint32 parses the next command-line value as uint32. | [
"Uint32",
"parses",
"the",
"next",
"command",
"-",
"line",
"value",
"as",
"uint32",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L249-L253 |
148,083 | alecthomas/kingpin | values_generated.go | Uint32List | func (p *parserMixin) Uint32List() (target *[]uint32) {
target = new([]uint32)
p.Uint32ListVar(target)
return
} | go | func (p *parserMixin) Uint32List() (target *[]uint32) {
target = new([]uint32)
p.Uint32ListVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Uint32List",
"(",
")",
"(",
"target",
"*",
"[",
"]",
"uint32",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"uint32",
")",
"\n",
"p",
".",
"Uint32ListVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Uint32List accumulates uint32 values into a slice. | [
"Uint32List",
"accumulates",
"uint32",
"values",
"into",
"a",
"slice",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L260-L264 |
148,084 | alecthomas/kingpin | values_generated.go | Uint64 | func (p *parserMixin) Uint64() (target *uint64) {
target = new(uint64)
p.Uint64Var(target)
return
} | go | func (p *parserMixin) Uint64() (target *uint64) {
target = new(uint64)
p.Uint64Var(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Uint64",
"(",
")",
"(",
"target",
"*",
"uint64",
")",
"{",
"target",
"=",
"new",
"(",
"uint64",
")",
"\n",
"p",
".",
"Uint64Var",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Uint64 parses the next command-line value as uint64. | [
"Uint64",
"parses",
"the",
"next",
"command",
"-",
"line",
"value",
"as",
"uint64",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L292-L296 |
148,085 | alecthomas/kingpin | values_generated.go | Uint64List | func (p *parserMixin) Uint64List() (target *[]uint64) {
target = new([]uint64)
p.Uint64ListVar(target)
return
} | go | func (p *parserMixin) Uint64List() (target *[]uint64) {
target = new([]uint64)
p.Uint64ListVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Uint64List",
"(",
")",
"(",
"target",
"*",
"[",
"]",
"uint64",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"uint64",
")",
"\n",
"p",
".",
"Uint64ListVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Uint64List accumulates uint64 values into a slice. | [
"Uint64List",
"accumulates",
"uint64",
"values",
"into",
"a",
"slice",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L303-L307 |
148,086 | alecthomas/kingpin | values_generated.go | Int | func (p *parserMixin) Int() (target *int) {
target = new(int)
p.IntVar(target)
return
} | go | func (p *parserMixin) Int() (target *int) {
target = new(int)
p.IntVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Int",
"(",
")",
"(",
"target",
"*",
"int",
")",
"{",
"target",
"=",
"new",
"(",
"int",
")",
"\n",
"p",
".",
"IntVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Int parses the next command-line value as int. | [
"Int",
"parses",
"the",
"next",
"command",
"-",
"line",
"value",
"as",
"int",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L335-L339 |
148,087 | alecthomas/kingpin | values_generated.go | Ints | func (p *parserMixin) Ints() (target *[]int) {
target = new([]int)
p.IntsVar(target)
return
} | go | func (p *parserMixin) Ints() (target *[]int) {
target = new([]int)
p.IntsVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Ints",
"(",
")",
"(",
"target",
"*",
"[",
"]",
"int",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"int",
")",
"\n",
"p",
".",
"IntsVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Ints accumulates int values into a slice. | [
"Ints",
"accumulates",
"int",
"values",
"into",
"a",
"slice",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L346-L350 |
148,088 | alecthomas/kingpin | values_generated.go | Int8 | func (p *parserMixin) Int8() (target *int8) {
target = new(int8)
p.Int8Var(target)
return
} | go | func (p *parserMixin) Int8() (target *int8) {
target = new(int8)
p.Int8Var(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Int8",
"(",
")",
"(",
"target",
"*",
"int8",
")",
"{",
"target",
"=",
"new",
"(",
"int8",
")",
"\n",
"p",
".",
"Int8Var",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Int8 parses the next command-line value as int8. | [
"Int8",
"parses",
"the",
"next",
"command",
"-",
"line",
"value",
"as",
"int8",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L378-L382 |
148,089 | alecthomas/kingpin | values_generated.go | Int8List | func (p *parserMixin) Int8List() (target *[]int8) {
target = new([]int8)
p.Int8ListVar(target)
return
} | go | func (p *parserMixin) Int8List() (target *[]int8) {
target = new([]int8)
p.Int8ListVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Int8List",
"(",
")",
"(",
"target",
"*",
"[",
"]",
"int8",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"int8",
")",
"\n",
"p",
".",
"Int8ListVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Int8List accumulates int8 values into a slice. | [
"Int8List",
"accumulates",
"int8",
"values",
"into",
"a",
"slice",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L389-L393 |
148,090 | alecthomas/kingpin | values_generated.go | Int16 | func (p *parserMixin) Int16() (target *int16) {
target = new(int16)
p.Int16Var(target)
return
} | go | func (p *parserMixin) Int16() (target *int16) {
target = new(int16)
p.Int16Var(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Int16",
"(",
")",
"(",
"target",
"*",
"int16",
")",
"{",
"target",
"=",
"new",
"(",
"int16",
")",
"\n",
"p",
".",
"Int16Var",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Int16 parses the next command-line value as int16. | [
"Int16",
"parses",
"the",
"next",
"command",
"-",
"line",
"value",
"as",
"int16",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L421-L425 |
148,091 | alecthomas/kingpin | values_generated.go | Int16List | func (p *parserMixin) Int16List() (target *[]int16) {
target = new([]int16)
p.Int16ListVar(target)
return
} | go | func (p *parserMixin) Int16List() (target *[]int16) {
target = new([]int16)
p.Int16ListVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Int16List",
"(",
")",
"(",
"target",
"*",
"[",
"]",
"int16",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"int16",
")",
"\n",
"p",
".",
"Int16ListVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Int16List accumulates int16 values into a slice. | [
"Int16List",
"accumulates",
"int16",
"values",
"into",
"a",
"slice",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L432-L436 |
148,092 | alecthomas/kingpin | values_generated.go | Int32 | func (p *parserMixin) Int32() (target *int32) {
target = new(int32)
p.Int32Var(target)
return
} | go | func (p *parserMixin) Int32() (target *int32) {
target = new(int32)
p.Int32Var(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Int32",
"(",
")",
"(",
"target",
"*",
"int32",
")",
"{",
"target",
"=",
"new",
"(",
"int32",
")",
"\n",
"p",
".",
"Int32Var",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Int32 parses the next command-line value as int32. | [
"Int32",
"parses",
"the",
"next",
"command",
"-",
"line",
"value",
"as",
"int32",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L464-L468 |
148,093 | alecthomas/kingpin | values_generated.go | Int32List | func (p *parserMixin) Int32List() (target *[]int32) {
target = new([]int32)
p.Int32ListVar(target)
return
} | go | func (p *parserMixin) Int32List() (target *[]int32) {
target = new([]int32)
p.Int32ListVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Int32List",
"(",
")",
"(",
"target",
"*",
"[",
"]",
"int32",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"int32",
")",
"\n",
"p",
".",
"Int32ListVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Int32List accumulates int32 values into a slice. | [
"Int32List",
"accumulates",
"int32",
"values",
"into",
"a",
"slice",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L475-L479 |
148,094 | alecthomas/kingpin | values_generated.go | Int64 | func (p *parserMixin) Int64() (target *int64) {
target = new(int64)
p.Int64Var(target)
return
} | go | func (p *parserMixin) Int64() (target *int64) {
target = new(int64)
p.Int64Var(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Int64",
"(",
")",
"(",
"target",
"*",
"int64",
")",
"{",
"target",
"=",
"new",
"(",
"int64",
")",
"\n",
"p",
".",
"Int64Var",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Int64 parses the next command-line value as int64. | [
"Int64",
"parses",
"the",
"next",
"command",
"-",
"line",
"value",
"as",
"int64",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L507-L511 |
148,095 | alecthomas/kingpin | values_generated.go | Int64List | func (p *parserMixin) Int64List() (target *[]int64) {
target = new([]int64)
p.Int64ListVar(target)
return
} | go | func (p *parserMixin) Int64List() (target *[]int64) {
target = new([]int64)
p.Int64ListVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Int64List",
"(",
")",
"(",
"target",
"*",
"[",
"]",
"int64",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"int64",
")",
"\n",
"p",
".",
"Int64ListVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Int64List accumulates int64 values into a slice. | [
"Int64List",
"accumulates",
"int64",
"values",
"into",
"a",
"slice",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L518-L522 |
148,096 | alecthomas/kingpin | values_generated.go | Float64 | func (p *parserMixin) Float64() (target *float64) {
target = new(float64)
p.Float64Var(target)
return
} | go | func (p *parserMixin) Float64() (target *float64) {
target = new(float64)
p.Float64Var(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Float64",
"(",
")",
"(",
"target",
"*",
"float64",
")",
"{",
"target",
"=",
"new",
"(",
"float64",
")",
"\n",
"p",
".",
"Float64Var",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Float64 parses the next command-line value as float64. | [
"Float64",
"parses",
"the",
"next",
"command",
"-",
"line",
"value",
"as",
"float64",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L550-L554 |
148,097 | alecthomas/kingpin | values_generated.go | Float64List | func (p *parserMixin) Float64List() (target *[]float64) {
target = new([]float64)
p.Float64ListVar(target)
return
} | go | func (p *parserMixin) Float64List() (target *[]float64) {
target = new([]float64)
p.Float64ListVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Float64List",
"(",
")",
"(",
"target",
"*",
"[",
"]",
"float64",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"float64",
")",
"\n",
"p",
".",
"Float64ListVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Float64List accumulates float64 values into a slice. | [
"Float64List",
"accumulates",
"float64",
"values",
"into",
"a",
"slice",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L561-L565 |
148,098 | alecthomas/kingpin | values_generated.go | Float32 | func (p *parserMixin) Float32() (target *float32) {
target = new(float32)
p.Float32Var(target)
return
} | go | func (p *parserMixin) Float32() (target *float32) {
target = new(float32)
p.Float32Var(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Float32",
"(",
")",
"(",
"target",
"*",
"float32",
")",
"{",
"target",
"=",
"new",
"(",
"float32",
")",
"\n",
"p",
".",
"Float32Var",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Float32 parses the next command-line value as float32. | [
"Float32",
"parses",
"the",
"next",
"command",
"-",
"line",
"value",
"as",
"float32",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L593-L597 |
148,099 | alecthomas/kingpin | values_generated.go | Float32List | func (p *parserMixin) Float32List() (target *[]float32) {
target = new([]float32)
p.Float32ListVar(target)
return
} | go | func (p *parserMixin) Float32List() (target *[]float32) {
target = new([]float32)
p.Float32ListVar(target)
return
} | [
"func",
"(",
"p",
"*",
"parserMixin",
")",
"Float32List",
"(",
")",
"(",
"target",
"*",
"[",
"]",
"float32",
")",
"{",
"target",
"=",
"new",
"(",
"[",
"]",
"float32",
")",
"\n",
"p",
".",
"Float32ListVar",
"(",
"target",
")",
"\n",
"return",
"\n",
"}"
] | // Float32List accumulates float32 values into a slice. | [
"Float32List",
"accumulates",
"float32",
"values",
"into",
"a",
"slice",
"."
] | ef6e7c151c4fdbd3fe78aad001729fee08fa0932 | https://github.com/alecthomas/kingpin/blob/ef6e7c151c4fdbd3fe78aad001729fee08fa0932/values_generated.go#L604-L608 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.