repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
thoas/go-funk
typesafe.go
ContainsInt32
func ContainsInt32(s []int32, v int32) bool { for _, vv := range s { if vv == v { return true } } return false }
go
func ContainsInt32(s []int32, v int32) bool { for _, vv := range s { if vv == v { return true } } return false }
[ "func", "ContainsInt32", "(", "s", "[", "]", "int32", ",", "v", "int32", ")", "bool", "{", "for", "_", ",", "vv", ":=", "range", "s", "{", "if", "vv", "==", "v", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// ContainsInt32 returns true if an int32 is present in a iteratee.
[ "ContainsInt32", "returns", "true", "if", "an", "int32", "is", "present", "in", "a", "iteratee", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L228-L235
train
thoas/go-funk
typesafe.go
ContainsInt64
func ContainsInt64(s []int64, v int64) bool { for _, vv := range s { if vv == v { return true } } return false }
go
func ContainsInt64(s []int64, v int64) bool { for _, vv := range s { if vv == v { return true } } return false }
[ "func", "ContainsInt64", "(", "s", "[", "]", "int64", ",", "v", "int64", ")", "bool", "{", "for", "_", ",", "vv", ":=", "range", "s", "{", "if", "vv", "==", "v", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// ContainsInt64 returns true if an int64 is present in a iteratee.
[ "ContainsInt64", "returns", "true", "if", "an", "int64", "is", "present", "in", "a", "iteratee", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L238-L245
train
thoas/go-funk
typesafe.go
ContainsFloat32
func ContainsFloat32(s []float32, v float32) bool { for _, vv := range s { if vv == v { return true } } return false }
go
func ContainsFloat32(s []float32, v float32) bool { for _, vv := range s { if vv == v { return true } } return false }
[ "func", "ContainsFloat32", "(", "s", "[", "]", "float32", ",", "v", "float32", ")", "bool", "{", "for", "_", ",", "vv", ":=", "range", "s", "{", "if", "vv", "==", "v", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", ...
// ContainsFloat32 returns true if a float32 is present in a iteratee.
[ "ContainsFloat32", "returns", "true", "if", "a", "float32", "is", "present", "in", "a", "iteratee", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L258-L265
train
thoas/go-funk
typesafe.go
ContainsFloat64
func ContainsFloat64(s []float64, v float64) bool { for _, vv := range s { if vv == v { return true } } return false }
go
func ContainsFloat64(s []float64, v float64) bool { for _, vv := range s { if vv == v { return true } } return false }
[ "func", "ContainsFloat64", "(", "s", "[", "]", "float64", ",", "v", "float64", ")", "bool", "{", "for", "_", ",", "vv", ":=", "range", "s", "{", "if", "vv", "==", "v", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", ...
// ContainsFloat64 returns true if a float64 is present in a iteratee.
[ "ContainsFloat64", "returns", "true", "if", "a", "float64", "is", "present", "in", "a", "iteratee", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L268-L275
train
thoas/go-funk
typesafe.go
SumInt32
func SumInt32(s []int32) (sum int32) { for _, v := range s { sum += v } return }
go
func SumInt32(s []int32) (sum int32) { for _, v := range s { sum += v } return }
[ "func", "SumInt32", "(", "s", "[", "]", "int32", ")", "(", "sum", "int32", ")", "{", "for", "_", ",", "v", ":=", "range", "s", "{", "sum", "+=", "v", "\n", "}", "\n", "return", "\n", "}" ]
// SumInt32 sums a int32 iteratee and returns the sum of all elements
[ "SumInt32", "sums", "a", "int32", "iteratee", "and", "returns", "the", "sum", "of", "all", "elements" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L278-L283
train
thoas/go-funk
typesafe.go
SumInt64
func SumInt64(s []int64) (sum int64) { for _, v := range s { sum += v } return }
go
func SumInt64(s []int64) (sum int64) { for _, v := range s { sum += v } return }
[ "func", "SumInt64", "(", "s", "[", "]", "int64", ")", "(", "sum", "int64", ")", "{", "for", "_", ",", "v", ":=", "range", "s", "{", "sum", "+=", "v", "\n", "}", "\n", "return", "\n", "}" ]
// SumInt64 sums a int64 iteratee and returns the sum of all elements
[ "SumInt64", "sums", "a", "int64", "iteratee", "and", "returns", "the", "sum", "of", "all", "elements" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L286-L291
train
thoas/go-funk
typesafe.go
SumInt
func SumInt(s []int) (sum int) { for _, v := range s { sum += v } return }
go
func SumInt(s []int) (sum int) { for _, v := range s { sum += v } return }
[ "func", "SumInt", "(", "s", "[", "]", "int", ")", "(", "sum", "int", ")", "{", "for", "_", ",", "v", ":=", "range", "s", "{", "sum", "+=", "v", "\n", "}", "\n", "return", "\n", "}" ]
// SumInt sums a int iteratee and returns the sum of all elements
[ "SumInt", "sums", "a", "int", "iteratee", "and", "returns", "the", "sum", "of", "all", "elements" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L294-L299
train
thoas/go-funk
typesafe.go
SumFloat64
func SumFloat64(s []float64) (sum float64) { for _, v := range s { sum += v } return }
go
func SumFloat64(s []float64) (sum float64) { for _, v := range s { sum += v } return }
[ "func", "SumFloat64", "(", "s", "[", "]", "float64", ")", "(", "sum", "float64", ")", "{", "for", "_", ",", "v", ":=", "range", "s", "{", "sum", "+=", "v", "\n", "}", "\n", "return", "\n", "}" ]
// SumFloat64 sums a float64 iteratee and returns the sum of all elements
[ "SumFloat64", "sums", "a", "float64", "iteratee", "and", "returns", "the", "sum", "of", "all", "elements" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L302-L307
train
thoas/go-funk
typesafe.go
SumFloat32
func SumFloat32(s []float32) (sum float32) { for _, v := range s { sum += v } return }
go
func SumFloat32(s []float32) (sum float32) { for _, v := range s { sum += v } return }
[ "func", "SumFloat32", "(", "s", "[", "]", "float32", ")", "(", "sum", "float32", ")", "{", "for", "_", ",", "v", ":=", "range", "s", "{", "sum", "+=", "v", "\n", "}", "\n", "return", "\n", "}" ]
// SumFloat32 sums a float32 iteratee and returns the sum of all elements
[ "SumFloat32", "sums", "a", "float32", "iteratee", "and", "returns", "the", "sum", "of", "all", "elements" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L310-L315
train
thoas/go-funk
typesafe.go
ReverseStrings
func ReverseStrings(s []string) []string { for i, j := 0, len(s)-1; i < len(s)/2; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } return s }
go
func ReverseStrings(s []string) []string { for i, j := 0, len(s)-1; i < len(s)/2; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } return s }
[ "func", "ReverseStrings", "(", "s", "[", "]", "string", ")", "[", "]", "string", "{", "for", "i", ",", "j", ":=", "0", ",", "len", "(", "s", ")", "-", "1", ";", "i", "<", "len", "(", "s", ")", "/", "2", ";", "i", ",", "j", "=", "i", "+"...
// ReverseStrings reverses an array of string
[ "ReverseStrings", "reverses", "an", "array", "of", "string" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L318-L323
train
thoas/go-funk
typesafe.go
ReverseInt
func ReverseInt(s []int) []int { for i, j := 0, len(s)-1; i < len(s)/2; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } return s }
go
func ReverseInt(s []int) []int { for i, j := 0, len(s)-1; i < len(s)/2; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } return s }
[ "func", "ReverseInt", "(", "s", "[", "]", "int", ")", "[", "]", "int", "{", "for", "i", ",", "j", ":=", "0", ",", "len", "(", "s", ")", "-", "1", ";", "i", "<", "len", "(", "s", ")", "/", "2", ";", "i", ",", "j", "=", "i", "+", "1", ...
// ReverseInt reverses an array of int
[ "ReverseInt", "reverses", "an", "array", "of", "int" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L326-L331
train
thoas/go-funk
typesafe.go
ReverseInt32
func ReverseInt32(s []int32) []int32 { for i, j := 0, len(s)-1; i < len(s)/2; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } return s }
go
func ReverseInt32(s []int32) []int32 { for i, j := 0, len(s)-1; i < len(s)/2; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } return s }
[ "func", "ReverseInt32", "(", "s", "[", "]", "int32", ")", "[", "]", "int32", "{", "for", "i", ",", "j", ":=", "0", ",", "len", "(", "s", ")", "-", "1", ";", "i", "<", "len", "(", "s", ")", "/", "2", ";", "i", ",", "j", "=", "i", "+", ...
// ReverseInt32 reverses an array of int32
[ "ReverseInt32", "reverses", "an", "array", "of", "int32" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L334-L339
train
thoas/go-funk
typesafe.go
ReverseInt64
func ReverseInt64(s []int64) []int64 { for i, j := 0, len(s)-1; i < len(s)/2; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } return s }
go
func ReverseInt64(s []int64) []int64 { for i, j := 0, len(s)-1; i < len(s)/2; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } return s }
[ "func", "ReverseInt64", "(", "s", "[", "]", "int64", ")", "[", "]", "int64", "{", "for", "i", ",", "j", ":=", "0", ",", "len", "(", "s", ")", "-", "1", ";", "i", "<", "len", "(", "s", ")", "/", "2", ";", "i", ",", "j", "=", "i", "+", ...
// ReverseInt64 reverses an array of int64
[ "ReverseInt64", "reverses", "an", "array", "of", "int64" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L342-L347
train
thoas/go-funk
typesafe.go
ReverseFloat64
func ReverseFloat64(s []float64) []float64 { for i, j := 0, len(s)-1; i < len(s)/2; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } return s }
go
func ReverseFloat64(s []float64) []float64 { for i, j := 0, len(s)-1; i < len(s)/2; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } return s }
[ "func", "ReverseFloat64", "(", "s", "[", "]", "float64", ")", "[", "]", "float64", "{", "for", "i", ",", "j", ":=", "0", ",", "len", "(", "s", ")", "-", "1", ";", "i", "<", "len", "(", "s", ")", "/", "2", ";", "i", ",", "j", "=", "i", "...
// ReverseFloat64 reverses an array of float64
[ "ReverseFloat64", "reverses", "an", "array", "of", "float64" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L350-L355
train
thoas/go-funk
typesafe.go
ReverseFloat32
func ReverseFloat32(s []float32) []float32 { for i, j := 0, len(s)-1; i < len(s)/2; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } return s }
go
func ReverseFloat32(s []float32) []float32 { for i, j := 0, len(s)-1; i < len(s)/2; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } return s }
[ "func", "ReverseFloat32", "(", "s", "[", "]", "float32", ")", "[", "]", "float32", "{", "for", "i", ",", "j", ":=", "0", ",", "len", "(", "s", ")", "-", "1", ";", "i", "<", "len", "(", "s", ")", "/", "2", ";", "i", ",", "j", "=", "i", "...
// ReverseFloat32 reverses an array of float32
[ "ReverseFloat32", "reverses", "an", "array", "of", "float32" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L358-L363
train
thoas/go-funk
typesafe.go
ReverseString
func ReverseString(s string) string { r := []rune(s) for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 { r[i], r[j] = r[j], r[i] } return string(r) }
go
func ReverseString(s string) string { r := []rune(s) for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 { r[i], r[j] = r[j], r[i] } return string(r) }
[ "func", "ReverseString", "(", "s", "string", ")", "string", "{", "r", ":=", "[", "]", "rune", "(", "s", ")", "\n", "for", "i", ",", "j", ":=", "0", ",", "len", "(", "r", ")", "-", "1", ";", "i", "<", "len", "(", "r", ")", "/", "2", ";", ...
// ReverseString reverses a string
[ "ReverseString", "reverses", "a", "string" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L366-L372
train
thoas/go-funk
typesafe.go
IndexOfInt
func IndexOfInt(a []int, x int) int { return indexOf(len(a), func(i int) bool { return a[i] == x }) }
go
func IndexOfInt(a []int, x int) int { return indexOf(len(a), func(i int) bool { return a[i] == x }) }
[ "func", "IndexOfInt", "(", "a", "[", "]", "int", ",", "x", "int", ")", "int", "{", "return", "indexOf", "(", "len", "(", "a", ")", ",", "func", "(", "i", "int", ")", "bool", "{", "return", "a", "[", "i", "]", "==", "x", "}", ")", "\n", "}" ...
// IndexOfInt gets the index at which the first occurrence of an int value is found in array or return -1 // if the value cannot be found
[ "IndexOfInt", "gets", "the", "index", "at", "which", "the", "first", "occurrence", "of", "an", "int", "value", "is", "found", "in", "array", "or", "return", "-", "1", "if", "the", "value", "cannot", "be", "found" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L385-L387
train
thoas/go-funk
typesafe.go
IndexOfInt32
func IndexOfInt32(a []int32, x int32) int { return indexOf(len(a), func(i int) bool { return a[i] == x }) }
go
func IndexOfInt32(a []int32, x int32) int { return indexOf(len(a), func(i int) bool { return a[i] == x }) }
[ "func", "IndexOfInt32", "(", "a", "[", "]", "int32", ",", "x", "int32", ")", "int", "{", "return", "indexOf", "(", "len", "(", "a", ")", ",", "func", "(", "i", "int", ")", "bool", "{", "return", "a", "[", "i", "]", "==", "x", "}", ")", "\n", ...
// IndexOfInt32 gets the index at which the first occurrence of an int32 value is found in array or return -1 // if the value cannot be found
[ "IndexOfInt32", "gets", "the", "index", "at", "which", "the", "first", "occurrence", "of", "an", "int32", "value", "is", "found", "in", "array", "or", "return", "-", "1", "if", "the", "value", "cannot", "be", "found" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L391-L393
train
thoas/go-funk
typesafe.go
IndexOfInt64
func IndexOfInt64(a []int64, x int64) int { return indexOf(len(a), func(i int) bool { return a[i] == x }) }
go
func IndexOfInt64(a []int64, x int64) int { return indexOf(len(a), func(i int) bool { return a[i] == x }) }
[ "func", "IndexOfInt64", "(", "a", "[", "]", "int64", ",", "x", "int64", ")", "int", "{", "return", "indexOf", "(", "len", "(", "a", ")", ",", "func", "(", "i", "int", ")", "bool", "{", "return", "a", "[", "i", "]", "==", "x", "}", ")", "\n", ...
// IndexOfInt64 gets the index at which the first occurrence of an int64 value is found in array or return -1 // if the value cannot be found
[ "IndexOfInt64", "gets", "the", "index", "at", "which", "the", "first", "occurrence", "of", "an", "int64", "value", "is", "found", "in", "array", "or", "return", "-", "1", "if", "the", "value", "cannot", "be", "found" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L397-L399
train
thoas/go-funk
typesafe.go
IndexOfFloat64
func IndexOfFloat64(a []float64, x float64) int { return indexOf(len(a), func(i int) bool { return a[i] == x }) }
go
func IndexOfFloat64(a []float64, x float64) int { return indexOf(len(a), func(i int) bool { return a[i] == x }) }
[ "func", "IndexOfFloat64", "(", "a", "[", "]", "float64", ",", "x", "float64", ")", "int", "{", "return", "indexOf", "(", "len", "(", "a", ")", ",", "func", "(", "i", "int", ")", "bool", "{", "return", "a", "[", "i", "]", "==", "x", "}", ")", ...
// IndexOfFloat64 gets the index at which the first occurrence of an float64 value is found in array or return -1 // if the value cannot be found
[ "IndexOfFloat64", "gets", "the", "index", "at", "which", "the", "first", "occurrence", "of", "an", "float64", "value", "is", "found", "in", "array", "or", "return", "-", "1", "if", "the", "value", "cannot", "be", "found" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L403-L405
train
thoas/go-funk
typesafe.go
IndexOfString
func IndexOfString(a []string, x string) int { return indexOf(len(a), func(i int) bool { return a[i] == x }) }
go
func IndexOfString(a []string, x string) int { return indexOf(len(a), func(i int) bool { return a[i] == x }) }
[ "func", "IndexOfString", "(", "a", "[", "]", "string", ",", "x", "string", ")", "int", "{", "return", "indexOf", "(", "len", "(", "a", ")", ",", "func", "(", "i", "int", ")", "bool", "{", "return", "a", "[", "i", "]", "==", "x", "}", ")", "\n...
// IndexOfString gets the index at which the first occurrence of a string value is found in array or return -1 // if the value cannot be found
[ "IndexOfString", "gets", "the", "index", "at", "which", "the", "first", "occurrence", "of", "a", "string", "value", "is", "found", "in", "array", "or", "return", "-", "1", "if", "the", "value", "cannot", "be", "found" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L409-L411
train
thoas/go-funk
typesafe.go
LastIndexOfInt
func LastIndexOfInt(a []int, x int) int { return lastIndexOf(len(a), func(i int) bool { return a[i] == x }) }
go
func LastIndexOfInt(a []int, x int) int { return lastIndexOf(len(a), func(i int) bool { return a[i] == x }) }
[ "func", "LastIndexOfInt", "(", "a", "[", "]", "int", ",", "x", "int", ")", "int", "{", "return", "lastIndexOf", "(", "len", "(", "a", ")", ",", "func", "(", "i", "int", ")", "bool", "{", "return", "a", "[", "i", "]", "==", "x", "}", ")", "\n"...
// LastIndexOfInt gets the index at which the first occurrence of an int value is found in array or return -1 // if the value cannot be found
[ "LastIndexOfInt", "gets", "the", "index", "at", "which", "the", "first", "occurrence", "of", "an", "int", "value", "is", "found", "in", "array", "or", "return", "-", "1", "if", "the", "value", "cannot", "be", "found" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L424-L426
train
thoas/go-funk
typesafe.go
LastIndexOfInt32
func LastIndexOfInt32(a []int32, x int32) int { return lastIndexOf(len(a), func(i int) bool { return a[i] == x }) }
go
func LastIndexOfInt32(a []int32, x int32) int { return lastIndexOf(len(a), func(i int) bool { return a[i] == x }) }
[ "func", "LastIndexOfInt32", "(", "a", "[", "]", "int32", ",", "x", "int32", ")", "int", "{", "return", "lastIndexOf", "(", "len", "(", "a", ")", ",", "func", "(", "i", "int", ")", "bool", "{", "return", "a", "[", "i", "]", "==", "x", "}", ")", ...
// LastIndexOfInt32 gets the index at which the first occurrence of an int32 value is found in array or return -1 // if the value cannot be found
[ "LastIndexOfInt32", "gets", "the", "index", "at", "which", "the", "first", "occurrence", "of", "an", "int32", "value", "is", "found", "in", "array", "or", "return", "-", "1", "if", "the", "value", "cannot", "be", "found" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L430-L432
train
thoas/go-funk
typesafe.go
LastIndexOfInt64
func LastIndexOfInt64(a []int64, x int64) int { return lastIndexOf(len(a), func(i int) bool { return a[i] == x }) }
go
func LastIndexOfInt64(a []int64, x int64) int { return lastIndexOf(len(a), func(i int) bool { return a[i] == x }) }
[ "func", "LastIndexOfInt64", "(", "a", "[", "]", "int64", ",", "x", "int64", ")", "int", "{", "return", "lastIndexOf", "(", "len", "(", "a", ")", ",", "func", "(", "i", "int", ")", "bool", "{", "return", "a", "[", "i", "]", "==", "x", "}", ")", ...
// LastIndexOfInt64 gets the index at which the first occurrence of an int64 value is found in array or return -1 // if the value cannot be found
[ "LastIndexOfInt64", "gets", "the", "index", "at", "which", "the", "first", "occurrence", "of", "an", "int64", "value", "is", "found", "in", "array", "or", "return", "-", "1", "if", "the", "value", "cannot", "be", "found" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L436-L438
train
thoas/go-funk
typesafe.go
LastIndexOfFloat64
func LastIndexOfFloat64(a []float64, x float64) int { return lastIndexOf(len(a), func(i int) bool { return a[i] == x }) }
go
func LastIndexOfFloat64(a []float64, x float64) int { return lastIndexOf(len(a), func(i int) bool { return a[i] == x }) }
[ "func", "LastIndexOfFloat64", "(", "a", "[", "]", "float64", ",", "x", "float64", ")", "int", "{", "return", "lastIndexOf", "(", "len", "(", "a", ")", ",", "func", "(", "i", "int", ")", "bool", "{", "return", "a", "[", "i", "]", "==", "x", "}", ...
// LastIndexOfFloat64 gets the index at which the first occurrence of an float64 value is found in array or return -1 // if the value cannot be found
[ "LastIndexOfFloat64", "gets", "the", "index", "at", "which", "the", "first", "occurrence", "of", "an", "float64", "value", "is", "found", "in", "array", "or", "return", "-", "1", "if", "the", "value", "cannot", "be", "found" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L442-L444
train
thoas/go-funk
typesafe.go
LastIndexOfFloat32
func LastIndexOfFloat32(a []float32, x float32) int { return lastIndexOf(len(a), func(i int) bool { return a[i] == x }) }
go
func LastIndexOfFloat32(a []float32, x float32) int { return lastIndexOf(len(a), func(i int) bool { return a[i] == x }) }
[ "func", "LastIndexOfFloat32", "(", "a", "[", "]", "float32", ",", "x", "float32", ")", "int", "{", "return", "lastIndexOf", "(", "len", "(", "a", ")", ",", "func", "(", "i", "int", ")", "bool", "{", "return", "a", "[", "i", "]", "==", "x", "}", ...
// LastIndexOfFloat32 gets the index at which the first occurrence of an float32 value is found in array or return -1 // if the value cannot be found
[ "LastIndexOfFloat32", "gets", "the", "index", "at", "which", "the", "first", "occurrence", "of", "an", "float32", "value", "is", "found", "in", "array", "or", "return", "-", "1", "if", "the", "value", "cannot", "be", "found" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L448-L450
train
thoas/go-funk
typesafe.go
LastIndexOfString
func LastIndexOfString(a []string, x string) int { return lastIndexOf(len(a), func(i int) bool { return a[i] == x }) }
go
func LastIndexOfString(a []string, x string) int { return lastIndexOf(len(a), func(i int) bool { return a[i] == x }) }
[ "func", "LastIndexOfString", "(", "a", "[", "]", "string", ",", "x", "string", ")", "int", "{", "return", "lastIndexOf", "(", "len", "(", "a", ")", ",", "func", "(", "i", "int", ")", "bool", "{", "return", "a", "[", "i", "]", "==", "x", "}", ")...
// LastIndexOfString gets the index at which the first occurrence of a string value is found in array or return -1 // if the value cannot be found
[ "LastIndexOfString", "gets", "the", "index", "at", "which", "the", "first", "occurrence", "of", "a", "string", "value", "is", "found", "in", "array", "or", "return", "-", "1", "if", "the", "value", "cannot", "be", "found" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L454-L456
train
thoas/go-funk
typesafe.go
UniqInt32
func UniqInt32(a []int32) []int32 { length := len(a) seen := make(map[int32]struct{}, length) j := 0 for i := 0; i < length; i++ { v := a[i] if _, ok := seen[v]; ok { continue } seen[v] = struct{}{} a[j] = v j++ } return a[0:j] }
go
func UniqInt32(a []int32) []int32 { length := len(a) seen := make(map[int32]struct{}, length) j := 0 for i := 0; i < length; i++ { v := a[i] if _, ok := seen[v]; ok { continue } seen[v] = struct{}{} a[j] = v j++ } return a[0:j] }
[ "func", "UniqInt32", "(", "a", "[", "]", "int32", ")", "[", "]", "int32", "{", "length", ":=", "len", "(", "a", ")", "\n\n", "seen", ":=", "make", "(", "map", "[", "int32", "]", "struct", "{", "}", ",", "length", ")", "\n", "j", ":=", "0", "\...
// UniqInt32 creates an array of int32 with unique values.
[ "UniqInt32", "creates", "an", "array", "of", "int32", "with", "unique", "values", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L459-L478
train
thoas/go-funk
typesafe.go
UniqInt64
func UniqInt64(a []int64) []int64 { length := len(a) seen := make(map[int64]struct{}, length) j := 0 for i := 0; i < length; i++ { v := a[i] if _, ok := seen[v]; ok { continue } seen[v] = struct{}{} a[j] = v j++ } return a[0:j] }
go
func UniqInt64(a []int64) []int64 { length := len(a) seen := make(map[int64]struct{}, length) j := 0 for i := 0; i < length; i++ { v := a[i] if _, ok := seen[v]; ok { continue } seen[v] = struct{}{} a[j] = v j++ } return a[0:j] }
[ "func", "UniqInt64", "(", "a", "[", "]", "int64", ")", "[", "]", "int64", "{", "length", ":=", "len", "(", "a", ")", "\n\n", "seen", ":=", "make", "(", "map", "[", "int64", "]", "struct", "{", "}", ",", "length", ")", "\n", "j", ":=", "0", "\...
// UniqInt64 creates an array of int64 with unique values.
[ "UniqInt64", "creates", "an", "array", "of", "int64", "with", "unique", "values", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L481-L500
train
thoas/go-funk
typesafe.go
UniqInt
func UniqInt(a []int) []int { length := len(a) seen := make(map[int]struct{}, length) j := 0 for i := 0; i < length; i++ { v := a[i] if _, ok := seen[v]; ok { continue } seen[v] = struct{}{} a[j] = v j++ } return a[0:j] }
go
func UniqInt(a []int) []int { length := len(a) seen := make(map[int]struct{}, length) j := 0 for i := 0; i < length; i++ { v := a[i] if _, ok := seen[v]; ok { continue } seen[v] = struct{}{} a[j] = v j++ } return a[0:j] }
[ "func", "UniqInt", "(", "a", "[", "]", "int", ")", "[", "]", "int", "{", "length", ":=", "len", "(", "a", ")", "\n\n", "seen", ":=", "make", "(", "map", "[", "int", "]", "struct", "{", "}", ",", "length", ")", "\n", "j", ":=", "0", "\n\n", ...
// UniqInt creates an array of int with unique values.
[ "UniqInt", "creates", "an", "array", "of", "int", "with", "unique", "values", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L503-L522
train
thoas/go-funk
typesafe.go
UniqString
func UniqString(a []string) []string { length := len(a) seen := make(map[string]struct{}, length) j := 0 for i := 0; i < length; i++ { v := a[i] if _, ok := seen[v]; ok { continue } seen[v] = struct{}{} a[j] = v j++ } return a[0:j] }
go
func UniqString(a []string) []string { length := len(a) seen := make(map[string]struct{}, length) j := 0 for i := 0; i < length; i++ { v := a[i] if _, ok := seen[v]; ok { continue } seen[v] = struct{}{} a[j] = v j++ } return a[0:j] }
[ "func", "UniqString", "(", "a", "[", "]", "string", ")", "[", "]", "string", "{", "length", ":=", "len", "(", "a", ")", "\n\n", "seen", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ",", "length", ")", "\n", "j", ":=", "0", ...
// UniqString creates an array of string with unique values.
[ "UniqString", "creates", "an", "array", "of", "string", "with", "unique", "values", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L525-L544
train
thoas/go-funk
typesafe.go
UniqFloat64
func UniqFloat64(a []float64) []float64 { length := len(a) seen := make(map[float64]struct{}, length) j := 0 for i := 0; i < length; i++ { v := a[i] if _, ok := seen[v]; ok { continue } seen[v] = struct{}{} a[j] = v j++ } return a[0:j] }
go
func UniqFloat64(a []float64) []float64 { length := len(a) seen := make(map[float64]struct{}, length) j := 0 for i := 0; i < length; i++ { v := a[i] if _, ok := seen[v]; ok { continue } seen[v] = struct{}{} a[j] = v j++ } return a[0:j] }
[ "func", "UniqFloat64", "(", "a", "[", "]", "float64", ")", "[", "]", "float64", "{", "length", ":=", "len", "(", "a", ")", "\n\n", "seen", ":=", "make", "(", "map", "[", "float64", "]", "struct", "{", "}", ",", "length", ")", "\n", "j", ":=", "...
// UniqFloat64 creates an array of float64 with unique values.
[ "UniqFloat64", "creates", "an", "array", "of", "float64", "with", "unique", "values", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L547-L566
train
thoas/go-funk
typesafe.go
UniqFloat32
func UniqFloat32(a []float32) []float32 { length := len(a) seen := make(map[float32]struct{}, length) j := 0 for i := 0; i < length; i++ { v := a[i] if _, ok := seen[v]; ok { continue } seen[v] = struct{}{} a[j] = v j++ } return a[0:j] }
go
func UniqFloat32(a []float32) []float32 { length := len(a) seen := make(map[float32]struct{}, length) j := 0 for i := 0; i < length; i++ { v := a[i] if _, ok := seen[v]; ok { continue } seen[v] = struct{}{} a[j] = v j++ } return a[0:j] }
[ "func", "UniqFloat32", "(", "a", "[", "]", "float32", ")", "[", "]", "float32", "{", "length", ":=", "len", "(", "a", ")", "\n\n", "seen", ":=", "make", "(", "map", "[", "float32", "]", "struct", "{", "}", ",", "length", ")", "\n", "j", ":=", "...
// UniqFloat32 creates an array of float32 with unique values.
[ "UniqFloat32", "creates", "an", "array", "of", "float32", "with", "unique", "values", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/typesafe.go#L569-L588
train
thoas/go-funk
map.go
Keys
func Keys(out interface{}) interface{} { value := redirectValue(reflect.ValueOf(out)) valueType := value.Type() if value.Kind() == reflect.Map { keys := value.MapKeys() length := len(keys) resultSlice := reflect.MakeSlice(reflect.SliceOf(valueType.Key()), length, length) for i, key := range keys { res...
go
func Keys(out interface{}) interface{} { value := redirectValue(reflect.ValueOf(out)) valueType := value.Type() if value.Kind() == reflect.Map { keys := value.MapKeys() length := len(keys) resultSlice := reflect.MakeSlice(reflect.SliceOf(valueType.Key()), length, length) for i, key := range keys { res...
[ "func", "Keys", "(", "out", "interface", "{", "}", ")", "interface", "{", "}", "{", "value", ":=", "redirectValue", "(", "reflect", ".", "ValueOf", "(", "out", ")", ")", "\n", "valueType", ":=", "value", ".", "Type", "(", ")", "\n\n", "if", "value", ...
// Keys creates an array of the own enumerable map keys or struct field names.
[ "Keys", "creates", "an", "array", "of", "the", "own", "enumerable", "map", "keys", "or", "struct", "field", "names", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/map.go#L9-L40
train
thoas/go-funk
scan.go
ForEach
func ForEach(arr interface{}, predicate interface{}) { if !IsIteratee(arr) { panic("First parameter must be an iteratee") } var ( funcValue = reflect.ValueOf(predicate) arrValue = reflect.ValueOf(arr) arrType = arrValue.Type() funcType = funcValue.Type() ) if arrType.Kind() == reflect.Slice || arrT...
go
func ForEach(arr interface{}, predicate interface{}) { if !IsIteratee(arr) { panic("First parameter must be an iteratee") } var ( funcValue = reflect.ValueOf(predicate) arrValue = reflect.ValueOf(arr) arrType = arrValue.Type() funcType = funcValue.Type() ) if arrType.Kind() == reflect.Slice || arrT...
[ "func", "ForEach", "(", "arr", "interface", "{", "}", ",", "predicate", "interface", "{", "}", ")", "{", "if", "!", "IsIteratee", "(", "arr", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "var", "(", "funcValue", "=", "reflect", ".", ...
// ForEach iterates over elements of collection and invokes iteratee // for each element.
[ "ForEach", "iterates", "over", "elements", "of", "collection", "and", "invokes", "iteratee", "for", "each", "element", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/scan.go#L10-L60
train
thoas/go-funk
scan.go
Head
func Head(arr interface{}) interface{} { value := redirectValue(reflect.ValueOf(arr)) valueType := value.Type() kind := value.Kind() if kind == reflect.Array || kind == reflect.Slice { if value.Len() == 0 { return nil } return value.Index(0).Interface() } panic(fmt.Sprintf("Type %s is not supported b...
go
func Head(arr interface{}) interface{} { value := redirectValue(reflect.ValueOf(arr)) valueType := value.Type() kind := value.Kind() if kind == reflect.Array || kind == reflect.Slice { if value.Len() == 0 { return nil } return value.Index(0).Interface() } panic(fmt.Sprintf("Type %s is not supported b...
[ "func", "Head", "(", "arr", "interface", "{", "}", ")", "interface", "{", "}", "{", "value", ":=", "redirectValue", "(", "reflect", ".", "ValueOf", "(", "arr", ")", ")", "\n", "valueType", ":=", "value", ".", "Type", "(", ")", "\n\n", "kind", ":=", ...
// Head gets the first element of array.
[ "Head", "gets", "the", "first", "element", "of", "array", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/scan.go#L119-L134
train
thoas/go-funk
scan.go
Tail
func Tail(arr interface{}) interface{} { value := redirectValue(reflect.ValueOf(arr)) valueType := value.Type() kind := value.Kind() if kind == reflect.Array || kind == reflect.Slice { length := value.Len() if length <= 1 { return arr } return value.Slice(1, length).Interface() } panic(fmt.Sprintf...
go
func Tail(arr interface{}) interface{} { value := redirectValue(reflect.ValueOf(arr)) valueType := value.Type() kind := value.Kind() if kind == reflect.Array || kind == reflect.Slice { length := value.Len() if length <= 1 { return arr } return value.Slice(1, length).Interface() } panic(fmt.Sprintf...
[ "func", "Tail", "(", "arr", "interface", "{", "}", ")", "interface", "{", "}", "{", "value", ":=", "redirectValue", "(", "reflect", ".", "ValueOf", "(", "arr", ")", ")", "\n", "valueType", ":=", "value", ".", "Type", "(", ")", "\n\n", "kind", ":=", ...
// Tail gets all but the first element of array.
[ "Tail", "gets", "all", "but", "the", "first", "element", "of", "array", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/scan.go#L175-L192
train
thoas/go-funk
presence.go
Filter
func Filter(arr interface{}, predicate interface{}) interface{} { if !IsIteratee(arr) { panic("First parameter must be an iteratee") } if !IsFunction(predicate, 1, 1) { panic("Second argument must be function") } funcValue := reflect.ValueOf(predicate) funcType := funcValue.Type() if funcType.Out(0).Kind...
go
func Filter(arr interface{}, predicate interface{}) interface{} { if !IsIteratee(arr) { panic("First parameter must be an iteratee") } if !IsFunction(predicate, 1, 1) { panic("Second argument must be function") } funcValue := reflect.ValueOf(predicate) funcType := funcValue.Type() if funcType.Out(0).Kind...
[ "func", "Filter", "(", "arr", "interface", "{", "}", ",", "predicate", "interface", "{", "}", ")", "interface", "{", "}", "{", "if", "!", "IsIteratee", "(", "arr", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "!", "IsFunction",...
// Filter iterates over elements of collection, returning an array of // all elements predicate returns truthy for.
[ "Filter", "iterates", "over", "elements", "of", "collection", "returning", "an", "array", "of", "all", "elements", "predicate", "returns", "truthy", "for", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/presence.go#L11-L49
train
thoas/go-funk
presence.go
Find
func Find(arr interface{}, predicate interface{}) interface{} { if !IsIteratee(arr) { panic("First parameter must be an iteratee") } if !IsFunction(predicate, 1, 1) { panic("Second argument must be function") } funcValue := reflect.ValueOf(predicate) funcType := funcValue.Type() if funcType.Out(0).Kind()...
go
func Find(arr interface{}, predicate interface{}) interface{} { if !IsIteratee(arr) { panic("First parameter must be an iteratee") } if !IsFunction(predicate, 1, 1) { panic("Second argument must be function") } funcValue := reflect.ValueOf(predicate) funcType := funcValue.Type() if funcType.Out(0).Kind()...
[ "func", "Find", "(", "arr", "interface", "{", "}", ",", "predicate", "interface", "{", "}", ")", "interface", "{", "}", "{", "if", "!", "IsIteratee", "(", "arr", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "!", "IsFunction", ...
// Find iterates over elements of collection, returning the first // element predicate returns truthy for.
[ "Find", "iterates", "over", "elements", "of", "collection", "returning", "the", "first", "element", "predicate", "returns", "truthy", "for", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/presence.go#L53-L83
train
thoas/go-funk
presence.go
IndexOf
func IndexOf(in interface{}, elem interface{}) int { inValue := reflect.ValueOf(in) elemValue := reflect.ValueOf(elem) inType := inValue.Type() if inType.Kind() == reflect.String { return strings.Index(inValue.String(), elemValue.String()) } if inType.Kind() == reflect.Slice { for i := 0; i < inValue.Len(...
go
func IndexOf(in interface{}, elem interface{}) int { inValue := reflect.ValueOf(in) elemValue := reflect.ValueOf(elem) inType := inValue.Type() if inType.Kind() == reflect.String { return strings.Index(inValue.String(), elemValue.String()) } if inType.Kind() == reflect.Slice { for i := 0; i < inValue.Len(...
[ "func", "IndexOf", "(", "in", "interface", "{", "}", ",", "elem", "interface", "{", "}", ")", "int", "{", "inValue", ":=", "reflect", ".", "ValueOf", "(", "in", ")", "\n\n", "elemValue", ":=", "reflect", ".", "ValueOf", "(", "elem", ")", "\n\n", "inT...
// IndexOf gets the index at which the first occurrence of value is found in array or return -1 // if the value cannot be found
[ "IndexOf", "gets", "the", "index", "at", "which", "the", "first", "occurrence", "of", "value", "is", "found", "in", "array", "or", "return", "-", "1", "if", "the", "value", "cannot", "be", "found" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/presence.go#L87-L107
train
thoas/go-funk
presence.go
Contains
func Contains(in interface{}, elem interface{}) bool { inValue := reflect.ValueOf(in) elemValue := reflect.ValueOf(elem) inType := inValue.Type() switch inType.Kind() { case reflect.String: return strings.Contains(inValue.String(), elemValue.String()) case reflect.Map: for _, key := range inValue.MapKeys() {...
go
func Contains(in interface{}, elem interface{}) bool { inValue := reflect.ValueOf(in) elemValue := reflect.ValueOf(elem) inType := inValue.Type() switch inType.Kind() { case reflect.String: return strings.Contains(inValue.String(), elemValue.String()) case reflect.Map: for _, key := range inValue.MapKeys() {...
[ "func", "Contains", "(", "in", "interface", "{", "}", ",", "elem", "interface", "{", "}", ")", "bool", "{", "inValue", ":=", "reflect", ".", "ValueOf", "(", "in", ")", "\n", "elemValue", ":=", "reflect", ".", "ValueOf", "(", "elem", ")", "\n", "inTyp...
// Contains returns true if an element is present in a iteratee.
[ "Contains", "returns", "true", "if", "an", "element", "is", "present", "in", "a", "iteratee", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/presence.go#L136-L161
train
thoas/go-funk
presence.go
Every
func Every(in interface{}, elements ...interface{}) bool { for _, elem := range elements { if !Contains(in, elem) { return false } } return true }
go
func Every(in interface{}, elements ...interface{}) bool { for _, elem := range elements { if !Contains(in, elem) { return false } } return true }
[ "func", "Every", "(", "in", "interface", "{", "}", ",", "elements", "...", "interface", "{", "}", ")", "bool", "{", "for", "_", ",", "elem", ":=", "range", "elements", "{", "if", "!", "Contains", "(", "in", ",", "elem", ")", "{", "return", "false",...
// Every returns true if every element is present in a iteratee.
[ "Every", "returns", "true", "if", "every", "element", "is", "present", "in", "a", "iteratee", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/presence.go#L164-L171
train
thoas/go-funk
builder.go
Chain
func Chain(v interface{}) Builder { isNotNil(v, "Chain") valueType := reflect.TypeOf(v) if isValidBuilderEntry(valueType) || (valueType.Kind() == reflect.Ptr && isValidBuilderEntry(valueType.Elem())) { return &chainBuilder{v} } panic(fmt.Sprintf("Type %s is not supported by Chain", valueType.String())) }
go
func Chain(v interface{}) Builder { isNotNil(v, "Chain") valueType := reflect.TypeOf(v) if isValidBuilderEntry(valueType) || (valueType.Kind() == reflect.Ptr && isValidBuilderEntry(valueType.Elem())) { return &chainBuilder{v} } panic(fmt.Sprintf("Type %s is not supported by Chain", valueType.String())) }
[ "func", "Chain", "(", "v", "interface", "{", "}", ")", "Builder", "{", "isNotNil", "(", "v", ",", "\"", "\"", ")", "\n\n", "valueType", ":=", "reflect", ".", "TypeOf", "(", "v", ")", "\n", "if", "isValidBuilderEntry", "(", "valueType", ")", "||", "("...
// Chain creates a simple new go-funk.Builder from a collection. Each method // call generate a new builder containing the previous result.
[ "Chain", "creates", "a", "simple", "new", "go", "-", "funk", ".", "Builder", "from", "a", "collection", ".", "Each", "method", "call", "generate", "a", "new", "builder", "containing", "the", "previous", "result", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/builder.go#L47-L57
train
thoas/go-funk
builder.go
LazyChain
func LazyChain(v interface{}) Builder { isNotNil(v, "LazyChain") valueType := reflect.TypeOf(v) if isValidBuilderEntry(valueType) || (valueType.Kind() == reflect.Ptr && isValidBuilderEntry(valueType.Elem())) { return &lazyBuilder{func() interface{} { return v }} } panic(fmt.Sprintf("Type %s is not supported ...
go
func LazyChain(v interface{}) Builder { isNotNil(v, "LazyChain") valueType := reflect.TypeOf(v) if isValidBuilderEntry(valueType) || (valueType.Kind() == reflect.Ptr && isValidBuilderEntry(valueType.Elem())) { return &lazyBuilder{func() interface{} { return v }} } panic(fmt.Sprintf("Type %s is not supported ...
[ "func", "LazyChain", "(", "v", "interface", "{", "}", ")", "Builder", "{", "isNotNil", "(", "v", ",", "\"", "\"", ")", "\n\n", "valueType", ":=", "reflect", ".", "TypeOf", "(", "v", ")", "\n", "if", "isValidBuilderEntry", "(", "valueType", ")", "||", ...
// LazyChain creates a lazy go-funk.Builder from a collection. Each method call // generate a new builder containing a method generating the previous value. // With that, all data are only generated when we call a tailling method like All or Find.
[ "LazyChain", "creates", "a", "lazy", "go", "-", "funk", ".", "Builder", "from", "a", "collection", ".", "Each", "method", "call", "generate", "a", "new", "builder", "containing", "a", "method", "generating", "the", "previous", "value", ".", "With", "that", ...
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/builder.go#L62-L73
train
thoas/go-funk
fill.go
Fill
func Fill(in interface{}, fillValue interface{}) (interface{}, error) { inValue := reflect.ValueOf(in) inKind := inValue.Type().Kind() if inKind != reflect.Slice && inKind != reflect.Array { return nil, errors.New("Can only fill slices and arrays") } inType := reflect.TypeOf(in).Elem() value := reflect.ValueOf...
go
func Fill(in interface{}, fillValue interface{}) (interface{}, error) { inValue := reflect.ValueOf(in) inKind := inValue.Type().Kind() if inKind != reflect.Slice && inKind != reflect.Array { return nil, errors.New("Can only fill slices and arrays") } inType := reflect.TypeOf(in).Elem() value := reflect.ValueOf...
[ "func", "Fill", "(", "in", "interface", "{", "}", ",", "fillValue", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "inValue", ":=", "reflect", ".", "ValueOf", "(", "in", ")", "\n", "inKind", ":=", "inValue", ".", "T...
// Fill fills elements of array with value
[ "Fill", "fills", "elements", "of", "array", "with", "value" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/fill.go#L10-L34
train
thoas/go-funk
intersection.go
Intersect
func Intersect(x interface{}, y interface{}) interface{} { if !IsCollection(x) { panic("First parameter must be a collection") } if !IsCollection(y) { panic("Second parameter must be a collection") } hash := map[interface{}]struct{}{} xValue := reflect.ValueOf(x) xType := xValue.Type() yValue := reflect....
go
func Intersect(x interface{}, y interface{}) interface{} { if !IsCollection(x) { panic("First parameter must be a collection") } if !IsCollection(y) { panic("Second parameter must be a collection") } hash := map[interface{}]struct{}{} xValue := reflect.ValueOf(x) xType := xValue.Type() yValue := reflect....
[ "func", "Intersect", "(", "x", "interface", "{", "}", ",", "y", "interface", "{", "}", ")", "interface", "{", "}", "{", "if", "!", "IsCollection", "(", "x", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "!", "IsCollection", "(",...
// Intersect returns the intersection between two collections.
[ "Intersect", "returns", "the", "intersection", "between", "two", "collections", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/intersection.go#L8-L45
train
thoas/go-funk
intersection.go
IntersectString
func IntersectString(x []string, y []string) []string { if len(x) == 0 || len(y) == 0 { return []string{} } set := []string{} hash := map[string]struct{}{} for _, v := range x { hash[v] = struct{}{} } for _, v := range y { _, ok := hash[v] if ok { set = append(set, v) } } return set }
go
func IntersectString(x []string, y []string) []string { if len(x) == 0 || len(y) == 0 { return []string{} } set := []string{} hash := map[string]struct{}{} for _, v := range x { hash[v] = struct{}{} } for _, v := range y { _, ok := hash[v] if ok { set = append(set, v) } } return set }
[ "func", "IntersectString", "(", "x", "[", "]", "string", ",", "y", "[", "]", "string", ")", "[", "]", "string", "{", "if", "len", "(", "x", ")", "==", "0", "||", "len", "(", "y", ")", "==", "0", "{", "return", "[", "]", "string", "{", "}", ...
// IntersectString returns the intersection between two collections of string.
[ "IntersectString", "returns", "the", "intersection", "between", "two", "collections", "of", "string", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/intersection.go#L48-L68
train
thoas/go-funk
helpers.go
ToFloat64
func ToFloat64(x interface{}) (float64, bool) { var xf float64 xok := true switch xn := x.(type) { case uint8: xf = float64(xn) case uint16: xf = float64(xn) case uint32: xf = float64(xn) case uint64: xf = float64(xn) case int: xf = float64(xn) case int8: xf = float64(xn) case int16: xf = float...
go
func ToFloat64(x interface{}) (float64, bool) { var xf float64 xok := true switch xn := x.(type) { case uint8: xf = float64(xn) case uint16: xf = float64(xn) case uint32: xf = float64(xn) case uint64: xf = float64(xn) case int: xf = float64(xn) case int8: xf = float64(xn) case int16: xf = float...
[ "func", "ToFloat64", "(", "x", "interface", "{", "}", ")", "(", "float64", ",", "bool", ")", "{", "var", "xf", "float64", "\n", "xok", ":=", "true", "\n\n", "switch", "xn", ":=", "x", ".", "(", "type", ")", "{", "case", "uint8", ":", "xf", "=", ...
// ToFloat64 converts any numeric value to float64.
[ "ToFloat64", "converts", "any", "numeric", "value", "to", "float64", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/helpers.go#L25-L57
train
thoas/go-funk
helpers.go
PtrOf
func PtrOf(itf interface{}) interface{} { t := reflect.TypeOf(itf) cp := reflect.New(t) cp.Elem().Set(reflect.ValueOf(itf)) // Avoid double pointers if itf is a pointer if t.Kind() == reflect.Ptr { return cp.Elem().Interface() } return cp.Interface() }
go
func PtrOf(itf interface{}) interface{} { t := reflect.TypeOf(itf) cp := reflect.New(t) cp.Elem().Set(reflect.ValueOf(itf)) // Avoid double pointers if itf is a pointer if t.Kind() == reflect.Ptr { return cp.Elem().Interface() } return cp.Interface() }
[ "func", "PtrOf", "(", "itf", "interface", "{", "}", ")", "interface", "{", "}", "{", "t", ":=", "reflect", ".", "TypeOf", "(", "itf", ")", "\n\n", "cp", ":=", "reflect", ".", "New", "(", "t", ")", "\n", "cp", ".", "Elem", "(", ")", ".", "Set", ...
// PtrOf makes a copy of the given interface and returns a pointer.
[ "PtrOf", "makes", "a", "copy", "of", "the", "given", "interface", "and", "returns", "a", "pointer", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/helpers.go#L60-L72
train
thoas/go-funk
helpers.go
IsFunction
func IsFunction(in interface{}, num ...int) bool { funcType := reflect.TypeOf(in) result := funcType.Kind() == reflect.Func if len(num) >= 1 { result = result && funcType.NumIn() == num[0] } if len(num) == 2 { result = result && funcType.NumOut() == num[1] } return result }
go
func IsFunction(in interface{}, num ...int) bool { funcType := reflect.TypeOf(in) result := funcType.Kind() == reflect.Func if len(num) >= 1 { result = result && funcType.NumIn() == num[0] } if len(num) == 2 { result = result && funcType.NumOut() == num[1] } return result }
[ "func", "IsFunction", "(", "in", "interface", "{", "}", ",", "num", "...", "int", ")", "bool", "{", "funcType", ":=", "reflect", ".", "TypeOf", "(", "in", ")", "\n\n", "result", ":=", "funcType", ".", "Kind", "(", ")", "==", "reflect", ".", "Func", ...
// IsFunction returns if the argument is a function.
[ "IsFunction", "returns", "if", "the", "argument", "is", "a", "function", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/helpers.go#L75-L89
train
thoas/go-funk
helpers.go
IsType
func IsType(expected interface{}, actual interface{}) bool { return IsEqual(reflect.TypeOf(expected), reflect.TypeOf(actual)) }
go
func IsType(expected interface{}, actual interface{}) bool { return IsEqual(reflect.TypeOf(expected), reflect.TypeOf(actual)) }
[ "func", "IsType", "(", "expected", "interface", "{", "}", ",", "actual", "interface", "{", "}", ")", "bool", "{", "return", "IsEqual", "(", "reflect", ".", "TypeOf", "(", "expected", ")", ",", "reflect", ".", "TypeOf", "(", "actual", ")", ")", "\n", ...
// IsType returns if the two objects are in the same type
[ "IsType", "returns", "if", "the", "two", "objects", "are", "in", "the", "same", "type" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/helpers.go#L115-L117
train
thoas/go-funk
helpers.go
IsIteratee
func IsIteratee(in interface{}) bool { if in == nil { return false } arrType := reflect.TypeOf(in) kind := arrType.Kind() return kind == reflect.Array || kind == reflect.Slice || kind == reflect.Map }
go
func IsIteratee(in interface{}) bool { if in == nil { return false } arrType := reflect.TypeOf(in) kind := arrType.Kind() return kind == reflect.Array || kind == reflect.Slice || kind == reflect.Map }
[ "func", "IsIteratee", "(", "in", "interface", "{", "}", ")", "bool", "{", "if", "in", "==", "nil", "{", "return", "false", "\n", "}", "\n", "arrType", ":=", "reflect", ".", "TypeOf", "(", "in", ")", "\n\n", "kind", ":=", "arrType", ".", "Kind", "("...
// IsIteratee returns if the argument is an iteratee.
[ "IsIteratee", "returns", "if", "the", "argument", "is", "an", "iteratee", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/helpers.go#L130-L139
train
thoas/go-funk
helpers.go
IsCollection
func IsCollection(in interface{}) bool { arrType := reflect.TypeOf(in) kind := arrType.Kind() return kind == reflect.Array || kind == reflect.Slice }
go
func IsCollection(in interface{}) bool { arrType := reflect.TypeOf(in) kind := arrType.Kind() return kind == reflect.Array || kind == reflect.Slice }
[ "func", "IsCollection", "(", "in", "interface", "{", "}", ")", "bool", "{", "arrType", ":=", "reflect", ".", "TypeOf", "(", "in", ")", "\n\n", "kind", ":=", "arrType", ".", "Kind", "(", ")", "\n\n", "return", "kind", "==", "reflect", ".", "Array", "|...
// IsCollection returns if the argument is a collection.
[ "IsCollection", "returns", "if", "the", "argument", "is", "a", "collection", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/helpers.go#L142-L148
train
thoas/go-funk
helpers.go
SliceOf
func SliceOf(in interface{}) interface{} { value := reflect.ValueOf(in) sliceType := reflect.SliceOf(reflect.TypeOf(in)) slice := reflect.New(sliceType) sliceValue := reflect.MakeSlice(sliceType, 0, 0) sliceValue = reflect.Append(sliceValue, value) slice.Elem().Set(sliceValue) return slice.Elem().Interface() }
go
func SliceOf(in interface{}) interface{} { value := reflect.ValueOf(in) sliceType := reflect.SliceOf(reflect.TypeOf(in)) slice := reflect.New(sliceType) sliceValue := reflect.MakeSlice(sliceType, 0, 0) sliceValue = reflect.Append(sliceValue, value) slice.Elem().Set(sliceValue) return slice.Elem().Interface() }
[ "func", "SliceOf", "(", "in", "interface", "{", "}", ")", "interface", "{", "}", "{", "value", ":=", "reflect", ".", "ValueOf", "(", "in", ")", "\n\n", "sliceType", ":=", "reflect", ".", "SliceOf", "(", "reflect", ".", "TypeOf", "(", "in", ")", ")", ...
// SliceOf returns a slice which contains the element.
[ "SliceOf", "returns", "a", "slice", "which", "contains", "the", "element", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/helpers.go#L151-L161
train
thoas/go-funk
helpers.go
Any
func Any(objs ...interface{}) bool { if len(objs) == 0 { return false } for _, obj := range objs { if !IsEmpty(obj) { return true } } return false }
go
func Any(objs ...interface{}) bool { if len(objs) == 0 { return false } for _, obj := range objs { if !IsEmpty(obj) { return true } } return false }
[ "func", "Any", "(", "objs", "...", "interface", "{", "}", ")", "bool", "{", "if", "len", "(", "objs", ")", "==", "0", "{", "return", "false", "\n", "}", "\n\n", "for", "_", ",", "obj", ":=", "range", "objs", "{", "if", "!", "IsEmpty", "(", "obj...
// Any returns true if any element of the iterable is not empty. If the iterable is empty, return False.
[ "Any", "returns", "true", "if", "any", "element", "of", "the", "iterable", "is", "not", "empty", ".", "If", "the", "iterable", "is", "empty", "return", "False", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/helpers.go#L164-L176
train
thoas/go-funk
helpers.go
IsEmpty
func IsEmpty(obj interface{}) bool { if obj == nil || obj == "" || obj == false { return true } for _, v := range numericZeros { if obj == v { return true } } objValue := reflect.ValueOf(obj) switch objValue.Kind() { case reflect.Map: fallthrough case reflect.Slice, reflect.Chan: return objValue...
go
func IsEmpty(obj interface{}) bool { if obj == nil || obj == "" || obj == false { return true } for _, v := range numericZeros { if obj == v { return true } } objValue := reflect.ValueOf(obj) switch objValue.Kind() { case reflect.Map: fallthrough case reflect.Slice, reflect.Chan: return objValue...
[ "func", "IsEmpty", "(", "obj", "interface", "{", "}", ")", "bool", "{", "if", "obj", "==", "nil", "||", "obj", "==", "\"", "\"", "||", "obj", "==", "false", "{", "return", "true", "\n", "}", "\n\n", "for", "_", ",", "v", ":=", "range", "numericZe...
// IsEmpty returns if the object is considered as empty or not.
[ "IsEmpty", "returns", "if", "the", "object", "is", "considered", "as", "empty", "or", "not", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/helpers.go#L194-L225
train
thoas/go-funk
helpers.go
IsZero
func IsZero(obj interface{}) bool { if obj == nil || obj == "" || obj == false { return true } for _, v := range numericZeros { if obj == v { return true } } return reflect.DeepEqual(obj, ZeroOf(obj)) }
go
func IsZero(obj interface{}) bool { if obj == nil || obj == "" || obj == false { return true } for _, v := range numericZeros { if obj == v { return true } } return reflect.DeepEqual(obj, ZeroOf(obj)) }
[ "func", "IsZero", "(", "obj", "interface", "{", "}", ")", "bool", "{", "if", "obj", "==", "nil", "||", "obj", "==", "\"", "\"", "||", "obj", "==", "false", "{", "return", "true", "\n", "}", "\n\n", "for", "_", ",", "v", ":=", "range", "numericZer...
// IsZero returns if the object is considered as zero value
[ "IsZero", "returns", "if", "the", "object", "is", "considered", "as", "zero", "value" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/helpers.go#L228-L240
train
thoas/go-funk
helpers.go
ZeroOf
func ZeroOf(in interface{}) interface{} { if in == nil { return nil } return reflect.Zero(reflect.TypeOf(in)).Interface() }
go
func ZeroOf(in interface{}) interface{} { if in == nil { return nil } return reflect.Zero(reflect.TypeOf(in)).Interface() }
[ "func", "ZeroOf", "(", "in", "interface", "{", "}", ")", "interface", "{", "}", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return", "reflect", ".", "Zero", "(", "reflect", ".", "TypeOf", "(", "in", ")", ")", ".", "Int...
// ZeroOf returns a zero value of an element.
[ "ZeroOf", "returns", "a", "zero", "value", "of", "an", "element", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/helpers.go#L248-L254
train
thoas/go-funk
helpers.go
RandomInt
func RandomInt(min, max int) int { return min + rand.Intn(max-min) }
go
func RandomInt(min, max int) int { return min + rand.Intn(max-min) }
[ "func", "RandomInt", "(", "min", ",", "max", "int", ")", "int", "{", "return", "min", "+", "rand", ".", "Intn", "(", "max", "-", "min", ")", "\n", "}" ]
// RandomInt generates a random int, based on a min and max values
[ "RandomInt", "generates", "a", "random", "int", "based", "on", "a", "min", "and", "max", "values" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/helpers.go#L257-L259
train
thoas/go-funk
helpers.go
Shard
func Shard(str string, width int, depth int, restOnly bool) []string { var results []string for i := 0; i < depth; i++ { results = append(results, str[(width*i):(width*(i+1))]) } if restOnly { results = append(results, str[(width*depth):]) } else { results = append(results, str) } return results }
go
func Shard(str string, width int, depth int, restOnly bool) []string { var results []string for i := 0; i < depth; i++ { results = append(results, str[(width*i):(width*(i+1))]) } if restOnly { results = append(results, str[(width*depth):]) } else { results = append(results, str) } return results }
[ "func", "Shard", "(", "str", "string", ",", "width", "int", ",", "depth", "int", ",", "restOnly", "bool", ")", "[", "]", "string", "{", "var", "results", "[", "]", "string", "\n\n", "for", "i", ":=", "0", ";", "i", "<", "depth", ";", "i", "++", ...
// Shard will shard a string name
[ "Shard", "will", "shard", "a", "string", "name" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/helpers.go#L262-L276
train
thoas/go-funk
helpers.go
RandomString
func RandomString(n int, allowedChars ...[]rune) string { var letters []rune if len(allowedChars) == 0 { letters = defaultLetters } else { letters = allowedChars[0] } b := make([]rune, n) for i := range b { b[i] = letters[rand.Intn(len(letters))] } return string(b) }
go
func RandomString(n int, allowedChars ...[]rune) string { var letters []rune if len(allowedChars) == 0 { letters = defaultLetters } else { letters = allowedChars[0] } b := make([]rune, n) for i := range b { b[i] = letters[rand.Intn(len(letters))] } return string(b) }
[ "func", "RandomString", "(", "n", "int", ",", "allowedChars", "...", "[", "]", "rune", ")", "string", "{", "var", "letters", "[", "]", "rune", "\n\n", "if", "len", "(", "allowedChars", ")", "==", "0", "{", "letters", "=", "defaultLetters", "\n", "}", ...
// RandomString returns a random string with a fixed length
[ "RandomString", "returns", "a", "random", "string", "with", "a", "fixed", "length" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/helpers.go#L281-L296
train
thoas/go-funk
transform.go
Chunk
func Chunk(arr interface{}, size int) interface{} { if !IsIteratee(arr) { panic("First parameter must be neither array nor slice") } arrValue := reflect.ValueOf(arr) arrType := arrValue.Type() resultSliceType := reflect.SliceOf(arrType) // Initialize final result slice which will contains slice resultSlice...
go
func Chunk(arr interface{}, size int) interface{} { if !IsIteratee(arr) { panic("First parameter must be neither array nor slice") } arrValue := reflect.ValueOf(arr) arrType := arrValue.Type() resultSliceType := reflect.SliceOf(arrType) // Initialize final result slice which will contains slice resultSlice...
[ "func", "Chunk", "(", "arr", "interface", "{", "}", ",", "size", "int", ")", "interface", "{", "}", "{", "if", "!", "IsIteratee", "(", "arr", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "arrValue", ":=", "reflect", ".", "ValueOf", ...
// Chunk creates an array of elements split into groups with the length of size. // If array can't be split evenly, the final chunk will be // the remaining element.
[ "Chunk", "creates", "an", "array", "of", "elements", "split", "into", "groups", "with", "the", "length", "of", "size", ".", "If", "array", "can", "t", "be", "split", "evenly", "the", "final", "chunk", "will", "be", "the", "remaining", "element", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/transform.go#L12-L51
train
thoas/go-funk
transform.go
Map
func Map(arr interface{}, mapFunc interface{}) interface{} { if !IsIteratee(arr) { panic("First parameter must be an iteratee") } if !IsFunction(mapFunc) { panic("Second argument must be function") } var ( funcValue = reflect.ValueOf(mapFunc) arrValue = reflect.ValueOf(arr) arrType = arrValue.Type()...
go
func Map(arr interface{}, mapFunc interface{}) interface{} { if !IsIteratee(arr) { panic("First parameter must be an iteratee") } if !IsFunction(mapFunc) { panic("Second argument must be function") } var ( funcValue = reflect.ValueOf(mapFunc) arrValue = reflect.ValueOf(arr) arrType = arrValue.Type()...
[ "func", "Map", "(", "arr", "interface", "{", "}", ",", "mapFunc", "interface", "{", "}", ")", "interface", "{", "}", "{", "if", "!", "IsIteratee", "(", "arr", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "!", "IsFunction", "(...
// Map manipulates an iteratee and transforms it to another type.
[ "Map", "manipulates", "an", "iteratee", "and", "transforms", "it", "to", "another", "type", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/transform.go#L193-L219
train
thoas/go-funk
transform.go
Shuffle
func Shuffle(in interface{}) interface{} { value := reflect.ValueOf(in) valueType := value.Type() kind := value.Kind() if kind == reflect.Array || kind == reflect.Slice { length := value.Len() resultSlice := makeSlice(value, length) for i, v := range rand.Perm(length) { resultSlice.Index(i).Set(value.I...
go
func Shuffle(in interface{}) interface{} { value := reflect.ValueOf(in) valueType := value.Type() kind := value.Kind() if kind == reflect.Array || kind == reflect.Slice { length := value.Len() resultSlice := makeSlice(value, length) for i, v := range rand.Perm(length) { resultSlice.Index(i).Set(value.I...
[ "func", "Shuffle", "(", "in", "interface", "{", "}", ")", "interface", "{", "}", "{", "value", ":=", "reflect", ".", "ValueOf", "(", "in", ")", "\n", "valueType", ":=", "value", ".", "Type", "(", ")", "\n\n", "kind", ":=", "value", ".", "Kind", "("...
// Shuffle creates an array of shuffled values
[ "Shuffle", "creates", "an", "array", "of", "shuffled", "values" ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/transform.go#L252-L271
train
thoas/go-funk
transform.go
Reverse
func Reverse(in interface{}) interface{} { value := reflect.ValueOf(in) valueType := value.Type() kind := value.Kind() if kind == reflect.String { return ReverseString(in.(string)) } if kind == reflect.Array || kind == reflect.Slice { length := value.Len() resultSlice := makeSlice(value, length) j :=...
go
func Reverse(in interface{}) interface{} { value := reflect.ValueOf(in) valueType := value.Type() kind := value.Kind() if kind == reflect.String { return ReverseString(in.(string)) } if kind == reflect.Array || kind == reflect.Slice { length := value.Len() resultSlice := makeSlice(value, length) j :=...
[ "func", "Reverse", "(", "in", "interface", "{", "}", ")", "interface", "{", "}", "{", "value", ":=", "reflect", ".", "ValueOf", "(", "in", ")", "\n", "valueType", ":=", "value", ".", "Type", "(", ")", "\n\n", "kind", ":=", "value", ".", "Kind", "("...
// Reverse transforms an array the first element will become the last, // the second element will become the second to last, etc.
[ "Reverse", "transforms", "an", "array", "the", "first", "element", "will", "become", "the", "last", "the", "second", "element", "will", "become", "the", "second", "to", "last", "etc", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/transform.go#L275-L300
train
thoas/go-funk
transform.go
Uniq
func Uniq(in interface{}) interface{} { value := reflect.ValueOf(in) valueType := value.Type() kind := value.Kind() if kind == reflect.Array || kind == reflect.Slice { length := value.Len() seen := make(map[interface{}]bool, length) j := 0 for i := 0; i < length; i++ { val := value.Index(i) v := v...
go
func Uniq(in interface{}) interface{} { value := reflect.ValueOf(in) valueType := value.Type() kind := value.Kind() if kind == reflect.Array || kind == reflect.Slice { length := value.Len() seen := make(map[interface{}]bool, length) j := 0 for i := 0; i < length; i++ { val := value.Index(i) v := v...
[ "func", "Uniq", "(", "in", "interface", "{", "}", ")", "interface", "{", "}", "{", "value", ":=", "reflect", ".", "ValueOf", "(", "in", ")", "\n", "valueType", ":=", "value", ".", "Type", "(", ")", "\n\n", "kind", ":=", "value", ".", "Kind", "(", ...
// Uniq creates an array with unique values.
[ "Uniq", "creates", "an", "array", "with", "unique", "values", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/transform.go#L303-L332
train
thoas/go-funk
transform.go
ConvertSlice
func ConvertSlice(in interface{}, out interface{}) { srcValue := reflect.ValueOf(in) dstValue := reflect.ValueOf(out) if dstValue.Kind() != reflect.Ptr { panic("Second argument must be a pointer") } dstValue = dstValue.Elem() if srcValue.Kind() != reflect.Slice && srcValue.Kind() != reflect.Array { panic(...
go
func ConvertSlice(in interface{}, out interface{}) { srcValue := reflect.ValueOf(in) dstValue := reflect.ValueOf(out) if dstValue.Kind() != reflect.Ptr { panic("Second argument must be a pointer") } dstValue = dstValue.Elem() if srcValue.Kind() != reflect.Slice && srcValue.Kind() != reflect.Array { panic(...
[ "func", "ConvertSlice", "(", "in", "interface", "{", "}", ",", "out", "interface", "{", "}", ")", "{", "srcValue", ":=", "reflect", ".", "ValueOf", "(", "in", ")", "\n\n", "dstValue", ":=", "reflect", ".", "ValueOf", "(", "out", ")", "\n\n", "if", "d...
// ConvertSlice converts a slice type to another, // a perfect example would be to convert a slice of struct to a slice of interface.
[ "ConvertSlice", "converts", "a", "slice", "type", "to", "another", "a", "perfect", "example", "would", "be", "to", "convert", "a", "slice", "of", "struct", "to", "a", "slice", "of", "interface", "." ]
a0a199e85d6d961670e46df4998f8868a3e3309b
https://github.com/thoas/go-funk/blob/a0a199e85d6d961670e46df4998f8868a3e3309b/transform.go#L336-L365
train
genuinetools/reg
registry/customtransport.go
RoundTrip
func (t *CustomTransport) RoundTrip(request *http.Request) (*http.Response, error) { if len(t.Headers) != 0 { for header, value := range t.Headers { request.Header.Add(header, value) } } resp, err := t.Transport.RoundTrip(request) return resp, err }
go
func (t *CustomTransport) RoundTrip(request *http.Request) (*http.Response, error) { if len(t.Headers) != 0 { for header, value := range t.Headers { request.Header.Add(header, value) } } resp, err := t.Transport.RoundTrip(request) return resp, err }
[ "func", "(", "t", "*", "CustomTransport", ")", "RoundTrip", "(", "request", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "if", "len", "(", "t", ".", "Headers", ")", "!=", "0", "{", "for", "header", ...
// RoundTrip defines the round tripper for the error transport.
[ "RoundTrip", "defines", "the", "round", "tripper", "for", "the", "error", "transport", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/customtransport.go#L14-L24
train
genuinetools/reg
registry/image.go
Reference
func (i Image) Reference() string { if len(i.Digest.String()) > 1 { return i.Digest.String() } return i.Tag }
go
func (i Image) Reference() string { if len(i.Digest.String()) > 1 { return i.Digest.String() } return i.Tag }
[ "func", "(", "i", "Image", ")", "Reference", "(", ")", "string", "{", "if", "len", "(", "i", ".", "Digest", ".", "String", "(", ")", ")", ">", "1", "{", "return", "i", ".", "Digest", ".", "String", "(", ")", "\n", "}", "\n\n", "return", "i", ...
// Reference returns either the digest if it is non-empty or the tag for the image.
[ "Reference", "returns", "either", "the", "digest", "if", "it", "is", "non", "-", "empty", "or", "the", "tag", "for", "the", "image", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/image.go#L25-L31
train
genuinetools/reg
registry/image.go
WithDigest
func (i *Image) WithDigest(digest digest.Digest) (err error) { i.Digest = digest i.named, err = reference.WithDigest(i.named, digest) return err }
go
func (i *Image) WithDigest(digest digest.Digest) (err error) { i.Digest = digest i.named, err = reference.WithDigest(i.named, digest) return err }
[ "func", "(", "i", "*", "Image", ")", "WithDigest", "(", "digest", "digest", ".", "Digest", ")", "(", "err", "error", ")", "{", "i", ".", "Digest", "=", "digest", "\n", "i", ".", "named", ",", "err", "=", "reference", ".", "WithDigest", "(", "i", ...
// WithDigest sets the digest for an image.
[ "WithDigest", "sets", "the", "digest", "for", "an", "image", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/image.go#L34-L38
train
genuinetools/reg
registry/image.go
ParseImage
func ParseImage(image string) (Image, error) { // Parse the image name and tag. named, err := reference.ParseNormalizedNamed(image) if err != nil { return Image{}, fmt.Errorf("parsing image %q failed: %v", image, err) } // Add the latest lag if they did not provide one. named = reference.TagNameOnly(named) i ...
go
func ParseImage(image string) (Image, error) { // Parse the image name and tag. named, err := reference.ParseNormalizedNamed(image) if err != nil { return Image{}, fmt.Errorf("parsing image %q failed: %v", image, err) } // Add the latest lag if they did not provide one. named = reference.TagNameOnly(named) i ...
[ "func", "ParseImage", "(", "image", "string", ")", "(", "Image", ",", "error", ")", "{", "// Parse the image name and tag.", "named", ",", "err", ":=", "reference", ".", "ParseNormalizedNamed", "(", "image", ")", "\n", "if", "err", "!=", "nil", "{", "return"...
// ParseImage returns an Image struct with all the values filled in for a given image.
[ "ParseImage", "returns", "an", "Image", "struct", "with", "all", "the", "values", "filled", "in", "for", "a", "given", "image", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/image.go#L41-L67
train
genuinetools/reg
registry/tags.go
Tags
func (r *Registry) Tags(ctx context.Context, repository string) ([]string, error) { url := r.url("/v2/%s/tags/list", repository) r.Logf("registry.tags url=%s repository=%s", url, repository) var response tagsResponse if _, err := r.getJSON(ctx, url, &response); err != nil { return nil, err } return response.T...
go
func (r *Registry) Tags(ctx context.Context, repository string) ([]string, error) { url := r.url("/v2/%s/tags/list", repository) r.Logf("registry.tags url=%s repository=%s", url, repository) var response tagsResponse if _, err := r.getJSON(ctx, url, &response); err != nil { return nil, err } return response.T...
[ "func", "(", "r", "*", "Registry", ")", "Tags", "(", "ctx", "context", ".", "Context", ",", "repository", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "url", ":=", "r", ".", "url", "(", "\"", "\"", ",", "repository", ")", "\n",...
// Tags returns the tags for a specific repository.
[ "Tags", "returns", "the", "tags", "for", "a", "specific", "repository", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/tags.go#L10-L20
train
genuinetools/reg
registry/ping.go
Ping
func (r *Registry) Ping(ctx context.Context) error { url := r.url("/v2/") r.Logf("registry.ping url=%s", url) req, err := http.NewRequest("GET", url, nil) if err != nil { return err } resp, err := r.Client.Do(req.WithContext(ctx)) if resp != nil { defer resp.Body.Close() } return err }
go
func (r *Registry) Ping(ctx context.Context) error { url := r.url("/v2/") r.Logf("registry.ping url=%s", url) req, err := http.NewRequest("GET", url, nil) if err != nil { return err } resp, err := r.Client.Do(req.WithContext(ctx)) if resp != nil { defer resp.Body.Close() } return err }
[ "func", "(", "r", "*", "Registry", ")", "Ping", "(", "ctx", "context", ".", "Context", ")", "error", "{", "url", ":=", "r", ".", "url", "(", "\"", "\"", ")", "\n", "r", ".", "Logf", "(", "\"", "\"", ",", "url", ")", "\n", "req", ",", "err", ...
// Ping tries to contact a registry URL to make sure it is up and accessible.
[ "Ping", "tries", "to", "contact", "a", "registry", "URL", "to", "make", "sure", "it", "is", "up", "and", "accessible", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/ping.go#L9-L21
train
genuinetools/reg
clair/vulns.go
Vulnerabilities
func (c *Clair) Vulnerabilities(ctx context.Context, r *registry.Registry, repo, tag string) (VulnerabilityReport, error) { report := VulnerabilityReport{ RegistryURL: r.Domain, Repo: repo, Tag: tag, Date: time.Now().Local().Format(time.RFC1123), VulnsBySeverity: make(ma...
go
func (c *Clair) Vulnerabilities(ctx context.Context, r *registry.Registry, repo, tag string) (VulnerabilityReport, error) { report := VulnerabilityReport{ RegistryURL: r.Domain, Repo: repo, Tag: tag, Date: time.Now().Local().Format(time.RFC1123), VulnsBySeverity: make(ma...
[ "func", "(", "c", "*", "Clair", ")", "Vulnerabilities", "(", "ctx", "context", ".", "Context", ",", "r", "*", "registry", ".", "Registry", ",", "repo", ",", "tag", "string", ")", "(", "VulnerabilityReport", ",", "error", ")", "{", "report", ":=", "Vuln...
// Vulnerabilities scans the given repo and tag.
[ "Vulnerabilities", "scans", "the", "given", "repo", "and", "tag", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/clair/vulns.go#L14-L77
train
genuinetools/reg
clair/layer.go
GetLayer
func (c *Clair) GetLayer(ctx context.Context, name string, features, vulnerabilities bool) (*Layer, error) { url := c.url("/v1/layers/%s?features=%t&vulnerabilities=%t", name, features, vulnerabilities) c.Logf("clair.layers.get url=%s name=%s", url, name) var respLayer layerEnvelope if _, err := c.getJSON(ctx, url...
go
func (c *Clair) GetLayer(ctx context.Context, name string, features, vulnerabilities bool) (*Layer, error) { url := c.url("/v1/layers/%s?features=%t&vulnerabilities=%t", name, features, vulnerabilities) c.Logf("clair.layers.get url=%s name=%s", url, name) var respLayer layerEnvelope if _, err := c.getJSON(ctx, url...
[ "func", "(", "c", "*", "Clair", ")", "GetLayer", "(", "ctx", "context", ".", "Context", ",", "name", "string", ",", "features", ",", "vulnerabilities", "bool", ")", "(", "*", "Layer", ",", "error", ")", "{", "url", ":=", "c", ".", "url", "(", "\"",...
// GetLayer displays a Layer and optionally all of its features and vulnerabilities.
[ "GetLayer", "displays", "a", "Layer", "and", "optionally", "all", "of", "its", "features", "and", "vulnerabilities", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/clair/layer.go#L12-L26
train
genuinetools/reg
clair/layer.go
PostLayer
func (c *Clair) PostLayer(ctx context.Context, layer *Layer) (*Layer, error) { url := c.url("/v1/layers") c.Logf("clair.layers.post url=%s name=%s", url, layer.Name) b, err := json.Marshal(layerEnvelope{Layer: layer}) if err != nil { return nil, err } c.Logf("clair.layers.post req.Body=%s", string(b)) req, ...
go
func (c *Clair) PostLayer(ctx context.Context, layer *Layer) (*Layer, error) { url := c.url("/v1/layers") c.Logf("clair.layers.post url=%s name=%s", url, layer.Name) b, err := json.Marshal(layerEnvelope{Layer: layer}) if err != nil { return nil, err } c.Logf("clair.layers.post req.Body=%s", string(b)) req, ...
[ "func", "(", "c", "*", "Clair", ")", "PostLayer", "(", "ctx", "context", ".", "Context", ",", "layer", "*", "Layer", ")", "(", "*", "Layer", ",", "error", ")", "{", "url", ":=", "c", ".", "url", "(", "\"", "\"", ")", "\n", "c", ".", "Logf", "...
// PostLayer performs the analysis of a Layer from the provided path.
[ "PostLayer", "performs", "the", "analysis", "of", "a", "Layer", "from", "the", "provided", "path", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/clair/layer.go#L29-L65
train
genuinetools/reg
clair/layer.go
DeleteLayer
func (c *Clair) DeleteLayer(ctx context.Context, name string) error { url := c.url("/v1/layers/%s", name) c.Logf("clair.layers.delete url=%s name=%s", url, name) req, err := http.NewRequest("DELETE", url, nil) if err != nil { return err } resp, err := c.Client.Do(req.WithContext(ctx)) if err != nil { retur...
go
func (c *Clair) DeleteLayer(ctx context.Context, name string) error { url := c.url("/v1/layers/%s", name) c.Logf("clair.layers.delete url=%s name=%s", url, name) req, err := http.NewRequest("DELETE", url, nil) if err != nil { return err } resp, err := c.Client.Do(req.WithContext(ctx)) if err != nil { retur...
[ "func", "(", "c", "*", "Clair", ")", "DeleteLayer", "(", "ctx", "context", ".", "Context", ",", "name", "string", ")", "error", "{", "url", ":=", "c", ".", "url", "(", "\"", "\"", ",", "name", ")", "\n", "c", ".", "Logf", "(", "\"", "\"", ",", ...
// DeleteLayer removes a layer reference from clair.
[ "DeleteLayer", "removes", "a", "layer", "reference", "from", "clair", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/clair/layer.go#L68-L89
train
genuinetools/reg
registry/catalog.go
Catalog
func (r *Registry) Catalog(ctx context.Context, u string) ([]string, error) { if u == "" { u = "/v2/_catalog" } uri := r.url(u) r.Logf("registry.catalog url=%s", uri) var response catalogResponse h, err := r.getJSON(ctx, uri, &response) if err != nil { return nil, err } for _, l := range link.ParseHeader...
go
func (r *Registry) Catalog(ctx context.Context, u string) ([]string, error) { if u == "" { u = "/v2/_catalog" } uri := r.url(u) r.Logf("registry.catalog url=%s", uri) var response catalogResponse h, err := r.getJSON(ctx, uri, &response) if err != nil { return nil, err } for _, l := range link.ParseHeader...
[ "func", "(", "r", "*", "Registry", ")", "Catalog", "(", "ctx", "context", ".", "Context", ",", "u", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "if", "u", "==", "\"", "\"", "{", "u", "=", "\"", "\"", "\n", "}", "\n", "uri"...
// Catalog returns the repositories in a registry.
[ "Catalog", "returns", "the", "repositories", "in", "a", "registry", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/catalog.go#L15-L40
train
genuinetools/reg
registry/tokentransport.go
RoundTrip
func (t *TokenTransport) RoundTrip(req *http.Request) (*http.Response, error) { resp, err := t.Transport.RoundTrip(req) if err != nil { return resp, err } authService, err := isTokenDemand(resp) if err != nil { resp.Body.Close() return nil, err } if authService == nil { return resp, nil } resp.Body....
go
func (t *TokenTransport) RoundTrip(req *http.Request) (*http.Response, error) { resp, err := t.Transport.RoundTrip(req) if err != nil { return resp, err } authService, err := isTokenDemand(resp) if err != nil { resp.Body.Close() return nil, err } if authService == nil { return resp, nil } resp.Body....
[ "func", "(", "t", "*", "TokenTransport", ")", "RoundTrip", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "resp", ",", "err", ":=", "t", ".", "Transport", ".", "RoundTrip", "(", "req", ")", ...
// RoundTrip defines the round tripper for token transport.
[ "RoundTrip", "defines", "the", "round", "tripper", "for", "token", "transport", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/tokentransport.go#L25-L44
train
genuinetools/reg
registry/tokentransport.go
Token
func (r *Registry) Token(ctx context.Context, url string) (string, error) { r.Logf("registry.token url=%s", url) req, err := http.NewRequest("GET", url, nil) if err != nil { return "", err } client := http.DefaultClient if r.Opt.Insecure { client = &http.Client{ Timeout: r.Opt.Timeout, Transport: &htt...
go
func (r *Registry) Token(ctx context.Context, url string) (string, error) { r.Logf("registry.token url=%s", url) req, err := http.NewRequest("GET", url, nil) if err != nil { return "", err } client := http.DefaultClient if r.Opt.Insecure { client = &http.Client{ Timeout: r.Opt.Timeout, Transport: &htt...
[ "func", "(", "r", "*", "Registry", ")", "Token", "(", "ctx", "context", ".", "Context", ",", "url", "string", ")", "(", "string", ",", "error", ")", "{", "r", ".", "Logf", "(", "\"", "\"", ",", "url", ")", "\n\n", "req", ",", "err", ":=", "http...
// Token returns the required token for the specific resource url. If the registry requires basic authentication, this // function returns ErrBasicAuth.
[ "Token", "returns", "the", "required", "token", "for", "the", "specific", "resource", "url", ".", "If", "the", "registry", "requires", "basic", "authentication", "this", "function", "returns", "ErrBasicAuth", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/tokentransport.go#L144-L207
train
genuinetools/reg
registry/tokentransport.go
Headers
func (r *Registry) Headers(ctx context.Context, uri string) (map[string]string, error) { // Get the token. token, err := r.Token(ctx, uri) if err != nil { if err == ErrBasicAuth { // If we couldn't get a token because the server requires basic auth, just return basic auth headers. return map[string]string{ ...
go
func (r *Registry) Headers(ctx context.Context, uri string) (map[string]string, error) { // Get the token. token, err := r.Token(ctx, uri) if err != nil { if err == ErrBasicAuth { // If we couldn't get a token because the server requires basic auth, just return basic auth headers. return map[string]string{ ...
[ "func", "(", "r", "*", "Registry", ")", "Headers", "(", "ctx", "context", ".", "Context", ",", "uri", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "// Get the token.", "token", ",", "err", ":=", "r", ".", "Token", ...
// Headers returns the authorization headers for a specific uri.
[ "Headers", "returns", "the", "authorization", "headers", "for", "a", "specific", "uri", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/tokentransport.go#L210-L230
train
genuinetools/reg
registry/layer.go
DownloadLayer
func (r *Registry) DownloadLayer(ctx context.Context, repository string, digest digest.Digest) (io.ReadCloser, error) { url := r.url("/v2/%s/blobs/%s", repository, digest) r.Logf("registry.layer.download url=%s repository=%s digest=%s", url, repository, digest) req, err := http.NewRequest("GET", url, nil) if err !...
go
func (r *Registry) DownloadLayer(ctx context.Context, repository string, digest digest.Digest) (io.ReadCloser, error) { url := r.url("/v2/%s/blobs/%s", repository, digest) r.Logf("registry.layer.download url=%s repository=%s digest=%s", url, repository, digest) req, err := http.NewRequest("GET", url, nil) if err !...
[ "func", "(", "r", "*", "Registry", ")", "DownloadLayer", "(", "ctx", "context", ".", "Context", ",", "repository", "string", ",", "digest", "digest", ".", "Digest", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "url", ":=", "r", ".", "ur...
// DownloadLayer downloads a specific layer by digest for a repository.
[ "DownloadLayer", "downloads", "a", "specific", "layer", "by", "digest", "for", "a", "repository", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/layer.go#L16-L30
train
genuinetools/reg
registry/layer.go
UploadLayer
func (r *Registry) UploadLayer(ctx context.Context, repository string, digest reference.Reference, content io.Reader) error { uploadURL, token, err := r.initiateUpload(ctx, repository) if err != nil { return err } q := uploadURL.Query() q.Set("digest", digest.String()) uploadURL.RawQuery = q.Encode() r.Logf("...
go
func (r *Registry) UploadLayer(ctx context.Context, repository string, digest reference.Reference, content io.Reader) error { uploadURL, token, err := r.initiateUpload(ctx, repository) if err != nil { return err } q := uploadURL.Query() q.Set("digest", digest.String()) uploadURL.RawQuery = q.Encode() r.Logf("...
[ "func", "(", "r", "*", "Registry", ")", "UploadLayer", "(", "ctx", "context", ".", "Context", ",", "repository", "string", ",", "digest", "reference", ".", "Reference", ",", "content", "io", ".", "Reader", ")", "error", "{", "uploadURL", ",", "token", ",...
// UploadLayer uploads a specific layer by digest for a repository.
[ "UploadLayer", "uploads", "a", "specific", "layer", "by", "digest", "for", "a", "repository", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/layer.go#L33-L53
train
genuinetools/reg
registry/layer.go
HasLayer
func (r *Registry) HasLayer(ctx context.Context, repository string, digest digest.Digest) (bool, error) { checkURL := r.url("/v2/%s/blobs/%s", repository, digest) r.Logf("registry.layer.check url=%s repository=%s digest=%s", checkURL, repository, digest) req, err := http.NewRequest("HEAD", checkURL, nil) if err !=...
go
func (r *Registry) HasLayer(ctx context.Context, repository string, digest digest.Digest) (bool, error) { checkURL := r.url("/v2/%s/blobs/%s", repository, digest) r.Logf("registry.layer.check url=%s repository=%s digest=%s", checkURL, repository, digest) req, err := http.NewRequest("HEAD", checkURL, nil) if err !=...
[ "func", "(", "r", "*", "Registry", ")", "HasLayer", "(", "ctx", "context", ".", "Context", ",", "repository", "string", ",", "digest", "digest", ".", "Digest", ")", "(", "bool", ",", "error", ")", "{", "checkURL", ":=", "r", ".", "url", "(", "\"", ...
// HasLayer returns if the registry contains the specific digest for a repository.
[ "HasLayer", "returns", "if", "the", "registry", "contains", "the", "specific", "digest", "for", "a", "repository", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/layer.go#L56-L83
train
genuinetools/reg
repoutils/repoutils.go
GetAuthConfig
func GetAuthConfig(username, password, registry string) (types.AuthConfig, error) { if username != "" && password != "" && registry != "" { return types.AuthConfig{ Username: username, Password: password, ServerAddress: registry, }, nil } dcfg, err := config.Load(config.Dir()) if err != nil ...
go
func GetAuthConfig(username, password, registry string) (types.AuthConfig, error) { if username != "" && password != "" && registry != "" { return types.AuthConfig{ Username: username, Password: password, ServerAddress: registry, }, nil } dcfg, err := config.Load(config.Dir()) if err != nil ...
[ "func", "GetAuthConfig", "(", "username", ",", "password", ",", "registry", "string", ")", "(", "types", ".", "AuthConfig", ",", "error", ")", "{", "if", "username", "!=", "\"", "\"", "&&", "password", "!=", "\"", "\"", "&&", "registry", "!=", "\"", "\...
// GetAuthConfig returns the docker registry AuthConfig. // Optionally takes in the authentication values, otherwise pulls them from the // docker config file.
[ "GetAuthConfig", "returns", "the", "docker", "registry", "AuthConfig", ".", "Optionally", "takes", "in", "the", "authentication", "values", "otherwise", "pulls", "them", "from", "the", "docker", "config", "file", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/repoutils/repoutils.go#L23-L110
train
genuinetools/reg
repoutils/repoutils.go
GetRepoAndRef
func GetRepoAndRef(image string) (repo, ref string, err error) { if image == "" { return "", "", reference.ErrNameEmpty } image = addLatestTagSuffix(image) var parts []string if strings.Contains(image, "@") { parts = strings.Split(image, "@") } else if strings.Contains(image, ":") { parts = strings.Split(...
go
func GetRepoAndRef(image string) (repo, ref string, err error) { if image == "" { return "", "", reference.ErrNameEmpty } image = addLatestTagSuffix(image) var parts []string if strings.Contains(image, "@") { parts = strings.Split(image, "@") } else if strings.Contains(image, ":") { parts = strings.Split(...
[ "func", "GetRepoAndRef", "(", "image", "string", ")", "(", "repo", ",", "ref", "string", ",", "err", "error", ")", "{", "if", "image", "==", "\"", "\"", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "reference", ".", "ErrNameEmpty", "\n", "}", "...
// GetRepoAndRef parses the repo name and reference.
[ "GetRepoAndRef", "parses", "the", "repo", "name", "and", "reference", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/repoutils/repoutils.go#L123-L143
train
genuinetools/reg
registry/digest.go
Digest
func (r *Registry) Digest(ctx context.Context, image Image) (digest.Digest, error) { if len(image.Digest) > 1 { // return early if we already have an image digest. return image.Digest, nil } url := r.url("/v2/%s/manifests/%s", image.Path, image.Tag) r.Logf("registry.manifests.get url=%s repository=%s ref=%s", ...
go
func (r *Registry) Digest(ctx context.Context, image Image) (digest.Digest, error) { if len(image.Digest) > 1 { // return early if we already have an image digest. return image.Digest, nil } url := r.url("/v2/%s/manifests/%s", image.Path, image.Tag) r.Logf("registry.manifests.get url=%s repository=%s ref=%s", ...
[ "func", "(", "r", "*", "Registry", ")", "Digest", "(", "ctx", "context", ".", "Context", ",", "image", "Image", ")", "(", "digest", ".", "Digest", ",", "error", ")", "{", "if", "len", "(", "image", ".", "Digest", ")", ">", "1", "{", "// return earl...
// Digest returns the digest for an image.
[ "Digest", "returns", "the", "digest", "for", "an", "image", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/digest.go#L13-L40
train
genuinetools/reg
clair/layerutil.go
NewClairLayer
func (c *Clair) NewClairLayer(ctx context.Context, r *registry.Registry, image string, fsLayers map[int]distribution.Descriptor, index int) (*Layer, error) { var parentName string if index < len(fsLayers)-1 { parentName = fsLayers[index+1].Digest.String() } // Form the path. p := strings.Join([]string{r.URL, "v...
go
func (c *Clair) NewClairLayer(ctx context.Context, r *registry.Registry, image string, fsLayers map[int]distribution.Descriptor, index int) (*Layer, error) { var parentName string if index < len(fsLayers)-1 { parentName = fsLayers[index+1].Digest.String() } // Form the path. p := strings.Join([]string{r.URL, "v...
[ "func", "(", "c", "*", "Clair", ")", "NewClairLayer", "(", "ctx", "context", ".", "Context", ",", "r", "*", "registry", ".", "Registry", ",", "image", "string", ",", "fsLayers", "map", "[", "int", "]", "distribution", ".", "Descriptor", ",", "index", "...
// NewClairLayer will form a layer struct required for a clair scan.
[ "NewClairLayer", "will", "form", "a", "layer", "struct", "required", "for", "a", "clair", "scan", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/clair/layerutil.go#L14-L36
train
genuinetools/reg
clair/layerutil.go
NewClairV3Layer
func (c *Clair) NewClairV3Layer(ctx context.Context, r *registry.Registry, image string, fsLayer distribution.Descriptor) (*clairpb.PostAncestryRequest_PostLayer, error) { // Form the path. p := strings.Join([]string{r.URL, "v2", image, "blobs", fsLayer.Digest.String()}, "/") // Get the headers. h, err := r.Header...
go
func (c *Clair) NewClairV3Layer(ctx context.Context, r *registry.Registry, image string, fsLayer distribution.Descriptor) (*clairpb.PostAncestryRequest_PostLayer, error) { // Form the path. p := strings.Join([]string{r.URL, "v2", image, "blobs", fsLayer.Digest.String()}, "/") // Get the headers. h, err := r.Header...
[ "func", "(", "c", "*", "Clair", ")", "NewClairV3Layer", "(", "ctx", "context", ".", "Context", ",", "r", "*", "registry", ".", "Registry", ",", "image", "string", ",", "fsLayer", "distribution", ".", "Descriptor", ")", "(", "*", "clairpb", ".", "PostAnce...
// NewClairV3Layer will form a layer struct required for a clair scan.
[ "NewClairV3Layer", "will", "form", "a", "layer", "struct", "required", "for", "a", "clair", "scan", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/clair/layerutil.go#L39-L54
train
genuinetools/reg
registry/registry.go
New
func New(ctx context.Context, auth types.AuthConfig, opt Opt) (*Registry, error) { transport := http.DefaultTransport if opt.Insecure { transport = &http.Transport{ TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, }, } } return newFromTransport(ctx, auth, transport, opt) }
go
func New(ctx context.Context, auth types.AuthConfig, opt Opt) (*Registry, error) { transport := http.DefaultTransport if opt.Insecure { transport = &http.Transport{ TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, }, } } return newFromTransport(ctx, auth, transport, opt) }
[ "func", "New", "(", "ctx", "context", ".", "Context", ",", "auth", "types", ".", "AuthConfig", ",", "opt", "Opt", ")", "(", "*", "Registry", ",", "error", ")", "{", "transport", ":=", "http", ".", "DefaultTransport", "\n\n", "if", "opt", ".", "Insecure...
// New creates a new Registry struct with the given URL and credentials.
[ "New", "creates", "a", "new", "Registry", "struct", "with", "the", "given", "URL", "and", "credentials", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/registry.go#L55-L67
train
genuinetools/reg
registry/registry.go
url
func (r *Registry) url(pathTemplate string, args ...interface{}) string { pathSuffix := fmt.Sprintf(pathTemplate, args...) url := fmt.Sprintf("%s%s", r.URL, pathSuffix) return url }
go
func (r *Registry) url(pathTemplate string, args ...interface{}) string { pathSuffix := fmt.Sprintf(pathTemplate, args...) url := fmt.Sprintf("%s%s", r.URL, pathSuffix) return url }
[ "func", "(", "r", "*", "Registry", ")", "url", "(", "pathTemplate", "string", ",", "args", "...", "interface", "{", "}", ")", "string", "{", "pathSuffix", ":=", "fmt", ".", "Sprintf", "(", "pathTemplate", ",", "args", "...", ")", "\n", "url", ":=", "...
// url returns a registry URL with the passed arguements concatenated.
[ "url", "returns", "a", "registry", "URL", "with", "the", "passed", "arguements", "concatenated", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/registry.go#L140-L144
train
genuinetools/reg
clair/ancestry.go
GetAncestry
func (c *Clair) GetAncestry(ctx context.Context, name string) (*clairpb.GetAncestryResponse_Ancestry, error) { c.Logf("clair.ancestry.get name=%s", name) if c.grpcConn == nil { return nil, ErrNilGRPCConn } client := clairpb.NewAncestryServiceClient(c.grpcConn) resp, err := client.GetAncestry(ctx, &clairpb.Get...
go
func (c *Clair) GetAncestry(ctx context.Context, name string) (*clairpb.GetAncestryResponse_Ancestry, error) { c.Logf("clair.ancestry.get name=%s", name) if c.grpcConn == nil { return nil, ErrNilGRPCConn } client := clairpb.NewAncestryServiceClient(c.grpcConn) resp, err := client.GetAncestry(ctx, &clairpb.Get...
[ "func", "(", "c", "*", "Clair", ")", "GetAncestry", "(", "ctx", "context", ".", "Context", ",", "name", "string", ")", "(", "*", "clairpb", ".", "GetAncestryResponse_Ancestry", ",", "error", ")", "{", "c", ".", "Logf", "(", "\"", "\"", ",", "name", "...
// GetAncestry displays an ancestry and all of its features and vulnerabilities.
[ "GetAncestry", "displays", "an", "ancestry", "and", "all", "of", "its", "features", "and", "vulnerabilities", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/clair/ancestry.go#L16-L41
train
genuinetools/reg
clair/ancestry.go
PostAncestry
func (c *Clair) PostAncestry(ctx context.Context, name string, layers []*clairpb.PostAncestryRequest_PostLayer) error { c.Logf("clair.ancestry.post name=%s", name) if c.grpcConn == nil { return ErrNilGRPCConn } client := clairpb.NewAncestryServiceClient(c.grpcConn) resp, err := client.PostAncestry(ctx, &clair...
go
func (c *Clair) PostAncestry(ctx context.Context, name string, layers []*clairpb.PostAncestryRequest_PostLayer) error { c.Logf("clair.ancestry.post name=%s", name) if c.grpcConn == nil { return ErrNilGRPCConn } client := clairpb.NewAncestryServiceClient(c.grpcConn) resp, err := client.PostAncestry(ctx, &clair...
[ "func", "(", "c", "*", "Clair", ")", "PostAncestry", "(", "ctx", "context", ".", "Context", ",", "name", "string", ",", "layers", "[", "]", "*", "clairpb", ".", "PostAncestryRequest_PostLayer", ")", "error", "{", "c", ".", "Logf", "(", "\"", "\"", ",",...
// PostAncestry performs the analysis of all layers from the provided path.
[ "PostAncestry", "performs", "the", "analysis", "of", "all", "layers", "from", "the", "provided", "path", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/clair/ancestry.go#L44-L71
train
genuinetools/reg
registry/manifest.go
ManifestList
func (r *Registry) ManifestList(ctx context.Context, repository, ref string) (manifestlist.ManifestList, error) { uri := r.url("/v2/%s/manifests/%s", repository, ref) r.Logf("registry.manifests uri=%s repository=%s ref=%s", uri, repository, ref) var m manifestlist.ManifestList if _, err := r.getJSON(ctx, uri, &m);...
go
func (r *Registry) ManifestList(ctx context.Context, repository, ref string) (manifestlist.ManifestList, error) { uri := r.url("/v2/%s/manifests/%s", repository, ref) r.Logf("registry.manifests uri=%s repository=%s ref=%s", uri, repository, ref) var m manifestlist.ManifestList if _, err := r.getJSON(ctx, uri, &m);...
[ "func", "(", "r", "*", "Registry", ")", "ManifestList", "(", "ctx", "context", ".", "Context", ",", "repository", ",", "ref", "string", ")", "(", "manifestlist", ".", "ManifestList", ",", "error", ")", "{", "uri", ":=", "r", ".", "url", "(", "\"", "\...
// ManifestList gets the registry v2 manifest list.
[ "ManifestList", "gets", "the", "registry", "v2", "manifest", "list", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/manifest.go#L56-L67
train
genuinetools/reg
registry/manifest.go
ManifestV2
func (r *Registry) ManifestV2(ctx context.Context, repository, ref string) (schema2.Manifest, error) { uri := r.url("/v2/%s/manifests/%s", repository, ref) r.Logf("registry.manifests uri=%s repository=%s ref=%s", uri, repository, ref) var m schema2.Manifest if _, err := r.getJSON(ctx, uri, &m); err != nil { r.Lo...
go
func (r *Registry) ManifestV2(ctx context.Context, repository, ref string) (schema2.Manifest, error) { uri := r.url("/v2/%s/manifests/%s", repository, ref) r.Logf("registry.manifests uri=%s repository=%s ref=%s", uri, repository, ref) var m schema2.Manifest if _, err := r.getJSON(ctx, uri, &m); err != nil { r.Lo...
[ "func", "(", "r", "*", "Registry", ")", "ManifestV2", "(", "ctx", "context", ".", "Context", ",", "repository", ",", "ref", "string", ")", "(", "schema2", ".", "Manifest", ",", "error", ")", "{", "uri", ":=", "r", ".", "url", "(", "\"", "\"", ",", ...
// ManifestV2 gets the registry v2 manifest.
[ "ManifestV2", "gets", "the", "registry", "v2", "manifest", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/manifest.go#L70-L85
train
genuinetools/reg
registry/manifest.go
ManifestV1
func (r *Registry) ManifestV1(ctx context.Context, repository, ref string) (schema1.SignedManifest, error) { uri := r.url("/v2/%s/manifests/%s", repository, ref) r.Logf("registry.manifests uri=%s repository=%s ref=%s", uri, repository, ref) var m schema1.SignedManifest if _, err := r.getJSON(ctx, uri, &m); err != ...
go
func (r *Registry) ManifestV1(ctx context.Context, repository, ref string) (schema1.SignedManifest, error) { uri := r.url("/v2/%s/manifests/%s", repository, ref) r.Logf("registry.manifests uri=%s repository=%s ref=%s", uri, repository, ref) var m schema1.SignedManifest if _, err := r.getJSON(ctx, uri, &m); err != ...
[ "func", "(", "r", "*", "Registry", ")", "ManifestV1", "(", "ctx", "context", ".", "Context", ",", "repository", ",", "ref", "string", ")", "(", "schema1", ".", "SignedManifest", ",", "error", ")", "{", "uri", ":=", "r", ".", "url", "(", "\"", "\"", ...
// ManifestV1 gets the registry v1 manifest.
[ "ManifestV1", "gets", "the", "registry", "v1", "manifest", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/manifest.go#L88-L103
train
genuinetools/reg
registry/manifest.go
PutManifest
func (r *Registry) PutManifest(ctx context.Context, repository, ref string, manifest distribution.Manifest) error { url := r.url("/v2/%s/manifests/%s", repository, ref) r.Logf("registry.manifest.put url=%s repository=%s reference=%s", url, repository, ref) b, err := json.Marshal(manifest) if err != nil { return ...
go
func (r *Registry) PutManifest(ctx context.Context, repository, ref string, manifest distribution.Manifest) error { url := r.url("/v2/%s/manifests/%s", repository, ref) r.Logf("registry.manifest.put url=%s repository=%s reference=%s", url, repository, ref) b, err := json.Marshal(manifest) if err != nil { return ...
[ "func", "(", "r", "*", "Registry", ")", "PutManifest", "(", "ctx", "context", ".", "Context", ",", "repository", ",", "ref", "string", ",", "manifest", "distribution", ".", "Manifest", ")", "error", "{", "url", ":=", "r", ".", "url", "(", "\"", "\"", ...
// PutManifest calls a PUT for the specific manifest for an image.
[ "PutManifest", "calls", "a", "PUT", "for", "the", "specific", "manifest", "for", "an", "image", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/manifest.go#L106-L126
train
genuinetools/reg
clair/clair.go
New
func New(url string, opt Opt) (*Clair, error) { transport := http.DefaultTransport grpcOpt := []grpc.DialOption{} if opt.Insecure { transport = &http.Transport{ TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, }, } grpcOpt = append(grpcOpt, grpc.WithInsecure()) } errorTransport := &Error...
go
func New(url string, opt Opt) (*Clair, error) { transport := http.DefaultTransport grpcOpt := []grpc.DialOption{} if opt.Insecure { transport = &http.Transport{ TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, }, } grpcOpt = append(grpcOpt, grpc.WithInsecure()) } errorTransport := &Error...
[ "func", "New", "(", "url", "string", ",", "opt", "Opt", ")", "(", "*", "Clair", ",", "error", ")", "{", "transport", ":=", "http", ".", "DefaultTransport", "\n\n", "grpcOpt", ":=", "[", "]", "grpc", ".", "DialOption", "{", "}", "\n\n", "if", "opt", ...
// New creates a new Clair struct with the given URL and credentials.
[ "New", "creates", "a", "new", "Clair", "struct", "with", "the", "given", "URL", "and", "credentials", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/clair/clair.go#L42-L83
train
genuinetools/reg
clair/clair.go
url
func (c *Clair) url(pathTemplate string, args ...interface{}) string { pathSuffix := fmt.Sprintf(pathTemplate, args...) url := fmt.Sprintf("%s%s", c.URL, pathSuffix) return url }
go
func (c *Clair) url(pathTemplate string, args ...interface{}) string { pathSuffix := fmt.Sprintf(pathTemplate, args...) url := fmt.Sprintf("%s%s", c.URL, pathSuffix) return url }
[ "func", "(", "c", "*", "Clair", ")", "url", "(", "pathTemplate", "string", ",", "args", "...", "interface", "{", "}", ")", "string", "{", "pathSuffix", ":=", "fmt", ".", "Sprintf", "(", "pathTemplate", ",", "args", "...", ")", "\n", "url", ":=", "fmt...
// url returns a clair URL with the passed arguments concatenated.
[ "url", "returns", "a", "clair", "URL", "with", "the", "passed", "arguments", "concatenated", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/clair/clair.go#L91-L95
train
genuinetools/reg
registry/basictransport.go
RoundTrip
func (t *BasicTransport) RoundTrip(req *http.Request) (*http.Response, error) { if strings.HasPrefix(req.URL.String(), t.URL) && req.Header.Get("Authorization") == "" { if t.Username != "" || t.Password != "" { req.SetBasicAuth(t.Username, t.Password) } } resp, err := t.Transport.RoundTrip(req) return resp, ...
go
func (t *BasicTransport) RoundTrip(req *http.Request) (*http.Response, error) { if strings.HasPrefix(req.URL.String(), t.URL) && req.Header.Get("Authorization") == "" { if t.Username != "" || t.Password != "" { req.SetBasicAuth(t.Username, t.Password) } } resp, err := t.Transport.RoundTrip(req) return resp, ...
[ "func", "(", "t", "*", "BasicTransport", ")", "RoundTrip", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "if", "strings", ".", "HasPrefix", "(", "req", ".", "URL", ".", "String", "(", ")", ...
// RoundTrip defines the round tripper for basic auth transport.
[ "RoundTrip", "defines", "the", "round", "tripper", "for", "basic", "auth", "transport", "." ]
d959057b30da67d5f162790f9d5b5160686901fd
https://github.com/genuinetools/reg/blob/d959057b30da67d5f162790f9d5b5160686901fd/registry/basictransport.go#L17-L25
train