id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
146,300
nranchev/go-libGeoIP
libgeo.go
lookupByIPNum
func (gi *GeoIP) lookupByIPNum(ip uint32) int { buf := make([]byte, 2*maxRecordLength) x := make([]int, 2) offset := 0 for depth := 31; depth >= 0; depth-- { for i := 0; i < 2*maxRecordLength; i++ { buf[i] = gi.data[(2*gi.recordLength*offset)+i] } for i := 0; i < 2; i++ { x[i] = 0 for j := 0; j < gi....
go
func (gi *GeoIP) lookupByIPNum(ip uint32) int { buf := make([]byte, 2*maxRecordLength) x := make([]int, 2) offset := 0 for depth := 31; depth >= 0; depth-- { for i := 0; i < 2*maxRecordLength; i++ { buf[i] = gi.data[(2*gi.recordLength*offset)+i] } for i := 0; i < 2; i++ { x[i] = 0 for j := 0; j < gi....
[ "func", "(", "gi", "*", "GeoIP", ")", "lookupByIPNum", "(", "ip", "uint32", ")", "int", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "2", "*", "maxRecordLength", ")", "\n", "x", ":=", "make", "(", "[", "]", "int", ",", "2", ")", "\n", ...
// Read the database and return record position
[ "Read", "the", "database", "and", "return", "record", "position" ]
d6d4a9a4c7e8d750064c10550bbd4f9aae50d48e
https://github.com/nranchev/go-libGeoIP/blob/d6d4a9a4c7e8d750064c10550bbd4f9aae50d48e/libgeo.go#L291-L322
146,301
moul/anonuuid
cmd/anonuuid/main.go
main
func main() { app := cli.NewApp() app.Name = path.Base(os.Args[0]) app.Author = "Manfred Touron" app.Email = "https://github.com/moul" app.Version = "1.0.0-dev" app.Usage = "Anonymize UUIDs outputs" app.Flags = []cli.Flag{ cli.BoolFlag{ Name: "hexspeak", Usage: "Generate hexspeak style fake UUIDs", }...
go
func main() { app := cli.NewApp() app.Name = path.Base(os.Args[0]) app.Author = "Manfred Touron" app.Email = "https://github.com/moul" app.Version = "1.0.0-dev" app.Usage = "Anonymize UUIDs outputs" app.Flags = []cli.Flag{ cli.BoolFlag{ Name: "hexspeak", Usage: "Generate hexspeak style fake UUIDs", }...
[ "func", "main", "(", ")", "{", "app", ":=", "cli", ".", "NewApp", "(", ")", "\n", "app", ".", "Name", "=", "path", ".", "Base", "(", "os", ".", "Args", "[", "0", "]", ")", "\n", "app", ".", "Author", "=", "\"", "\"", "\n", "app", ".", "Emai...
// main is the entrypoint
[ "main", "is", "the", "entrypoint" ]
9814ab0e7b96efb9a44990368169dcadd6fcda55
https://github.com/moul/anonuuid/blob/9814ab0e7b96efb9a44990368169dcadd6fcda55/cmd/anonuuid/main.go#L14-L51
146,302
moul/anonuuid
anonuuid.go
Sanitize
func (a *AnonUUID) Sanitize(input string) string { r := regexp.MustCompile(UUIDRegex) return r.ReplaceAllStringFunc(input, func(m string) string { parts := r.FindStringSubmatch(m) return a.FakeUUID(parts[0]) }) }
go
func (a *AnonUUID) Sanitize(input string) string { r := regexp.MustCompile(UUIDRegex) return r.ReplaceAllStringFunc(input, func(m string) string { parts := r.FindStringSubmatch(m) return a.FakeUUID(parts[0]) }) }
[ "func", "(", "a", "*", "AnonUUID", ")", "Sanitize", "(", "input", "string", ")", "string", "{", "r", ":=", "regexp", ".", "MustCompile", "(", "UUIDRegex", ")", "\n\n", "return", "r", ".", "ReplaceAllStringFunc", "(", "input", ",", "func", "(", "m", "st...
// Sanitize takes a string as input and return sanitized string
[ "Sanitize", "takes", "a", "string", "as", "input", "and", "return", "sanitized", "string" ]
9814ab0e7b96efb9a44990368169dcadd6fcda55
https://github.com/moul/anonuuid/blob/9814ab0e7b96efb9a44990368169dcadd6fcda55/anonuuid.go#L47-L54
146,303
moul/anonuuid
anonuuid.go
New
func New() *AnonUUID { return &AnonUUID{ cache: make(map[string]string), Hexspeak: false, Random: false, } }
go
func New() *AnonUUID { return &AnonUUID{ cache: make(map[string]string), Hexspeak: false, Random: false, } }
[ "func", "New", "(", ")", "*", "AnonUUID", "{", "return", "&", "AnonUUID", "{", "cache", ":", "make", "(", "map", "[", "string", "]", "string", ")", ",", "Hexspeak", ":", "false", ",", "Random", ":", "false", ",", "}", "\n", "}" ]
// New returns a prepared AnonUUID structure
[ "New", "returns", "a", "prepared", "AnonUUID", "structure" ]
9814ab0e7b96efb9a44990368169dcadd6fcda55
https://github.com/moul/anonuuid/blob/9814ab0e7b96efb9a44990368169dcadd6fcda55/anonuuid.go#L125-L131
146,304
moul/anonuuid
anonuuid.go
PrefixUUID
func PrefixUUID(prefix string, uuid string) (string, error) { uuidLetters := uuid[:8] + uuid[9:13] + uuid[14:18] + uuid[19:23] + uuid[24:36] prefixedUUID, err := FormatUUID(prefix + uuidLetters) if err != nil { return "", err } return prefixedUUID, nil }
go
func PrefixUUID(prefix string, uuid string) (string, error) { uuidLetters := uuid[:8] + uuid[9:13] + uuid[14:18] + uuid[19:23] + uuid[24:36] prefixedUUID, err := FormatUUID(prefix + uuidLetters) if err != nil { return "", err } return prefixedUUID, nil }
[ "func", "PrefixUUID", "(", "prefix", "string", ",", "uuid", "string", ")", "(", "string", ",", "error", ")", "{", "uuidLetters", ":=", "uuid", "[", ":", "8", "]", "+", "uuid", "[", "9", ":", "13", "]", "+", "uuid", "[", "14", ":", "18", "]", "+...
// PrefixUUID returns a prefixed UUID
[ "PrefixUUID", "returns", "a", "prefixed", "UUID" ]
9814ab0e7b96efb9a44990368169dcadd6fcda55
https://github.com/moul/anonuuid/blob/9814ab0e7b96efb9a44990368169dcadd6fcda55/anonuuid.go#L138-L145
146,305
moul/anonuuid
anonuuid.go
SuffixUUID
func SuffixUUID(suffix string, uuid string) (string, error) { uuidLetters := uuid[:8] + uuid[9:13] + uuid[14:18] + uuid[19:23] + uuid[24:36] uuidLetters = uuidLetters[:32-len(suffix)] + suffix suffixedUUID, err := FormatUUID(uuidLetters) if err != nil { return "", err } return suffixedUUID, nil }
go
func SuffixUUID(suffix string, uuid string) (string, error) { uuidLetters := uuid[:8] + uuid[9:13] + uuid[14:18] + uuid[19:23] + uuid[24:36] uuidLetters = uuidLetters[:32-len(suffix)] + suffix suffixedUUID, err := FormatUUID(uuidLetters) if err != nil { return "", err } return suffixedUUID, nil }
[ "func", "SuffixUUID", "(", "suffix", "string", ",", "uuid", "string", ")", "(", "string", ",", "error", ")", "{", "uuidLetters", ":=", "uuid", "[", ":", "8", "]", "+", "uuid", "[", "9", ":", "13", "]", "+", "uuid", "[", "14", ":", "18", "]", "+...
// SuffixUUID returns a suffixed UUID
[ "SuffixUUID", "returns", "a", "suffixed", "UUID" ]
9814ab0e7b96efb9a44990368169dcadd6fcda55
https://github.com/moul/anonuuid/blob/9814ab0e7b96efb9a44990368169dcadd6fcda55/anonuuid.go#L148-L156
146,306
moul/anonuuid
anonuuid.go
IsUUID
func IsUUID(input string) error { matched, err := regexp.MatchString("^"+UUIDRegex+"$", input) if err != nil { return err } if !matched { return fmt.Errorf("String '%s' is not a valid UUID", input) } return nil }
go
func IsUUID(input string) error { matched, err := regexp.MatchString("^"+UUIDRegex+"$", input) if err != nil { return err } if !matched { return fmt.Errorf("String '%s' is not a valid UUID", input) } return nil }
[ "func", "IsUUID", "(", "input", "string", ")", "error", "{", "matched", ",", "err", ":=", "regexp", ".", "MatchString", "(", "\"", "\"", "+", "UUIDRegex", "+", "\"", "\"", ",", "input", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n...
// IsUUID returns nil if the input is an UUID, else it returns an error
[ "IsUUID", "returns", "nil", "if", "the", "input", "is", "an", "UUID", "else", "it", "returns", "an", "error" ]
9814ab0e7b96efb9a44990368169dcadd6fcda55
https://github.com/moul/anonuuid/blob/9814ab0e7b96efb9a44990368169dcadd6fcda55/anonuuid.go#L159-L168
146,307
moul/anonuuid
anonuuid.go
FormatUUID
func FormatUUID(part string) (string, error) { if len(part) < 1 { return "", fmt.Errorf("Empty UUID") } if len(part) < 32 { part = strings.Repeat(part, 32) } if len(part) > 32 { part = part[:32] } uuid := part[:8] + "-" + part[8:12] + "-1" + part[13:16] + "-" + part[16:20] + "-" + part[20:32] err := IsUU...
go
func FormatUUID(part string) (string, error) { if len(part) < 1 { return "", fmt.Errorf("Empty UUID") } if len(part) < 32 { part = strings.Repeat(part, 32) } if len(part) > 32 { part = part[:32] } uuid := part[:8] + "-" + part[8:12] + "-1" + part[13:16] + "-" + part[16:20] + "-" + part[20:32] err := IsUU...
[ "func", "FormatUUID", "(", "part", "string", ")", "(", "string", ",", "error", ")", "{", "if", "len", "(", "part", ")", "<", "1", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "...
// FormatUUID takes a string in input and return an UUID formatted string by repeating the string and placing dashes if necessary
[ "FormatUUID", "takes", "a", "string", "in", "input", "and", "return", "an", "UUID", "formatted", "string", "by", "repeating", "the", "string", "and", "placing", "dashes", "if", "necessary" ]
9814ab0e7b96efb9a44990368169dcadd6fcda55
https://github.com/moul/anonuuid/blob/9814ab0e7b96efb9a44990368169dcadd6fcda55/anonuuid.go#L171-L189
146,308
moul/anonuuid
anonuuid.go
GenerateRandomUUID
func GenerateRandomUUID(length int) (string, error) { var letters = []rune("abcdef0123456789") b := make([]rune, length) for i := range b { b[i] = letters[rand.Intn(len(letters))] } return FormatUUID(string(b)) }
go
func GenerateRandomUUID(length int) (string, error) { var letters = []rune("abcdef0123456789") b := make([]rune, length) for i := range b { b[i] = letters[rand.Intn(len(letters))] } return FormatUUID(string(b)) }
[ "func", "GenerateRandomUUID", "(", "length", "int", ")", "(", "string", ",", "error", ")", "{", "var", "letters", "=", "[", "]", "rune", "(", "\"", "\"", ")", "\n\n", "b", ":=", "make", "(", "[", "]", "rune", ",", "length", ")", "\n", "for", "i",...
// GenerateRandomUUID returns an UUID based on random strings
[ "GenerateRandomUUID", "returns", "an", "UUID", "based", "on", "random", "strings" ]
9814ab0e7b96efb9a44990368169dcadd6fcda55
https://github.com/moul/anonuuid/blob/9814ab0e7b96efb9a44990368169dcadd6fcda55/anonuuid.go#L192-L200
146,309
moul/anonuuid
anonuuid.go
GenerateHexspeakUUID
func GenerateHexspeakUUID(i int) (string, error) { if i < 0 { i = -i } hexspeaks := []string{ "0ff1ce", "31337", "4b1d", "badc0de", "badcafe", "badf00d", "deadbabe", "deadbeef", "deadc0de", "deadfeed", "fee1bad", } return FormatUUID(hexspeaks[i%len(hexspeaks)]) }
go
func GenerateHexspeakUUID(i int) (string, error) { if i < 0 { i = -i } hexspeaks := []string{ "0ff1ce", "31337", "4b1d", "badc0de", "badcafe", "badf00d", "deadbabe", "deadbeef", "deadc0de", "deadfeed", "fee1bad", } return FormatUUID(hexspeaks[i%len(hexspeaks)]) }
[ "func", "GenerateHexspeakUUID", "(", "i", "int", ")", "(", "string", ",", "error", ")", "{", "if", "i", "<", "0", "{", "i", "=", "-", "i", "\n", "}", "\n", "hexspeaks", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\...
// GenerateHexspeakUUID returns an UUID formatted string containing hexspeak words
[ "GenerateHexspeakUUID", "returns", "an", "UUID", "formatted", "string", "containing", "hexspeak", "words" ]
9814ab0e7b96efb9a44990368169dcadd6fcda55
https://github.com/moul/anonuuid/blob/9814ab0e7b96efb9a44990368169dcadd6fcda55/anonuuid.go#L203-L221
146,310
moul/anonuuid
anonuuid.go
GenerateLenUUID
func GenerateLenUUID(i int) (string, error) { if i < 0 { i = 2<<29 + i } return FormatUUID(fmt.Sprintf("%x", i)) }
go
func GenerateLenUUID(i int) (string, error) { if i < 0 { i = 2<<29 + i } return FormatUUID(fmt.Sprintf("%x", i)) }
[ "func", "GenerateLenUUID", "(", "i", "int", ")", "(", "string", ",", "error", ")", "{", "if", "i", "<", "0", "{", "i", "=", "2", "<<", "29", "+", "i", "\n", "}", "\n", "return", "FormatUUID", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", ...
// GenerateLenUUID returns an UUID formatted string based on an index number
[ "GenerateLenUUID", "returns", "an", "UUID", "formatted", "string", "based", "on", "an", "index", "number" ]
9814ab0e7b96efb9a44990368169dcadd6fcda55
https://github.com/moul/anonuuid/blob/9814ab0e7b96efb9a44990368169dcadd6fcda55/anonuuid.go#L224-L229
146,311
giantswarm/versionbundle
index_release.go
CompileReleases
func CompileReleases(logger micrologger.Logger, indexReleases []IndexRelease, bundles []Bundle) ([]Release, error) { releases, err := buildReleases(logger, indexReleases, bundles) if err != nil { return nil, err } releases = deduplicateReleaseChangelog(releases) return releases, nil }
go
func CompileReleases(logger micrologger.Logger, indexReleases []IndexRelease, bundles []Bundle) ([]Release, error) { releases, err := buildReleases(logger, indexReleases, bundles) if err != nil { return nil, err } releases = deduplicateReleaseChangelog(releases) return releases, nil }
[ "func", "CompileReleases", "(", "logger", "micrologger", ".", "Logger", ",", "indexReleases", "[", "]", "IndexRelease", ",", "bundles", "[", "]", "Bundle", ")", "(", "[", "]", "Release", ",", "error", ")", "{", "releases", ",", "err", ":=", "buildReleases"...
// CompileReleases takes indexReleases and collected version bundles and // compiles canonicalized Releases from them.
[ "CompileReleases", "takes", "indexReleases", "and", "collected", "version", "bundles", "and", "compiles", "canonicalized", "Releases", "from", "them", "." ]
c91a5899eae8867e7966df734f4cccbba450c841
https://github.com/giantswarm/versionbundle/blob/c91a5899eae8867e7966df734f4cccbba450c841/index_release.go#L26-L35
146,312
giantswarm/versionbundle
index_release.go
findPreviousRelease
func findPreviousRelease(r0 Release, releases []Release) Release { for i := len(releases) - 1; i >= 0; i-- { if releases[i].timestamp.Before(r0.timestamp) { return releases[i] } } return Release{} }
go
func findPreviousRelease(r0 Release, releases []Release) Release { for i := len(releases) - 1; i >= 0; i-- { if releases[i].timestamp.Before(r0.timestamp) { return releases[i] } } return Release{} }
[ "func", "findPreviousRelease", "(", "r0", "Release", ",", "releases", "[", "]", "Release", ")", "Release", "{", "for", "i", ":=", "len", "(", "releases", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", "{", "if", "releases", "[", "i", "]", "....
// findPreviousRelease finds release that is older than argument r0. This // function expects that releases is sorted by version as it is iterated // backwards. If no previous release is found, empty Release is returned.
[ "findPreviousRelease", "finds", "release", "that", "is", "older", "than", "argument", "r0", ".", "This", "function", "expects", "that", "releases", "is", "sorted", "by", "version", "as", "it", "is", "iterated", "backwards", ".", "If", "no", "previous", "releas...
c91a5899eae8867e7966df734f4cccbba450c841
https://github.com/giantswarm/versionbundle/blob/c91a5899eae8867e7966df734f4cccbba450c841/index_release.go#L140-L148
146,313
giantswarm/versionbundle
index_release.go
ValidateIndexReleases
func ValidateIndexReleases(indexReleases []IndexRelease) error { if len(indexReleases) == 0 { return nil } var err error err = validateReleaseAuthorities(indexReleases) if err != nil { return microerror.Mask(err) } err = validateReleaseDates(indexReleases) if err != nil { return microerror.Mask(err) } ...
go
func ValidateIndexReleases(indexReleases []IndexRelease) error { if len(indexReleases) == 0 { return nil } var err error err = validateReleaseAuthorities(indexReleases) if err != nil { return microerror.Mask(err) } err = validateReleaseDates(indexReleases) if err != nil { return microerror.Mask(err) } ...
[ "func", "ValidateIndexReleases", "(", "indexReleases", "[", "]", "IndexRelease", ")", "error", "{", "if", "len", "(", "indexReleases", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "var", "err", "error", "\n\n", "err", "=", "validateReleaseAuthori...
// ValidateIndexReleases ensures semantic rules for collection of indexReleases // so that when used together, they form consistent and integral release index.
[ "ValidateIndexReleases", "ensures", "semantic", "rules", "for", "collection", "of", "indexReleases", "so", "that", "when", "used", "together", "they", "form", "consistent", "and", "integral", "release", "index", "." ]
c91a5899eae8867e7966df734f4cccbba450c841
https://github.com/giantswarm/versionbundle/blob/c91a5899eae8867e7966df734f4cccbba450c841/index_release.go#L163-L184
146,314
ngaut/pools
resource_pool.go
NewResourcePool
func NewResourcePool(factory Factory, capacity, maxCap int, idleTimeout time.Duration) *ResourcePool { if capacity <= 0 || maxCap <= 0 || capacity > maxCap { panic(fmt.Errorf("Invalid/out of range capacity")) } rp := &ResourcePool{ resources: make(chan resourceWrapper, maxCap), factory: factory, capaci...
go
func NewResourcePool(factory Factory, capacity, maxCap int, idleTimeout time.Duration) *ResourcePool { if capacity <= 0 || maxCap <= 0 || capacity > maxCap { panic(fmt.Errorf("Invalid/out of range capacity")) } rp := &ResourcePool{ resources: make(chan resourceWrapper, maxCap), factory: factory, capaci...
[ "func", "NewResourcePool", "(", "factory", "Factory", ",", "capacity", ",", "maxCap", "int", ",", "idleTimeout", "time", ".", "Duration", ")", "*", "ResourcePool", "{", "if", "capacity", "<=", "0", "||", "maxCap", "<=", "0", "||", "capacity", ">", "maxCap"...
// NewResourcePool creates a new ResourcePool pool. // capacity is the initial capacity of the pool. // maxCap is the maximum capacity. // If a resource is unused beyond idleTimeout, it's discarded. // An idleTimeout of 0 means that there is no timeout.
[ "NewResourcePool", "creates", "a", "new", "ResourcePool", "pool", ".", "capacity", "is", "the", "initial", "capacity", "of", "the", "pool", ".", "maxCap", "is", "the", "maximum", "capacity", ".", "If", "a", "resource", "is", "unused", "beyond", "idleTimeout", ...
b7bc8c42aac787667ba45adea78233f53f548443
https://github.com/ngaut/pools/blob/b7bc8c42aac787667ba45adea78233f53f548443/resource_pool.go#L52-L66
146,315
ngaut/pools
resource_pool.go
Get
func (rp *ResourcePool) Get() (resource Resource, err error) { return rp.get(true) }
go
func (rp *ResourcePool) Get() (resource Resource, err error) { return rp.get(true) }
[ "func", "(", "rp", "*", "ResourcePool", ")", "Get", "(", ")", "(", "resource", "Resource", ",", "err", "error", ")", "{", "return", "rp", ".", "get", "(", "true", ")", "\n", "}" ]
// Get will return the next available resource. If capacity // has not been reached, it will create a new one using the factory. Otherwise, // it will indefinitely wait till the next resource becomes available.
[ "Get", "will", "return", "the", "next", "available", "resource", ".", "If", "capacity", "has", "not", "been", "reached", "it", "will", "create", "a", "new", "one", "using", "the", "factory", ".", "Otherwise", "it", "will", "indefinitely", "wait", "till", "...
b7bc8c42aac787667ba45adea78233f53f548443
https://github.com/ngaut/pools/blob/b7bc8c42aac787667ba45adea78233f53f548443/resource_pool.go#L83-L85
146,316
ngaut/pools
resource_pool.go
SetCapacity
func (rp *ResourcePool) SetCapacity(capacity int) error { if capacity < 0 || capacity > cap(rp.resources) { return fmt.Errorf("capacity %d is out of range", capacity) } // Atomically swap new capacity with old, but only // if old capacity is non-zero. var oldcap int for { oldcap = int(rp.capacity.Get()) if...
go
func (rp *ResourcePool) SetCapacity(capacity int) error { if capacity < 0 || capacity > cap(rp.resources) { return fmt.Errorf("capacity %d is out of range", capacity) } // Atomically swap new capacity with old, but only // if old capacity is non-zero. var oldcap int for { oldcap = int(rp.capacity.Get()) if...
[ "func", "(", "rp", "*", "ResourcePool", ")", "SetCapacity", "(", "capacity", "int", ")", "error", "{", "if", "capacity", "<", "0", "||", "capacity", ">", "cap", "(", "rp", ".", "resources", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ...
// SetCapacity changes the capacity of the pool. // You can use it to shrink or expand, but not beyond // the max capacity. If the change requires the pool // to be shrunk, SetCapacity waits till the necessary // number of resources are returned to the pool. // A SetCapacity of 0 is equivalent to closing the ResourcePo...
[ "SetCapacity", "changes", "the", "capacity", "of", "the", "pool", ".", "You", "can", "use", "it", "to", "shrink", "or", "expand", "but", "not", "beyond", "the", "max", "capacity", ".", "If", "the", "change", "requires", "the", "pool", "to", "be", "shrunk...
b7bc8c42aac787667ba45adea78233f53f548443
https://github.com/ngaut/pools/blob/b7bc8c42aac787667ba45adea78233f53f548443/resource_pool.go#L149-L186
146,317
ngaut/pools
numbered.go
Register
func (nu *Numbered) Register(id int64, val interface{}) error { nu.mu.Lock() defer nu.mu.Unlock() if _, ok := nu.resources[id]; ok { return fmt.Errorf("already present") } now := time.Now() nu.resources[id] = &numberedWrapper{ val: val, timeCreated: now, timeUsed: now, } return nil }
go
func (nu *Numbered) Register(id int64, val interface{}) error { nu.mu.Lock() defer nu.mu.Unlock() if _, ok := nu.resources[id]; ok { return fmt.Errorf("already present") } now := time.Now() nu.resources[id] = &numberedWrapper{ val: val, timeCreated: now, timeUsed: now, } return nil }
[ "func", "(", "nu", "*", "Numbered", ")", "Register", "(", "id", "int64", ",", "val", "interface", "{", "}", ")", "error", "{", "nu", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "nu", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "_", "...
// Register starts tracking a resource by the supplied id. // It does not lock the object. // It returns an error if the id already exists.
[ "Register", "starts", "tracking", "a", "resource", "by", "the", "supplied", "id", ".", "It", "does", "not", "lock", "the", "object", ".", "It", "returns", "an", "error", "if", "the", "id", "already", "exists", "." ]
b7bc8c42aac787667ba45adea78233f53f548443
https://github.com/ngaut/pools/blob/b7bc8c42aac787667ba45adea78233f53f548443/numbered.go#L38-L51
146,318
ngaut/pools
numbered.go
Unregister
func (nu *Numbered) Unregister(id int64) { nu.mu.Lock() defer nu.mu.Unlock() delete(nu.resources, id) if len(nu.resources) == 0 { nu.empty.Broadcast() } }
go
func (nu *Numbered) Unregister(id int64) { nu.mu.Lock() defer nu.mu.Unlock() delete(nu.resources, id) if len(nu.resources) == 0 { nu.empty.Broadcast() } }
[ "func", "(", "nu", "*", "Numbered", ")", "Unregister", "(", "id", "int64", ")", "{", "nu", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "nu", ".", "mu", ".", "Unlock", "(", ")", "\n", "delete", "(", "nu", ".", "resources", ",", "id", ")", ...
// Unregiester forgets the specified resource. // If the resource is not present, it's ignored.
[ "Unregiester", "forgets", "the", "specified", "resource", ".", "If", "the", "resource", "is", "not", "present", "it", "s", "ignored", "." ]
b7bc8c42aac787667ba45adea78233f53f548443
https://github.com/ngaut/pools/blob/b7bc8c42aac787667ba45adea78233f53f548443/numbered.go#L55-L62
146,319
ngaut/pools
roundrobin.go
NewRoundRobin
func NewRoundRobin(capacity int, idleTimeout time.Duration) *RoundRobin { r := &RoundRobin{ resources: make(chan fifoWrapper, capacity), size: 0, idleTimeout: idleTimeout, } r.available = sync.NewCond(&r.mu) return r }
go
func NewRoundRobin(capacity int, idleTimeout time.Duration) *RoundRobin { r := &RoundRobin{ resources: make(chan fifoWrapper, capacity), size: 0, idleTimeout: idleTimeout, } r.available = sync.NewCond(&r.mu) return r }
[ "func", "NewRoundRobin", "(", "capacity", "int", ",", "idleTimeout", "time", ".", "Duration", ")", "*", "RoundRobin", "{", "r", ":=", "&", "RoundRobin", "{", "resources", ":", "make", "(", "chan", "fifoWrapper", ",", "capacity", ")", ",", "size", ":", "0...
// NewRoundRobin creates a new RoundRobin pool. // capacity is the maximum number of resources RoundRobin will create. // factory will be the function used to create resources. // If a resource is unused beyond idleTimeout, it's discarded.
[ "NewRoundRobin", "creates", "a", "new", "RoundRobin", "pool", ".", "capacity", "is", "the", "maximum", "number", "of", "resources", "RoundRobin", "will", "create", ".", "factory", "will", "be", "the", "function", "used", "to", "create", "resources", ".", "If",...
b7bc8c42aac787667ba45adea78233f53f548443
https://github.com/ngaut/pools/blob/b7bc8c42aac787667ba45adea78233f53f548443/roundrobin.go#L37-L45
146,320
ngaut/pools
roundrobin.go
Open
func (rr *RoundRobin) Open(factory Factory) { rr.mu.Lock() defer rr.mu.Unlock() rr.factory = factory }
go
func (rr *RoundRobin) Open(factory Factory) { rr.mu.Lock() defer rr.mu.Unlock() rr.factory = factory }
[ "func", "(", "rr", "*", "RoundRobin", ")", "Open", "(", "factory", "Factory", ")", "{", "rr", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "rr", ".", "mu", ".", "Unlock", "(", ")", "\n", "rr", ".", "factory", "=", "factory", "\n", "}" ]
// Open starts allowing the creation of resources
[ "Open", "starts", "allowing", "the", "creation", "of", "resources" ]
b7bc8c42aac787667ba45adea78233f53f548443
https://github.com/ngaut/pools/blob/b7bc8c42aac787667ba45adea78233f53f548443/roundrobin.go#L48-L52
146,321
ngaut/pools
roundrobin.go
Get
func (rr *RoundRobin) Get() (resource Resource, err error) { return rr.get(true) }
go
func (rr *RoundRobin) Get() (resource Resource, err error) { return rr.get(true) }
[ "func", "(", "rr", "*", "RoundRobin", ")", "Get", "(", ")", "(", "resource", "Resource", ",", "err", "error", ")", "{", "return", "rr", ".", "get", "(", "true", ")", "\n", "}" ]
// Get will return the next available resource. If none is available, and capacity // has not been reached, it will create a new one using the factory. Otherwise, // it will indefinitely wait till the next resource becomes available.
[ "Get", "will", "return", "the", "next", "available", "resource", ".", "If", "none", "is", "available", "and", "capacity", "has", "not", "been", "reached", "it", "will", "create", "a", "new", "one", "using", "the", "factory", ".", "Otherwise", "it", "will",...
b7bc8c42aac787667ba45adea78233f53f548443
https://github.com/ngaut/pools/blob/b7bc8c42aac787667ba45adea78233f53f548443/roundrobin.go#L78-L80
146,322
ngaut/pools
roundrobin.go
SetCapacity
func (rr *RoundRobin) SetCapacity(capacity int) error { rr.mu.Lock() defer rr.available.Broadcast() defer rr.mu.Unlock() nr := make(chan fifoWrapper, capacity) // This loop transfers resources from the old channel // to the new one, until it fills up or runs out. // It discards extras, if any. for { select {...
go
func (rr *RoundRobin) SetCapacity(capacity int) error { rr.mu.Lock() defer rr.available.Broadcast() defer rr.mu.Unlock() nr := make(chan fifoWrapper, capacity) // This loop transfers resources from the old channel // to the new one, until it fills up or runs out. // It discards extras, if any. for { select {...
[ "func", "(", "rr", "*", "RoundRobin", ")", "SetCapacity", "(", "capacity", "int", ")", "error", "{", "rr", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "rr", ".", "available", ".", "Broadcast", "(", ")", "\n", "defer", "rr", ".", "mu", ".", "...
// Set capacity changes the capacity of the pool. // You can use it to expand or shrink.
[ "Set", "capacity", "changes", "the", "capacity", "of", "the", "pool", ".", "You", "can", "use", "it", "to", "expand", "or", "shrink", "." ]
b7bc8c42aac787667ba45adea78233f53f548443
https://github.com/ngaut/pools/blob/b7bc8c42aac787667ba45adea78233f53f548443/roundrobin.go#L172-L197
146,323
agrison/go-tablib
tablib_tabular.go
Tabular
func (d *Dataset) Tabular(format string) *Exportable { back := d.Records() t := gotabulate.Create(back) if format == TabularCondensed || format == TabularMarkdown { rendered := regexp.MustCompile("\n\n\\s").ReplaceAllString(t.Render("simple"), "\n ") if format == TabularMarkdown { firstLine := regexp.MustCom...
go
func (d *Dataset) Tabular(format string) *Exportable { back := d.Records() t := gotabulate.Create(back) if format == TabularCondensed || format == TabularMarkdown { rendered := regexp.MustCompile("\n\n\\s").ReplaceAllString(t.Render("simple"), "\n ") if format == TabularMarkdown { firstLine := regexp.MustCom...
[ "func", "(", "d", "*", "Dataset", ")", "Tabular", "(", "format", "string", ")", "*", "Exportable", "{", "back", ":=", "d", ".", "Records", "(", ")", "\n", "t", ":=", "gotabulate", ".", "Create", "(", "back", ")", "\n\n", "if", "format", "==", "Tabu...
// Tabular returns a tabular Exportable representation of the Dataset. // format is either grid, simple, condensed or markdown.
[ "Tabular", "returns", "a", "tabular", "Exportable", "representation", "of", "the", "Dataset", ".", "format", "is", "either", "grid", "simple", "condensed", "or", "markdown", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_tabular.go#L32-L72
146,324
agrison/go-tablib
tablib_dataset.go
NewDatasetWithData
func NewDatasetWithData(headers []string, data [][]interface{}) *Dataset { d := &Dataset{"", headers, data, make([][]string, 0), make([]ColumnConstraint, len(headers)), len(data), len(headers), nil} return d }
go
func NewDatasetWithData(headers []string, data [][]interface{}) *Dataset { d := &Dataset{"", headers, data, make([][]string, 0), make([]ColumnConstraint, len(headers)), len(data), len(headers), nil} return d }
[ "func", "NewDatasetWithData", "(", "headers", "[", "]", "string", ",", "data", "[", "]", "[", "]", "interface", "{", "}", ")", "*", "Dataset", "{", "d", ":=", "&", "Dataset", "{", "\"", "\"", ",", "headers", ",", "data", ",", "make", "(", "[", "]...
// NewDatasetWithData creates a new Dataset.
[ "NewDatasetWithData", "creates", "a", "new", "Dataset", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L47-L51
146,325
agrison/go-tablib
tablib_dataset.go
Append
func (d *Dataset) Append(row []interface{}) error { if len(row) != d.cols { return ErrInvalidDimensions } d.data = append(d.data, row) d.tags = append(d.tags, make([]string, 0)) d.rows++ return nil }
go
func (d *Dataset) Append(row []interface{}) error { if len(row) != d.cols { return ErrInvalidDimensions } d.data = append(d.data, row) d.tags = append(d.tags, make([]string, 0)) d.rows++ return nil }
[ "func", "(", "d", "*", "Dataset", ")", "Append", "(", "row", "[", "]", "interface", "{", "}", ")", "error", "{", "if", "len", "(", "row", ")", "!=", "d", ".", "cols", "{", "return", "ErrInvalidDimensions", "\n", "}", "\n", "d", ".", "data", "=", ...
// Append appends a row of values to the Dataset.
[ "Append", "appends", "a", "row", "of", "values", "to", "the", "Dataset", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L69-L77
146,326
agrison/go-tablib
tablib_dataset.go
AppendTagged
func (d *Dataset) AppendTagged(row []interface{}, tags ...string) error { if err := d.Append(row); err != nil { return err } d.tags[d.rows-1] = tags[:] return nil }
go
func (d *Dataset) AppendTagged(row []interface{}, tags ...string) error { if err := d.Append(row); err != nil { return err } d.tags[d.rows-1] = tags[:] return nil }
[ "func", "(", "d", "*", "Dataset", ")", "AppendTagged", "(", "row", "[", "]", "interface", "{", "}", ",", "tags", "...", "string", ")", "error", "{", "if", "err", ":=", "d", ".", "Append", "(", "row", ")", ";", "err", "!=", "nil", "{", "return", ...
// AppendTagged appends a row of values to the Dataset with one or multiple tags // for filtering purposes.
[ "AppendTagged", "appends", "a", "row", "of", "values", "to", "the", "Dataset", "with", "one", "or", "multiple", "tags", "for", "filtering", "purposes", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L81-L87
146,327
agrison/go-tablib
tablib_dataset.go
AppendValuesTagged
func (d *Dataset) AppendValuesTagged(row ...interface{}) error { if len(row) < d.cols { return ErrInvalidDimensions } var tags []string for _, tag := range row[d.cols:] { if tagStr, ok := tag.(string); ok { tags = append(tags, tagStr) } else { return ErrInvalidTag } } return d.AppendTagged(row[:d.co...
go
func (d *Dataset) AppendValuesTagged(row ...interface{}) error { if len(row) < d.cols { return ErrInvalidDimensions } var tags []string for _, tag := range row[d.cols:] { if tagStr, ok := tag.(string); ok { tags = append(tags, tagStr) } else { return ErrInvalidTag } } return d.AppendTagged(row[:d.co...
[ "func", "(", "d", "*", "Dataset", ")", "AppendValuesTagged", "(", "row", "...", "interface", "{", "}", ")", "error", "{", "if", "len", "(", "row", ")", "<", "d", ".", "cols", "{", "return", "ErrInvalidDimensions", "\n", "}", "\n", "var", "tags", "[",...
// AppendValuesTagged appends a row of values to the Dataset with one or multiple tags // for filtering purposes.
[ "AppendValuesTagged", "appends", "a", "row", "of", "values", "to", "the", "Dataset", "with", "one", "or", "multiple", "tags", "for", "filtering", "purposes", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L96-L109
146,328
agrison/go-tablib
tablib_dataset.go
Insert
func (d *Dataset) Insert(index int, row []interface{}) error { if index < 0 || index >= d.rows { return ErrInvalidRowIndex } if len(row) != d.cols { return ErrInvalidDimensions } ndata := make([][]interface{}, 0, d.rows+1) ndata = append(ndata, d.data[:index]...) ndata = append(ndata, row) ndata = append(...
go
func (d *Dataset) Insert(index int, row []interface{}) error { if index < 0 || index >= d.rows { return ErrInvalidRowIndex } if len(row) != d.cols { return ErrInvalidDimensions } ndata := make([][]interface{}, 0, d.rows+1) ndata = append(ndata, d.data[:index]...) ndata = append(ndata, row) ndata = append(...
[ "func", "(", "d", "*", "Dataset", ")", "Insert", "(", "index", "int", ",", "row", "[", "]", "interface", "{", "}", ")", "error", "{", "if", "index", "<", "0", "||", "index", ">=", "d", ".", "rows", "{", "return", "ErrInvalidRowIndex", "\n", "}", ...
// Insert inserts a row at a given index.
[ "Insert", "inserts", "a", "row", "at", "a", "given", "index", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L112-L135
146,329
agrison/go-tablib
tablib_dataset.go
InsertValues
func (d *Dataset) InsertValues(index int, values ...interface{}) error { return d.Insert(index, values[:]) }
go
func (d *Dataset) InsertValues(index int, values ...interface{}) error { return d.Insert(index, values[:]) }
[ "func", "(", "d", "*", "Dataset", ")", "InsertValues", "(", "index", "int", ",", "values", "...", "interface", "{", "}", ")", "error", "{", "return", "d", ".", "Insert", "(", "index", ",", "values", "[", ":", "]", ")", "\n", "}" ]
// InsertValues inserts a row of values at a given index.
[ "InsertValues", "inserts", "a", "row", "of", "values", "at", "a", "given", "index", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L138-L140
146,330
agrison/go-tablib
tablib_dataset.go
InsertTagged
func (d *Dataset) InsertTagged(index int, row []interface{}, tags ...string) error { if err := d.Insert(index, row); err != nil { return err } d.Insert(index, row) d.tags[index] = tags[:] return nil }
go
func (d *Dataset) InsertTagged(index int, row []interface{}, tags ...string) error { if err := d.Insert(index, row); err != nil { return err } d.Insert(index, row) d.tags[index] = tags[:] return nil }
[ "func", "(", "d", "*", "Dataset", ")", "InsertTagged", "(", "index", "int", ",", "row", "[", "]", "interface", "{", "}", ",", "tags", "...", "string", ")", "error", "{", "if", "err", ":=", "d", ".", "Insert", "(", "index", ",", "row", ")", ";", ...
// InsertTagged inserts a row at a given index with specific tags.
[ "InsertTagged", "inserts", "a", "row", "at", "a", "given", "index", "with", "specific", "tags", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L143-L151
146,331
agrison/go-tablib
tablib_dataset.go
Tag
func (d *Dataset) Tag(index int, tags ...string) error { if index < 0 || index >= d.rows { return ErrInvalidRowIndex } for _, tag := range tags { if !isTagged(tag, d.tags[index]) { d.tags[index] = append(d.tags[index], tag) } } return nil }
go
func (d *Dataset) Tag(index int, tags ...string) error { if index < 0 || index >= d.rows { return ErrInvalidRowIndex } for _, tag := range tags { if !isTagged(tag, d.tags[index]) { d.tags[index] = append(d.tags[index], tag) } } return nil }
[ "func", "(", "d", "*", "Dataset", ")", "Tag", "(", "index", "int", ",", "tags", "...", "string", ")", "error", "{", "if", "index", "<", "0", "||", "index", ">=", "d", ".", "rows", "{", "return", "ErrInvalidRowIndex", "\n", "}", "\n\n", "for", "_", ...
// Tag tags a row at a given index with specific tags. // Returns ErrInvalidRowIndex if the row does not exist.
[ "Tag", "tags", "a", "row", "at", "a", "given", "index", "with", "specific", "tags", ".", "Returns", "ErrInvalidRowIndex", "if", "the", "row", "does", "not", "exist", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L155-L167
146,332
agrison/go-tablib
tablib_dataset.go
Tags
func (d *Dataset) Tags(index int) ([]string, error) { if index < 0 || index >= d.rows { return nil, ErrInvalidRowIndex } return d.tags[index], nil }
go
func (d *Dataset) Tags(index int) ([]string, error) { if index < 0 || index >= d.rows { return nil, ErrInvalidRowIndex } return d.tags[index], nil }
[ "func", "(", "d", "*", "Dataset", ")", "Tags", "(", "index", "int", ")", "(", "[", "]", "string", ",", "error", ")", "{", "if", "index", "<", "0", "||", "index", ">=", "d", ".", "rows", "{", "return", "nil", ",", "ErrInvalidRowIndex", "\n", "}", ...
// Tags returns the tags of a row at a given index. // Returns ErrInvalidRowIndex if the row does not exist.
[ "Tags", "returns", "the", "tags", "of", "a", "row", "at", "a", "given", "index", ".", "Returns", "ErrInvalidRowIndex", "if", "the", "row", "does", "not", "exist", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L171-L177
146,333
agrison/go-tablib
tablib_dataset.go
AppendColumn
func (d *Dataset) AppendColumn(header string, cols []interface{}) error { if len(cols) != d.rows { return ErrInvalidDimensions } d.headers = append(d.headers, header) d.constraints = append(d.constraints, nil) // no constraint by default d.cols++ for i, e := range d.data { d.data[i] = append(e, cols[i]) } r...
go
func (d *Dataset) AppendColumn(header string, cols []interface{}) error { if len(cols) != d.rows { return ErrInvalidDimensions } d.headers = append(d.headers, header) d.constraints = append(d.constraints, nil) // no constraint by default d.cols++ for i, e := range d.data { d.data[i] = append(e, cols[i]) } r...
[ "func", "(", "d", "*", "Dataset", ")", "AppendColumn", "(", "header", "string", ",", "cols", "[", "]", "interface", "{", "}", ")", "error", "{", "if", "len", "(", "cols", ")", "!=", "d", ".", "rows", "{", "return", "ErrInvalidDimensions", "\n", "}", ...
// AppendColumn appends a new column with values to the Dataset.
[ "AppendColumn", "appends", "a", "new", "column", "with", "values", "to", "the", "Dataset", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L180-L191
146,334
agrison/go-tablib
tablib_dataset.go
AppendConstrainedColumn
func (d *Dataset) AppendConstrainedColumn(header string, constraint ColumnConstraint, cols []interface{}) error { err := d.AppendColumn(header, cols) if err != nil { return err } d.constraints[d.cols-1] = constraint return nil }
go
func (d *Dataset) AppendConstrainedColumn(header string, constraint ColumnConstraint, cols []interface{}) error { err := d.AppendColumn(header, cols) if err != nil { return err } d.constraints[d.cols-1] = constraint return nil }
[ "func", "(", "d", "*", "Dataset", ")", "AppendConstrainedColumn", "(", "header", "string", ",", "constraint", "ColumnConstraint", ",", "cols", "[", "]", "interface", "{", "}", ")", "error", "{", "err", ":=", "d", ".", "AppendColumn", "(", "header", ",", ...
// AppendConstrainedColumn appends a constrained column to the Dataset.
[ "AppendConstrainedColumn", "appends", "a", "constrained", "column", "to", "the", "Dataset", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L194-L202
146,335
agrison/go-tablib
tablib_dataset.go
AppendColumnValues
func (d *Dataset) AppendColumnValues(header string, cols ...interface{}) error { return d.AppendColumn(header, cols[:]) }
go
func (d *Dataset) AppendColumnValues(header string, cols ...interface{}) error { return d.AppendColumn(header, cols[:]) }
[ "func", "(", "d", "*", "Dataset", ")", "AppendColumnValues", "(", "header", "string", ",", "cols", "...", "interface", "{", "}", ")", "error", "{", "return", "d", ".", "AppendColumn", "(", "header", ",", "cols", "[", ":", "]", ")", "\n", "}" ]
// AppendColumnValues appends a new column with values to the Dataset.
[ "AppendColumnValues", "appends", "a", "new", "column", "with", "values", "to", "the", "Dataset", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L205-L207
146,336
agrison/go-tablib
tablib_dataset.go
AppendDynamicColumn
func (d *Dataset) AppendDynamicColumn(header string, fn DynamicColumn) { d.headers = append(d.headers, header) d.constraints = append(d.constraints, nil) d.cols++ for i, e := range d.data { d.data[i] = append(e, fn) } }
go
func (d *Dataset) AppendDynamicColumn(header string, fn DynamicColumn) { d.headers = append(d.headers, header) d.constraints = append(d.constraints, nil) d.cols++ for i, e := range d.data { d.data[i] = append(e, fn) } }
[ "func", "(", "d", "*", "Dataset", ")", "AppendDynamicColumn", "(", "header", "string", ",", "fn", "DynamicColumn", ")", "{", "d", ".", "headers", "=", "append", "(", "d", ".", "headers", ",", "header", ")", "\n", "d", ".", "constraints", "=", "append",...
// AppendDynamicColumn appends a dynamic column to the Dataset.
[ "AppendDynamicColumn", "appends", "a", "dynamic", "column", "to", "the", "Dataset", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L210-L217
146,337
agrison/go-tablib
tablib_dataset.go
ConstrainColumn
func (d *Dataset) ConstrainColumn(header string, constraint ColumnConstraint) { i := indexOfColumn(header, d) if i != -1 { d.constraints[i] = constraint } }
go
func (d *Dataset) ConstrainColumn(header string, constraint ColumnConstraint) { i := indexOfColumn(header, d) if i != -1 { d.constraints[i] = constraint } }
[ "func", "(", "d", "*", "Dataset", ")", "ConstrainColumn", "(", "header", "string", ",", "constraint", "ColumnConstraint", ")", "{", "i", ":=", "indexOfColumn", "(", "header", ",", "d", ")", "\n", "if", "i", "!=", "-", "1", "{", "d", ".", "constraints",...
// ConstrainColumn adds a constraint to a column in the Dataset.
[ "ConstrainColumn", "adds", "a", "constraint", "to", "a", "column", "in", "the", "Dataset", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L220-L225
146,338
agrison/go-tablib
tablib_dataset.go
InsertColumn
func (d *Dataset) InsertColumn(index int, header string, cols []interface{}) error { if index < 0 || index >= d.cols { return ErrInvalidColumnIndex } if len(cols) != d.rows { return ErrInvalidDimensions } d.insertHeader(index, header) // for each row, insert the column for i, r := range d.data { row := ...
go
func (d *Dataset) InsertColumn(index int, header string, cols []interface{}) error { if index < 0 || index >= d.cols { return ErrInvalidColumnIndex } if len(cols) != d.rows { return ErrInvalidDimensions } d.insertHeader(index, header) // for each row, insert the column for i, r := range d.data { row := ...
[ "func", "(", "d", "*", "Dataset", ")", "InsertColumn", "(", "index", "int", ",", "header", "string", ",", "cols", "[", "]", "interface", "{", "}", ")", "error", "{", "if", "index", "<", "0", "||", "index", ">=", "d", ".", "cols", "{", "return", "...
// InsertColumn insert a new column at a given index.
[ "InsertColumn", "insert", "a", "new", "column", "at", "a", "given", "index", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L228-L249
146,339
agrison/go-tablib
tablib_dataset.go
InsertDynamicColumn
func (d *Dataset) InsertDynamicColumn(index int, header string, fn DynamicColumn) error { if index < 0 || index >= d.cols { return ErrInvalidColumnIndex } d.insertHeader(index, header) // for each row, insert the column for i, r := range d.data { row := make([]interface{}, 0, d.cols) row = append(row, r[:i...
go
func (d *Dataset) InsertDynamicColumn(index int, header string, fn DynamicColumn) error { if index < 0 || index >= d.cols { return ErrInvalidColumnIndex } d.insertHeader(index, header) // for each row, insert the column for i, r := range d.data { row := make([]interface{}, 0, d.cols) row = append(row, r[:i...
[ "func", "(", "d", "*", "Dataset", ")", "InsertDynamicColumn", "(", "index", "int", ",", "header", "string", ",", "fn", "DynamicColumn", ")", "error", "{", "if", "index", "<", "0", "||", "index", ">=", "d", ".", "cols", "{", "return", "ErrInvalidColumnInd...
// InsertDynamicColumn insert a new dynamic column at a given index.
[ "InsertDynamicColumn", "insert", "a", "new", "dynamic", "column", "at", "a", "given", "index", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L252-L269
146,340
agrison/go-tablib
tablib_dataset.go
InsertConstrainedColumn
func (d *Dataset) InsertConstrainedColumn(index int, header string, constraint ColumnConstraint, cols []interface{}) error { err := d.InsertColumn(index, header, cols) if err != nil { return err } d.constraints[index] = constraint return nil }
go
func (d *Dataset) InsertConstrainedColumn(index int, header string, constraint ColumnConstraint, cols []interface{}) error { err := d.InsertColumn(index, header, cols) if err != nil { return err } d.constraints[index] = constraint return nil }
[ "func", "(", "d", "*", "Dataset", ")", "InsertConstrainedColumn", "(", "index", "int", ",", "header", "string", ",", "constraint", "ColumnConstraint", ",", "cols", "[", "]", "interface", "{", "}", ")", "error", "{", "err", ":=", "d", ".", "InsertColumn", ...
// InsertConstrainedColumn insert a new constrained column at a given index.
[ "InsertConstrainedColumn", "insert", "a", "new", "constrained", "column", "at", "a", "given", "index", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L272-L281
146,341
agrison/go-tablib
tablib_dataset.go
insertHeader
func (d *Dataset) insertHeader(index int, header string) { headers := make([]string, 0, d.cols+1) headers = append(headers, d.headers[:index]...) headers = append(headers, header) headers = append(headers, d.headers[index:]...) d.headers = headers constraints := make([]ColumnConstraint, 0, d.cols+1) constraints...
go
func (d *Dataset) insertHeader(index int, header string) { headers := make([]string, 0, d.cols+1) headers = append(headers, d.headers[:index]...) headers = append(headers, header) headers = append(headers, d.headers[index:]...) d.headers = headers constraints := make([]ColumnConstraint, 0, d.cols+1) constraints...
[ "func", "(", "d", "*", "Dataset", ")", "insertHeader", "(", "index", "int", ",", "header", "string", ")", "{", "headers", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "d", ".", "cols", "+", "1", ")", "\n", "headers", "=", "append", "(", ...
// insertHeader inserts a header at a specific index.
[ "insertHeader", "inserts", "a", "header", "at", "a", "specific", "index", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L284-L298
146,342
agrison/go-tablib
tablib_dataset.go
ValidFailFast
func (d *Dataset) ValidFailFast() bool { valid := true for column, constraint := range d.constraints { if constraint != nil { for row, val := range d.Column(d.headers[column]) { cellIsValid := true switch val.(type) { case DynamicColumn: cellIsValid = constraint((val.(DynamicColumn))(d.data[row...
go
func (d *Dataset) ValidFailFast() bool { valid := true for column, constraint := range d.constraints { if constraint != nil { for row, val := range d.Column(d.headers[column]) { cellIsValid := true switch val.(type) { case DynamicColumn: cellIsValid = constraint((val.(DynamicColumn))(d.data[row...
[ "func", "(", "d", "*", "Dataset", ")", "ValidFailFast", "(", ")", "bool", "{", "valid", ":=", "true", "\n", "for", "column", ",", "constraint", ":=", "range", "d", ".", "constraints", "{", "if", "constraint", "!=", "nil", "{", "for", "row", ",", "val...
// ValidFailFast returns whether the Dataset is valid regarding constraints that have // been previously set on columns.
[ "ValidFailFast", "returns", "whether", "the", "Dataset", "is", "valid", "regarding", "constraints", "that", "have", "been", "previously", "set", "on", "columns", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L302-L329
146,343
agrison/go-tablib
tablib_dataset.go
HasAnyConstraint
func (d *Dataset) HasAnyConstraint() bool { hasConstraint := false for _, constraint := range d.constraints { if constraint != nil { hasConstraint = true break } } return hasConstraint }
go
func (d *Dataset) HasAnyConstraint() bool { hasConstraint := false for _, constraint := range d.constraints { if constraint != nil { hasConstraint = true break } } return hasConstraint }
[ "func", "(", "d", "*", "Dataset", ")", "HasAnyConstraint", "(", ")", "bool", "{", "hasConstraint", ":=", "false", "\n", "for", "_", ",", "constraint", ":=", "range", "d", ".", "constraints", "{", "if", "constraint", "!=", "nil", "{", "hasConstraint", "="...
// HasAnyConstraint returns whether the Dataset has any constraint set.
[ "HasAnyConstraint", "returns", "whether", "the", "Dataset", "has", "any", "constraint", "set", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L363-L372
146,344
agrison/go-tablib
tablib_dataset.go
internalValidSubset
func (d *Dataset) internalValidSubset(valid bool) *Dataset { if !d.HasAnyConstraint() { return d } nd := NewDataset(d.headers) nd.data = make([][]interface{}, 0) ndRowIndex := 0 nd.tags = make([][]string, 0) for i, row := range d.data { keep := true for j, val := range d.data[i] { if d.constraints[j] ...
go
func (d *Dataset) internalValidSubset(valid bool) *Dataset { if !d.HasAnyConstraint() { return d } nd := NewDataset(d.headers) nd.data = make([][]interface{}, 0) ndRowIndex := 0 nd.tags = make([][]string, 0) for i, row := range d.data { keep := true for j, val := range d.data[i] { if d.constraints[j] ...
[ "func", "(", "d", "*", "Dataset", ")", "internalValidSubset", "(", "valid", "bool", ")", "*", "Dataset", "{", "if", "!", "d", ".", "HasAnyConstraint", "(", ")", "{", "return", "d", "\n", "}", "\n\n", "nd", ":=", "NewDataset", "(", "d", ".", "headers"...
// internalValidSubset return a new Dataset containing only the rows validating their // constraints or not depending on its parameter `valid`.
[ "internalValidSubset", "return", "a", "new", "Dataset", "containing", "only", "the", "rows", "validating", "their", "constraints", "or", "not", "depending", "on", "its", "parameter", "valid", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L392-L438
146,345
agrison/go-tablib
tablib_dataset.go
Stack
func (d *Dataset) Stack(other *Dataset) (*Dataset, error) { if d.Width() != other.Width() { return nil, ErrInvalidDimensions } nd := NewDataset(d.headers) nd.cols = d.cols nd.rows = d.rows + other.rows nd.tags = make([][]string, 0, nd.rows) nd.tags = append(nd.tags, d.tags...) nd.tags = append(nd.tags, othe...
go
func (d *Dataset) Stack(other *Dataset) (*Dataset, error) { if d.Width() != other.Width() { return nil, ErrInvalidDimensions } nd := NewDataset(d.headers) nd.cols = d.cols nd.rows = d.rows + other.rows nd.tags = make([][]string, 0, nd.rows) nd.tags = append(nd.tags, d.tags...) nd.tags = append(nd.tags, othe...
[ "func", "(", "d", "*", "Dataset", ")", "Stack", "(", "other", "*", "Dataset", ")", "(", "*", "Dataset", ",", "error", ")", "{", "if", "d", ".", "Width", "(", ")", "!=", "other", ".", "Width", "(", ")", "{", "return", "nil", ",", "ErrInvalidDimens...
// Stack stacks two Dataset by joining at the row level, and return new combined Dataset.
[ "Stack", "stacks", "two", "Dataset", "by", "joining", "at", "the", "row", "level", "and", "return", "new", "combined", "Dataset", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L441-L459
146,346
agrison/go-tablib
tablib_dataset.go
StackColumn
func (d *Dataset) StackColumn(other *Dataset) (*Dataset, error) { if d.Height() != other.Height() { return nil, ErrInvalidDimensions } nheaders := d.headers nheaders = append(nheaders, other.headers...) nd := NewDataset(nheaders) nd.cols = d.cols + nd.cols nd.rows = d.rows nd.data = make([][]interface{}, nd...
go
func (d *Dataset) StackColumn(other *Dataset) (*Dataset, error) { if d.Height() != other.Height() { return nil, ErrInvalidDimensions } nheaders := d.headers nheaders = append(nheaders, other.headers...) nd := NewDataset(nheaders) nd.cols = d.cols + nd.cols nd.rows = d.rows nd.data = make([][]interface{}, nd...
[ "func", "(", "d", "*", "Dataset", ")", "StackColumn", "(", "other", "*", "Dataset", ")", "(", "*", "Dataset", ",", "error", ")", "{", "if", "d", ".", "Height", "(", ")", "!=", "other", ".", "Height", "(", ")", "{", "return", "nil", ",", "ErrInval...
// StackColumn stacks two Dataset by joining them at the column level, and return new combined Dataset.
[ "StackColumn", "stacks", "two", "Dataset", "by", "joining", "them", "at", "the", "column", "level", "and", "return", "new", "combined", "Dataset", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L462-L487
146,347
agrison/go-tablib
tablib_dataset.go
Column
func (d *Dataset) Column(header string) []interface{} { colIndex := indexOfColumn(header, d) if colIndex == -1 { return nil } values := make([]interface{}, d.rows) for i, e := range d.data { switch e[colIndex].(type) { case DynamicColumn: values[i] = e[colIndex].(DynamicColumn)(e) default: values[i]...
go
func (d *Dataset) Column(header string) []interface{} { colIndex := indexOfColumn(header, d) if colIndex == -1 { return nil } values := make([]interface{}, d.rows) for i, e := range d.data { switch e[colIndex].(type) { case DynamicColumn: values[i] = e[colIndex].(DynamicColumn)(e) default: values[i]...
[ "func", "(", "d", "*", "Dataset", ")", "Column", "(", "header", "string", ")", "[", "]", "interface", "{", "}", "{", "colIndex", ":=", "indexOfColumn", "(", "header", ",", "d", ")", "\n", "if", "colIndex", "==", "-", "1", "{", "return", "nil", "\n"...
// Column returns all the values for a specific column // returns nil if column is not found.
[ "Column", "returns", "all", "the", "values", "for", "a", "specific", "column", "returns", "nil", "if", "column", "is", "not", "found", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L491-L507
146,348
agrison/go-tablib
tablib_dataset.go
Row
func (d *Dataset) Row(index int) (map[string]interface{}, error) { if index < 0 || index >= d.rows { return nil, ErrInvalidRowIndex } row := make(map[string]interface{}) for i, e := range d.data[index] { switch e.(type) { case DynamicColumn: row[d.headers[i]] = e.(DynamicColumn)(d.data[index]) default: ...
go
func (d *Dataset) Row(index int) (map[string]interface{}, error) { if index < 0 || index >= d.rows { return nil, ErrInvalidRowIndex } row := make(map[string]interface{}) for i, e := range d.data[index] { switch e.(type) { case DynamicColumn: row[d.headers[i]] = e.(DynamicColumn)(d.data[index]) default: ...
[ "func", "(", "d", "*", "Dataset", ")", "Row", "(", "index", "int", ")", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "if", "index", "<", "0", "||", "index", ">=", "d", ".", "rows", "{", "return", "nil", ",", ...
// Row returns a map representing a specific row of the Dataset. // returns tablib.ErrInvalidRowIndex if the row cannot be found
[ "Row", "returns", "a", "map", "representing", "a", "specific", "row", "of", "the", "Dataset", ".", "returns", "tablib", ".", "ErrInvalidRowIndex", "if", "the", "row", "cannot", "be", "found" ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L511-L526
146,349
agrison/go-tablib
tablib_dataset.go
Rows
func (d *Dataset) Rows(index ...int) ([]map[string]interface{}, error) { for _, i := range index { if i < 0 || i >= d.rows { return nil, ErrInvalidRowIndex } } rows := make([]map[string]interface{}, 0, len(index)) for _, i := range index { row, _ := d.Row(i) rows = append(rows, row) } return rows, ni...
go
func (d *Dataset) Rows(index ...int) ([]map[string]interface{}, error) { for _, i := range index { if i < 0 || i >= d.rows { return nil, ErrInvalidRowIndex } } rows := make([]map[string]interface{}, 0, len(index)) for _, i := range index { row, _ := d.Row(i) rows = append(rows, row) } return rows, ni...
[ "func", "(", "d", "*", "Dataset", ")", "Rows", "(", "index", "...", "int", ")", "(", "[", "]", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "for", "_", ",", "i", ":=", "range", "index", "{", "if", "i", "<", "0", ...
// Rows returns an array of map representing a set of specific rows of the Dataset. // returns tablib.ErrInvalidRowIndex if the row cannot be found.
[ "Rows", "returns", "an", "array", "of", "map", "representing", "a", "set", "of", "specific", "rows", "of", "the", "Dataset", ".", "returns", "tablib", ".", "ErrInvalidRowIndex", "if", "the", "row", "cannot", "be", "found", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L530-L544
146,350
agrison/go-tablib
tablib_dataset.go
Slice
func (d *Dataset) Slice(lower, upperNonInclusive int) (*Dataset, error) { if lower > upperNonInclusive || lower < 0 || upperNonInclusive > d.rows { return nil, ErrInvalidRowIndex } rowCount := upperNonInclusive - lower cols := d.cols nd := NewDataset(d.headers) nd.data = make([][]interface{}, 0, rowCount) nd....
go
func (d *Dataset) Slice(lower, upperNonInclusive int) (*Dataset, error) { if lower > upperNonInclusive || lower < 0 || upperNonInclusive > d.rows { return nil, ErrInvalidRowIndex } rowCount := upperNonInclusive - lower cols := d.cols nd := NewDataset(d.headers) nd.data = make([][]interface{}, 0, rowCount) nd....
[ "func", "(", "d", "*", "Dataset", ")", "Slice", "(", "lower", ",", "upperNonInclusive", "int", ")", "(", "*", "Dataset", ",", "error", ")", "{", "if", "lower", ">", "upperNonInclusive", "||", "lower", "<", "0", "||", "upperNonInclusive", ">", "d", ".",...
// Slice returns a new Dataset representing a slice of the orignal Dataset like a slice of an array. // returns tablib.ErrInvalidRowIndex if the lower or upper bound is out of range.
[ "Slice", "returns", "a", "new", "Dataset", "representing", "a", "slice", "of", "the", "orignal", "Dataset", "like", "a", "slice", "of", "an", "array", ".", "returns", "tablib", ".", "ErrInvalidRowIndex", "if", "the", "lower", "or", "upper", "bound", "is", ...
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L548-L571
146,351
agrison/go-tablib
tablib_dataset.go
Filter
func (d *Dataset) Filter(tags ...string) *Dataset { nd := NewDataset(d.headers) for rowIndex, rowValue := range d.data { for _, filterTag := range tags { if isTagged(filterTag, d.tags[rowIndex]) { nd.AppendTagged(rowValue, d.tags[rowIndex]...) // copy tags } } } return nd }
go
func (d *Dataset) Filter(tags ...string) *Dataset { nd := NewDataset(d.headers) for rowIndex, rowValue := range d.data { for _, filterTag := range tags { if isTagged(filterTag, d.tags[rowIndex]) { nd.AppendTagged(rowValue, d.tags[rowIndex]...) // copy tags } } } return nd }
[ "func", "(", "d", "*", "Dataset", ")", "Filter", "(", "tags", "...", "string", ")", "*", "Dataset", "{", "nd", ":=", "NewDataset", "(", "d", ".", "headers", ")", "\n", "for", "rowIndex", ",", "rowValue", ":=", "range", "d", ".", "data", "{", "for",...
// Filter filters a Dataset, returning a fresh Dataset including only the rows // previously tagged with one of the given tags. Returns a new Dataset.
[ "Filter", "filters", "a", "Dataset", "returning", "a", "fresh", "Dataset", "including", "only", "the", "rows", "previously", "tagged", "with", "one", "of", "the", "given", "tags", ".", "Returns", "a", "new", "Dataset", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L575-L585
146,352
agrison/go-tablib
tablib_dataset.go
Sort
func (d *Dataset) Sort(column string) *Dataset { return d.internalSort(column, false) }
go
func (d *Dataset) Sort(column string) *Dataset { return d.internalSort(column, false) }
[ "func", "(", "d", "*", "Dataset", ")", "Sort", "(", "column", "string", ")", "*", "Dataset", "{", "return", "d", ".", "internalSort", "(", "column", ",", "false", ")", "\n", "}" ]
// Sort sorts the Dataset by a specific column. Returns a new Dataset.
[ "Sort", "sorts", "the", "Dataset", "by", "a", "specific", "column", ".", "Returns", "a", "new", "Dataset", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L588-L590
146,353
agrison/go-tablib
tablib_dataset.go
SortReverse
func (d *Dataset) SortReverse(column string) *Dataset { return d.internalSort(column, true) }
go
func (d *Dataset) SortReverse(column string) *Dataset { return d.internalSort(column, true) }
[ "func", "(", "d", "*", "Dataset", ")", "SortReverse", "(", "column", "string", ")", "*", "Dataset", "{", "return", "d", ".", "internalSort", "(", "column", ",", "true", ")", "\n", "}" ]
// SortReverse sorts the Dataset by a specific column in reverse order. Returns a new Dataset.
[ "SortReverse", "sorts", "the", "Dataset", "by", "a", "specific", "column", "in", "reverse", "order", ".", "Returns", "a", "new", "Dataset", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L593-L595
146,354
agrison/go-tablib
tablib_dataset.go
DeleteRow
func (d *Dataset) DeleteRow(row int) error { if row < 0 || row >= d.rows { return ErrInvalidRowIndex } d.data = append(d.data[:row], d.data[row+1:]...) d.rows-- return nil }
go
func (d *Dataset) DeleteRow(row int) error { if row < 0 || row >= d.rows { return ErrInvalidRowIndex } d.data = append(d.data[:row], d.data[row+1:]...) d.rows-- return nil }
[ "func", "(", "d", "*", "Dataset", ")", "DeleteRow", "(", "row", "int", ")", "error", "{", "if", "row", "<", "0", "||", "row", ">=", "d", ".", "rows", "{", "return", "ErrInvalidRowIndex", "\n", "}", "\n", "d", ".", "data", "=", "append", "(", "d",...
// DeleteRow deletes a row at a specific index
[ "DeleteRow", "deletes", "a", "row", "at", "a", "specific", "index" ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L663-L670
146,355
agrison/go-tablib
tablib_dataset.go
DeleteColumn
func (d *Dataset) DeleteColumn(header string) error { colIndex := indexOfColumn(header, d) if colIndex == -1 { return ErrInvalidColumnIndex } d.cols-- d.headers = append(d.headers[:colIndex], d.headers[colIndex+1:]...) // remove the column for i := range d.data { d.data[i] = append(d.data[i][:colIndex], d.da...
go
func (d *Dataset) DeleteColumn(header string) error { colIndex := indexOfColumn(header, d) if colIndex == -1 { return ErrInvalidColumnIndex } d.cols-- d.headers = append(d.headers[:colIndex], d.headers[colIndex+1:]...) // remove the column for i := range d.data { d.data[i] = append(d.data[i][:colIndex], d.da...
[ "func", "(", "d", "*", "Dataset", ")", "DeleteColumn", "(", "header", "string", ")", "error", "{", "colIndex", ":=", "indexOfColumn", "(", "header", ",", "d", ")", "\n", "if", "colIndex", "==", "-", "1", "{", "return", "ErrInvalidColumnIndex", "\n", "}",...
// DeleteColumn deletes a column from the Dataset.
[ "DeleteColumn", "deletes", "a", "column", "from", "the", "Dataset", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L673-L685
146,356
agrison/go-tablib
tablib_dataset.go
Dict
func (d *Dataset) Dict() []interface{} { back := make([]interface{}, d.rows) for i, e := range d.data { m := make(map[string]interface{}, d.cols-1) for j, c := range d.headers { switch e[j].(type) { case DynamicColumn: m[c] = e[j].(DynamicColumn)(e) default: m[c] = e[j] } } back[i] = m } ...
go
func (d *Dataset) Dict() []interface{} { back := make([]interface{}, d.rows) for i, e := range d.data { m := make(map[string]interface{}, d.cols-1) for j, c := range d.headers { switch e[j].(type) { case DynamicColumn: m[c] = e[j].(DynamicColumn)(e) default: m[c] = e[j] } } back[i] = m } ...
[ "func", "(", "d", "*", "Dataset", ")", "Dict", "(", ")", "[", "]", "interface", "{", "}", "{", "back", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "d", ".", "rows", ")", "\n", "for", "i", ",", "e", ":=", "range", "d", ".", "dat...
// Dict returns the Dataset as an array of map where each key is a column.
[ "Dict", "returns", "the", "Dataset", "as", "an", "array", "of", "map", "where", "each", "key", "is", "a", "column", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L697-L712
146,357
agrison/go-tablib
tablib_dataset.go
Records
func (d *Dataset) Records() [][]string { records := make([][]string, d.rows+1 /* +1 for header */) records[0] = make([]string, d.cols) for j, e := range d.headers { records[0][j] = e } for i, e := range d.data { rowIndex := i + 1 j := 0 records[rowIndex] = make([]string, d.cols) for _, v := range e { ...
go
func (d *Dataset) Records() [][]string { records := make([][]string, d.rows+1 /* +1 for header */) records[0] = make([]string, d.cols) for j, e := range d.headers { records[0][j] = e } for i, e := range d.data { rowIndex := i + 1 j := 0 records[rowIndex] = make([]string, d.cols) for _, v := range e { ...
[ "func", "(", "d", "*", "Dataset", ")", "Records", "(", ")", "[", "]", "[", "]", "string", "{", "records", ":=", "make", "(", "[", "]", "[", "]", "string", ",", "d", ".", "rows", "+", "1", "/* +1 for header */", ")", "\n", "records", "[", "0", "...
// Records returns the Dataset as an array of array where each entry is a string. // The first row of the returned 2d array represents the columns of the Dataset.
[ "Records", "returns", "the", "Dataset", "as", "an", "array", "of", "array", "where", "each", "entry", "is", "a", "string", ".", "The", "first", "row", "of", "the", "returned", "2d", "array", "represents", "the", "columns", "of", "the", "Dataset", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_dataset.go#L716-L740
146,358
agrison/go-tablib
tablib_databook.go
AddSheet
func (d *Databook) AddSheet(title string, dataset *Dataset) { d.sheets[title] = Sheet{title, dataset} }
go
func (d *Databook) AddSheet(title string, dataset *Dataset) { d.sheets[title] = Sheet{title, dataset} }
[ "func", "(", "d", "*", "Databook", ")", "AddSheet", "(", "title", "string", ",", "dataset", "*", "Dataset", ")", "{", "d", ".", "sheets", "[", "title", "]", "=", "Sheet", "{", "title", ",", "dataset", "}", "\n", "}" ]
// AddSheet adds a sheet to the Databook.
[ "AddSheet", "adds", "a", "sheet", "to", "the", "Databook", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_databook.go#L40-L42
146,359
agrison/go-tablib
tablib_databook.go
Wipe
func (d *Databook) Wipe() { for k := range d.sheets { delete(d.sheets, k) } }
go
func (d *Databook) Wipe() { for k := range d.sheets { delete(d.sheets, k) } }
[ "func", "(", "d", "*", "Databook", ")", "Wipe", "(", ")", "{", "for", "k", ":=", "range", "d", ".", "sheets", "{", "delete", "(", "d", ".", "sheets", ",", "k", ")", "\n", "}", "\n", "}" ]
// Wipe removes all Dataset objects from the Databook.
[ "Wipe", "removes", "all", "Dataset", "objects", "from", "the", "Databook", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_databook.go#L50-L54
146,360
agrison/go-tablib
tablib_json.go
LoadJSON
func LoadJSON(jsonContent []byte) (*Dataset, error) { var input []map[string]interface{} if err := json.Unmarshal(jsonContent, &input); err != nil { return nil, err } return internalLoadFromDict(input) }
go
func LoadJSON(jsonContent []byte) (*Dataset, error) { var input []map[string]interface{} if err := json.Unmarshal(jsonContent, &input); err != nil { return nil, err } return internalLoadFromDict(input) }
[ "func", "LoadJSON", "(", "jsonContent", "[", "]", "byte", ")", "(", "*", "Dataset", ",", "error", ")", "{", "var", "input", "[", "]", "map", "[", "string", "]", "interface", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "jsonCon...
// LoadJSON loads a dataset from a YAML source.
[ "LoadJSON", "loads", "a", "dataset", "from", "a", "YAML", "source", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_json.go#L8-L15
146,361
agrison/go-tablib
tablib_json.go
LoadDatabookJSON
func LoadDatabookJSON(jsonContent []byte) (*Databook, error) { var input []map[string]interface{} var internalInput []map[string]interface{} if err := json.Unmarshal(jsonContent, &input); err != nil { return nil, err } db := NewDatabook() for _, d := range input { b, err := json.Marshal(d["data"]) if err !...
go
func LoadDatabookJSON(jsonContent []byte) (*Databook, error) { var input []map[string]interface{} var internalInput []map[string]interface{} if err := json.Unmarshal(jsonContent, &input); err != nil { return nil, err } db := NewDatabook() for _, d := range input { b, err := json.Marshal(d["data"]) if err !...
[ "func", "LoadDatabookJSON", "(", "jsonContent", "[", "]", "byte", ")", "(", "*", "Databook", ",", "error", ")", "{", "var", "input", "[", "]", "map", "[", "string", "]", "interface", "{", "}", "\n", "var", "internalInput", "[", "]", "map", "[", "stri...
// LoadDatabookJSON loads a Databook from a JSON source.
[ "LoadDatabookJSON", "loads", "a", "Databook", "from", "a", "JSON", "source", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_json.go#L18-L43
146,362
agrison/go-tablib
tablib_json.go
JSON
func (d *Dataset) JSON() (*Exportable, error) { back := d.Dict() b, err := json.Marshal(back) if err != nil { return nil, err } return newExportableFromBytes(b), nil }
go
func (d *Dataset) JSON() (*Exportable, error) { back := d.Dict() b, err := json.Marshal(back) if err != nil { return nil, err } return newExportableFromBytes(b), nil }
[ "func", "(", "d", "*", "Dataset", ")", "JSON", "(", ")", "(", "*", "Exportable", ",", "error", ")", "{", "back", ":=", "d", ".", "Dict", "(", ")", "\n\n", "b", ",", "err", ":=", "json", ".", "Marshal", "(", "back", ")", "\n", "if", "err", "!=...
// JSON returns a JSON representation of the Dataset as an Exportable.
[ "JSON", "returns", "a", "JSON", "representation", "of", "the", "Dataset", "as", "an", "Exportable", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_json.go#L46-L54
146,363
agrison/go-tablib
tablib_json.go
JSON
func (d *Databook) JSON() (*Exportable, error) { b := newBuffer() b.WriteString("[") for _, s := range d.sheets { b.WriteString("{\"title\": \"" + s.title + "\", \"data\": ") js, err := s.dataset.JSON() if err != nil { return nil, err } b.Write(js.Bytes()) b.WriteString("},") } by := b.Bytes() by[l...
go
func (d *Databook) JSON() (*Exportable, error) { b := newBuffer() b.WriteString("[") for _, s := range d.sheets { b.WriteString("{\"title\": \"" + s.title + "\", \"data\": ") js, err := s.dataset.JSON() if err != nil { return nil, err } b.Write(js.Bytes()) b.WriteString("},") } by := b.Bytes() by[l...
[ "func", "(", "d", "*", "Databook", ")", "JSON", "(", ")", "(", "*", "Exportable", ",", "error", ")", "{", "b", ":=", "newBuffer", "(", ")", "\n", "b", ".", "WriteString", "(", "\"", "\"", ")", "\n", "for", "_", ",", "s", ":=", "range", "d", "...
// JSON returns a JSON representation of the Databook as an Exportable.
[ "JSON", "returns", "a", "JSON", "representation", "of", "the", "Databook", "as", "an", "Exportable", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_json.go#L57-L72
146,364
jacobsa/ogletest
failure.go
AddFailure
func AddFailure(format string, a ...interface{}) { r := FailureRecord{ Error: fmt.Sprintf(format, a...), } // Get information about the call site. var ok bool if _, r.FileName, r.LineNumber, ok = runtime.Caller(1); !ok { panic("Can't find caller") } r.FileName = path.Base(r.FileName) AddFailureRecord(r) ...
go
func AddFailure(format string, a ...interface{}) { r := FailureRecord{ Error: fmt.Sprintf(format, a...), } // Get information about the call site. var ok bool if _, r.FileName, r.LineNumber, ok = runtime.Caller(1); !ok { panic("Can't find caller") } r.FileName = path.Base(r.FileName) AddFailureRecord(r) ...
[ "func", "AddFailure", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "r", ":=", "FailureRecord", "{", "Error", ":", "fmt", ".", "Sprintf", "(", "format", ",", "a", "...", ")", ",", "}", "\n\n", "// Get information about the ca...
// Call AddFailureRecord with a record whose file name and line number come // from the caller of this function, and whose error string is created by // calling fmt.Sprintf using the arguments to this function.
[ "Call", "AddFailureRecord", "with", "a", "record", "whose", "file", "name", "and", "line", "number", "come", "from", "the", "caller", "of", "this", "function", "and", "whose", "error", "string", "is", "created", "by", "calling", "fmt", ".", "Sprintf", "using...
80d50a735a1108a2aeb7abc4a988d183f20c5292
https://github.com/jacobsa/ogletest/blob/80d50a735a1108a2aeb7abc4a988d183f20c5292/failure.go#L63-L77
146,365
agrison/go-tablib
tablib_yaml.go
LoadYAML
func LoadYAML(yamlContent []byte) (*Dataset, error) { var input []map[string]interface{} if err := yaml.Unmarshal(yamlContent, &input); err != nil { return nil, err } return internalLoadFromDict(input) }
go
func LoadYAML(yamlContent []byte) (*Dataset, error) { var input []map[string]interface{} if err := yaml.Unmarshal(yamlContent, &input); err != nil { return nil, err } return internalLoadFromDict(input) }
[ "func", "LoadYAML", "(", "yamlContent", "[", "]", "byte", ")", "(", "*", "Dataset", ",", "error", ")", "{", "var", "input", "[", "]", "map", "[", "string", "]", "interface", "{", "}", "\n", "if", "err", ":=", "yaml", ".", "Unmarshal", "(", "yamlCon...
// LoadYAML loads a dataset from a YAML source.
[ "LoadYAML", "loads", "a", "dataset", "from", "a", "YAML", "source", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_yaml.go#L6-L13
146,366
agrison/go-tablib
tablib_yaml.go
LoadDatabookYAML
func LoadDatabookYAML(yamlContent []byte) (*Databook, error) { var input []map[string]interface{} var internalInput []map[string]interface{} if err := yaml.Unmarshal(yamlContent, &input); err != nil { return nil, err } db := NewDatabook() for _, d := range input { b, err := yaml.Marshal(d["data"]) if err !...
go
func LoadDatabookYAML(yamlContent []byte) (*Databook, error) { var input []map[string]interface{} var internalInput []map[string]interface{} if err := yaml.Unmarshal(yamlContent, &input); err != nil { return nil, err } db := NewDatabook() for _, d := range input { b, err := yaml.Marshal(d["data"]) if err !...
[ "func", "LoadDatabookYAML", "(", "yamlContent", "[", "]", "byte", ")", "(", "*", "Databook", ",", "error", ")", "{", "var", "input", "[", "]", "map", "[", "string", "]", "interface", "{", "}", "\n", "var", "internalInput", "[", "]", "map", "[", "stri...
// LoadDatabookYAML loads a Databook from a YAML source.
[ "LoadDatabookYAML", "loads", "a", "Databook", "from", "a", "YAML", "source", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_yaml.go#L16-L41
146,367
agrison/go-tablib
tablib_yaml.go
YAML
func (d *Dataset) YAML() (*Exportable, error) { back := d.Dict() b, err := yaml.Marshal(back) if err != nil { return nil, err } return newExportableFromBytes(b), nil }
go
func (d *Dataset) YAML() (*Exportable, error) { back := d.Dict() b, err := yaml.Marshal(back) if err != nil { return nil, err } return newExportableFromBytes(b), nil }
[ "func", "(", "d", "*", "Dataset", ")", "YAML", "(", ")", "(", "*", "Exportable", ",", "error", ")", "{", "back", ":=", "d", ".", "Dict", "(", ")", "\n\n", "b", ",", "err", ":=", "yaml", ".", "Marshal", "(", "back", ")", "\n", "if", "err", "!=...
// YAML returns a YAML representation of the Dataset as an Exportable.
[ "YAML", "returns", "a", "YAML", "representation", "of", "the", "Dataset", "as", "an", "Exportable", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_yaml.go#L44-L52
146,368
agrison/go-tablib
tablib_yaml.go
YAML
func (d *Databook) YAML() (*Exportable, error) { y := make([]map[string]interface{}, len(d.sheets)) i := 0 for _, s := range d.sheets { y[i] = make(map[string]interface{}) y[i]["title"] = s.title y[i]["data"] = s.dataset.Dict() i++ } b, err := yaml.Marshal(y) if err != nil { return nil, err } return n...
go
func (d *Databook) YAML() (*Exportable, error) { y := make([]map[string]interface{}, len(d.sheets)) i := 0 for _, s := range d.sheets { y[i] = make(map[string]interface{}) y[i]["title"] = s.title y[i]["data"] = s.dataset.Dict() i++ } b, err := yaml.Marshal(y) if err != nil { return nil, err } return n...
[ "func", "(", "d", "*", "Databook", ")", "YAML", "(", ")", "(", "*", "Exportable", ",", "error", ")", "{", "y", ":=", "make", "(", "[", "]", "map", "[", "string", "]", "interface", "{", "}", ",", "len", "(", "d", ".", "sheets", ")", ")", "\n",...
// YAML returns a YAML representation of the Databook as an Exportable.
[ "YAML", "returns", "a", "YAML", "representation", "of", "the", "Databook", "as", "an", "Exportable", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_yaml.go#L55-L69
146,369
agrison/go-tablib
tablib_html.go
HTML
func (d *Dataset) HTML() *Exportable { back := d.Records() b := newBuffer() b.WriteString("<table class=\"table table-striped\">\n\t<thead>") for i, r := range back { b.WriteString("\n\t\t<tr>") for _, c := range r { tag := "td" if i == 0 { tag = "th" } b.WriteString("\n\t\t\t<" + tag + ">") ...
go
func (d *Dataset) HTML() *Exportable { back := d.Records() b := newBuffer() b.WriteString("<table class=\"table table-striped\">\n\t<thead>") for i, r := range back { b.WriteString("\n\t\t<tr>") for _, c := range r { tag := "td" if i == 0 { tag = "th" } b.WriteString("\n\t\t\t<" + tag + ">") ...
[ "func", "(", "d", "*", "Dataset", ")", "HTML", "(", ")", "*", "Exportable", "{", "back", ":=", "d", ".", "Records", "(", ")", "\n", "b", ":=", "newBuffer", "(", ")", "\n\n", "b", ".", "WriteString", "(", "\"", "\\\"", "\\\"", "\\n", "\\t", "\"", ...
// HTML returns the HTML representation of the Dataset as an Exportable.
[ "HTML", "returns", "the", "HTML", "representation", "of", "the", "Dataset", "as", "an", "Exportable", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_html.go#L4-L28
146,370
agrison/go-tablib
tablib_html.go
HTML
func (d *Databook) HTML() *Exportable { b := newBuffer() for _, s := range d.sheets { b.WriteString("<h1>" + s.title + "</h1>\n") b.Write(s.dataset.HTML().Bytes()) b.WriteString("\n\n") } return newExportable(b) }
go
func (d *Databook) HTML() *Exportable { b := newBuffer() for _, s := range d.sheets { b.WriteString("<h1>" + s.title + "</h1>\n") b.Write(s.dataset.HTML().Bytes()) b.WriteString("\n\n") } return newExportable(b) }
[ "func", "(", "d", "*", "Databook", ")", "HTML", "(", ")", "*", "Exportable", "{", "b", ":=", "newBuffer", "(", ")", "\n\n", "for", "_", ",", "s", ":=", "range", "d", ".", "sheets", "{", "b", ".", "WriteString", "(", "\"", "\"", "+", "s", ".", ...
// HTML returns a HTML representation of the Databook as an Exportable.
[ "HTML", "returns", "a", "HTML", "representation", "of", "the", "Databook", "as", "an", "Exportable", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_html.go#L31-L41
146,371
agrison/go-tablib
tablib_xlsx.go
XLSX
func (d *Dataset) XLSX() (*Exportable, error) { file := xlsx.NewFile() if err := d.addXlsxSheetToFile(file, "Sheet 1"); err != nil { return nil, err } b := newBuffer() file.Write(b) return newExportable(b), nil }
go
func (d *Dataset) XLSX() (*Exportable, error) { file := xlsx.NewFile() if err := d.addXlsxSheetToFile(file, "Sheet 1"); err != nil { return nil, err } b := newBuffer() file.Write(b) return newExportable(b), nil }
[ "func", "(", "d", "*", "Dataset", ")", "XLSX", "(", ")", "(", "*", "Exportable", ",", "error", ")", "{", "file", ":=", "xlsx", ".", "NewFile", "(", ")", "\n", "if", "err", ":=", "d", ".", "addXlsxSheetToFile", "(", "file", ",", "\"", "\"", ")", ...
// XLSX exports the Dataset as a byte array representing the .xlsx format.
[ "XLSX", "exports", "the", "Dataset", "as", "a", "byte", "array", "representing", "the", ".", "xlsx", "format", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_xlsx.go#L8-L17
146,372
agrison/go-tablib
tablib_xlsx.go
XLSX
func (d *Databook) XLSX() (*Exportable, error) { file := xlsx.NewFile() for _, s := range d.sheets { s.dataset.addXlsxSheetToFile(file, s.title) } b := newBuffer() file.Write(b) return newExportable(b), nil }
go
func (d *Databook) XLSX() (*Exportable, error) { file := xlsx.NewFile() for _, s := range d.sheets { s.dataset.addXlsxSheetToFile(file, s.title) } b := newBuffer() file.Write(b) return newExportable(b), nil }
[ "func", "(", "d", "*", "Databook", ")", "XLSX", "(", ")", "(", "*", "Exportable", ",", "error", ")", "{", "file", ":=", "xlsx", ".", "NewFile", "(", ")", "\n\n", "for", "_", ",", "s", ":=", "range", "d", ".", "sheets", "{", "s", ".", "dataset",...
// XLSX returns a XLSX representation of the Databook as an exportable.
[ "XLSX", "returns", "a", "XLSX", "representation", "of", "the", "Databook", "as", "an", "exportable", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_xlsx.go#L20-L30
146,373
agrison/go-tablib
tablib_exportable.go
newBufferWithCap
func newBufferWithCap(initialCap int) *bytes.Buffer { initialBuf := make([]byte, 0, initialCap) return bytes.NewBuffer(initialBuf) }
go
func newBufferWithCap(initialCap int) *bytes.Buffer { initialBuf := make([]byte, 0, initialCap) return bytes.NewBuffer(initialBuf) }
[ "func", "newBufferWithCap", "(", "initialCap", "int", ")", "*", "bytes", ".", "Buffer", "{", "initialBuf", ":=", "make", "(", "[", "]", "byte", ",", "0", ",", "initialCap", ")", "\n", "return", "bytes", ".", "NewBuffer", "(", "initialBuf", ")", "\n", "...
// newBufferWithCap returns a new bytes.Buffer instance already initialized // with an underlying bytes array of the given capacity.
[ "newBufferWithCap", "returns", "a", "new", "bytes", ".", "Buffer", "instance", "already", "initialized", "with", "an", "underlying", "bytes", "array", "of", "the", "given", "capacity", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_exportable.go#L20-L23
146,374
agrison/go-tablib
tablib_exportable.go
newExportableFromString
func newExportableFromString(str string) *Exportable { buff := newBufferWithCap(len(str)) buff.WriteString(str) return newExportable(buff) }
go
func newExportableFromString(str string) *Exportable { buff := newBufferWithCap(len(str)) buff.WriteString(str) return newExportable(buff) }
[ "func", "newExportableFromString", "(", "str", "string", ")", "*", "Exportable", "{", "buff", ":=", "newBufferWithCap", "(", "len", "(", "str", ")", ")", "\n", "buff", ".", "WriteString", "(", "str", ")", "\n", "return", "newExportable", "(", "buff", ")", ...
// newExportableFromString creates a new instance of Exportable from a string.
[ "newExportableFromString", "creates", "a", "new", "instance", "of", "Exportable", "from", "a", "string", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_exportable.go#L44-L48
146,375
agrison/go-tablib
tablib_exportable.go
WriteTo
func (e *Exportable) WriteTo(w io.Writer) (int64, error) { return e.buffer.WriteTo(w) }
go
func (e *Exportable) WriteTo(w io.Writer) (int64, error) { return e.buffer.WriteTo(w) }
[ "func", "(", "e", "*", "Exportable", ")", "WriteTo", "(", "w", "io", ".", "Writer", ")", "(", "int64", ",", "error", ")", "{", "return", "e", ".", "buffer", ".", "WriteTo", "(", "w", ")", "\n", "}" ]
// WriteTo writes the exported dataset to w.
[ "WriteTo", "writes", "the", "exported", "dataset", "to", "w", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_exportable.go#L61-L63
146,376
agrison/go-tablib
tablib_exportable.go
WriteFile
func (e *Exportable) WriteFile(filename string, perm os.FileMode) error { return ioutil.WriteFile(filename, e.Bytes(), perm) }
go
func (e *Exportable) WriteFile(filename string, perm os.FileMode) error { return ioutil.WriteFile(filename, e.Bytes(), perm) }
[ "func", "(", "e", "*", "Exportable", ")", "WriteFile", "(", "filename", "string", ",", "perm", "os", ".", "FileMode", ")", "error", "{", "return", "ioutil", ".", "WriteFile", "(", "filename", ",", "e", ".", "Bytes", "(", ")", ",", "perm", ")", "\n", ...
// WriteFile writes the databook or dataset content to a file named by filename. // If the file does not exist, WriteFile creates it with permissions perm; // otherwise WriteFile truncates it before writing.
[ "WriteFile", "writes", "the", "databook", "or", "dataset", "content", "to", "a", "file", "named", "by", "filename", ".", "If", "the", "file", "does", "not", "exist", "WriteFile", "creates", "it", "with", "permissions", "perm", ";", "otherwise", "WriteFile", ...
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_exportable.go#L68-L70
146,377
jacobsa/ogletest
srcutil/methods.go
GetMethodsInSourceOrder
func GetMethodsInSourceOrder(t reflect.Type) []reflect.Method { // Build the list of methods. methods := sortableMethodSet{} for i := 0; i < t.NumMethod(); i++ { methods = append(methods, t.Method(i)) } // Sort it. sort.Sort(methods) return methods }
go
func GetMethodsInSourceOrder(t reflect.Type) []reflect.Method { // Build the list of methods. methods := sortableMethodSet{} for i := 0; i < t.NumMethod(); i++ { methods = append(methods, t.Method(i)) } // Sort it. sort.Sort(methods) return methods }
[ "func", "GetMethodsInSourceOrder", "(", "t", "reflect", ".", "Type", ")", "[", "]", "reflect", ".", "Method", "{", "// Build the list of methods.", "methods", ":=", "sortableMethodSet", "{", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "t", ".", "NumMe...
// Given a type t, return all of the methods of t sorted such that source file // order is preserved. Order across files is undefined. Order within lines is // undefined.
[ "Given", "a", "type", "t", "return", "all", "of", "the", "methods", "of", "t", "sorted", "such", "that", "source", "file", "order", "is", "preserved", ".", "Order", "across", "files", "is", "undefined", ".", "Order", "within", "lines", "is", "undefined", ...
80d50a735a1108a2aeb7abc4a988d183f20c5292
https://github.com/jacobsa/ogletest/blob/80d50a735a1108a2aeb7abc4a988d183f20c5292/srcutil/methods.go#L54-L65
146,378
agrison/go-tablib
tablib_util.go
internalLoadFromDict
func internalLoadFromDict(input []map[string]interface{}) (*Dataset, error) { // retrieve columns headers := make([]string, 0, 10) for h := range input[0] { headers = append(headers, h) } ds := NewDataset(headers) for _, e := range input { row := make([]interface{}, 0, len(headers)) for _, h := range heade...
go
func internalLoadFromDict(input []map[string]interface{}) (*Dataset, error) { // retrieve columns headers := make([]string, 0, 10) for h := range input[0] { headers = append(headers, h) } ds := NewDataset(headers) for _, e := range input { row := make([]interface{}, 0, len(headers)) for _, h := range heade...
[ "func", "internalLoadFromDict", "(", "input", "[", "]", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "*", "Dataset", ",", "error", ")", "{", "// retrieve columns", "headers", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "10", ...
// internalLoadFromDict creates a Dataset from an array of map representing columns.
[ "internalLoadFromDict", "creates", "a", "Dataset", "from", "an", "array", "of", "map", "representing", "columns", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_util.go#L10-L27
146,379
agrison/go-tablib
tablib_util.go
isTagged
func isTagged(tag string, tags []string) bool { for _, t := range tags { if t == tag { return true } } return false }
go
func isTagged(tag string, tags []string) bool { for _, t := range tags { if t == tag { return true } } return false }
[ "func", "isTagged", "(", "tag", "string", ",", "tags", "[", "]", "string", ")", "bool", "{", "for", "_", ",", "t", ":=", "range", "tags", "{", "if", "t", "==", "tag", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "...
// isTagged checks if a tag is in an array of tags.
[ "isTagged", "checks", "if", "a", "tag", "is", "in", "an", "array", "of", "tags", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_util.go#L30-L37
146,380
agrison/go-tablib
tablib_util.go
asString
func (d *Dataset) asString(vv interface{}) string { var v string switch vv.(type) { case string: v = vv.(string) case int: v = strconv.Itoa(vv.(int)) case int64: v = strconv.FormatInt(vv.(int64), 10) case uint64: v = strconv.FormatUint(vv.(uint64), 10) case bool: v = strconv.FormatBool(vv.(bool)) case...
go
func (d *Dataset) asString(vv interface{}) string { var v string switch vv.(type) { case string: v = vv.(string) case int: v = strconv.Itoa(vv.(int)) case int64: v = strconv.FormatInt(vv.(int64), 10) case uint64: v = strconv.FormatUint(vv.(uint64), 10) case bool: v = strconv.FormatBool(vv.(bool)) case...
[ "func", "(", "d", "*", "Dataset", ")", "asString", "(", "vv", "interface", "{", "}", ")", "string", "{", "var", "v", "string", "\n", "switch", "vv", ".", "(", "type", ")", "{", "case", "string", ":", "v", "=", "vv", ".", "(", "string", ")", "\n...
// asString returns a value as a string.
[ "asString", "returns", "a", "value", "as", "a", "string", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_util.go#L40-L65
146,381
agrison/go-tablib
tablib_csv.go
CSV
func (d *Dataset) CSV() (*Exportable, error) { records := d.Records() b := newBuffer() w := csv.NewWriter(b) w.WriteAll(records) // calls Flush internally if err := w.Error(); err != nil { return nil, err } return newExportable(b), nil }
go
func (d *Dataset) CSV() (*Exportable, error) { records := d.Records() b := newBuffer() w := csv.NewWriter(b) w.WriteAll(records) // calls Flush internally if err := w.Error(); err != nil { return nil, err } return newExportable(b), nil }
[ "func", "(", "d", "*", "Dataset", ")", "CSV", "(", ")", "(", "*", "Exportable", ",", "error", ")", "{", "records", ":=", "d", ".", "Records", "(", ")", "\n", "b", ":=", "newBuffer", "(", ")", "\n\n", "w", ":=", "csv", ".", "NewWriter", "(", "b"...
// CSV returns a CSV representation of the Dataset an Exportable.
[ "CSV", "returns", "a", "CSV", "representation", "of", "the", "Dataset", "an", "Exportable", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_csv.go#L9-L21
146,382
agrison/go-tablib
tablib_csv.go
LoadTSV
func LoadTSV(input []byte) (*Dataset, error) { reader := csv.NewReader(bytes.NewReader(input)) reader.Comma = '\t' records, err := reader.ReadAll() if err != nil { return nil, err } ds := NewDataset(records[0]) for i := 1; i < len(records); i++ { // this is odd row := make([]interface{}, len(records[i]))...
go
func LoadTSV(input []byte) (*Dataset, error) { reader := csv.NewReader(bytes.NewReader(input)) reader.Comma = '\t' records, err := reader.ReadAll() if err != nil { return nil, err } ds := NewDataset(records[0]) for i := 1; i < len(records); i++ { // this is odd row := make([]interface{}, len(records[i]))...
[ "func", "LoadTSV", "(", "input", "[", "]", "byte", ")", "(", "*", "Dataset", ",", "error", ")", "{", "reader", ":=", "csv", ".", "NewReader", "(", "bytes", ".", "NewReader", "(", "input", ")", ")", "\n", "reader", ".", "Comma", "=", "'\\t'", "\n\n"...
// LoadTSV loads a Dataset by its TSV representation.
[ "LoadTSV", "loads", "a", "Dataset", "by", "its", "TSV", "representation", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_csv.go#L61-L81
146,383
jacobsa/ogletest
register.go
Register
func Register(suite TestSuite) { // Make sure the suite is legal. if suite.Name == "" { panic("Test suites must have names.") } for _, tf := range suite.TestFunctions { if tf.Name == "" { panic("Test functions must have names.") } if tf.Run == nil { panic("Test functions must have non-nil run fields...
go
func Register(suite TestSuite) { // Make sure the suite is legal. if suite.Name == "" { panic("Test suites must have names.") } for _, tf := range suite.TestFunctions { if tf.Name == "" { panic("Test functions must have names.") } if tf.Run == nil { panic("Test functions must have non-nil run fields...
[ "func", "Register", "(", "suite", "TestSuite", ")", "{", "// Make sure the suite is legal.", "if", "suite", ".", "Name", "==", "\"", "\"", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "for", "_", ",", "tf", ":=", "range", "suite", ".", "TestF...
// Register a test suite for execution by RunTests. // // This is the most general registration mechanism. Most users will want // RegisterTestSuite, which is a wrapper around this function that requires // less boilerplate. // // Panics on invalid input.
[ "Register", "a", "test", "suite", "for", "execution", "by", "RunTests", ".", "This", "is", "the", "most", "general", "registration", "mechanism", ".", "Most", "users", "will", "want", "RegisterTestSuite", "which", "is", "a", "wrapper", "around", "this", "funct...
80d50a735a1108a2aeb7abc4a988d183f20c5292
https://github.com/jacobsa/ogletest/blob/80d50a735a1108a2aeb7abc4a988d183f20c5292/register.go#L65-L83
146,384
agrison/go-tablib
tablib_sql.go
MySQL
func (d *Dataset) MySQL(table string) *Exportable { return d.sql(table, typeMySQL) }
go
func (d *Dataset) MySQL(table string) *Exportable { return d.sql(table, typeMySQL) }
[ "func", "(", "d", "*", "Dataset", ")", "MySQL", "(", "table", "string", ")", "*", "Exportable", "{", "return", "d", ".", "sql", "(", "table", ",", "typeMySQL", ")", "\n", "}" ]
// MySQL returns a string representing a suite of MySQL commands // recreating the Dataset into a table.
[ "MySQL", "returns", "a", "string", "representing", "a", "suite", "of", "MySQL", "commands", "recreating", "the", "Dataset", "into", "a", "table", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_sql.go#L76-L78
146,385
agrison/go-tablib
tablib_sql.go
Postgres
func (d *Dataset) Postgres(table string) *Exportable { return d.sql(table, typePostgres) }
go
func (d *Dataset) Postgres(table string) *Exportable { return d.sql(table, typePostgres) }
[ "func", "(", "d", "*", "Dataset", ")", "Postgres", "(", "table", "string", ")", "*", "Exportable", "{", "return", "d", ".", "sql", "(", "table", ",", "typePostgres", ")", "\n", "}" ]
// Postgres returns a string representing a suite of Postgres commands // recreating the Dataset into a table.
[ "Postgres", "returns", "a", "string", "representing", "a", "suite", "of", "Postgres", "commands", "recreating", "the", "Dataset", "into", "a", "table", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_sql.go#L82-L84
146,386
agrison/go-tablib
tablib_sql.go
sql
func (d *Dataset) sql(table, dbType string) *Exportable { b := newBuffer() tableSQL, columnTypes, columnValues := d.createTable(table, dbType) b.WriteString(tableSQL) reg, _ := regexp.Compile("[']") // inserts for i := range d.data { b.WriteString("INSERT INTO " + table + " VALUES(" + strconv.Itoa(i+1) + ", "...
go
func (d *Dataset) sql(table, dbType string) *Exportable { b := newBuffer() tableSQL, columnTypes, columnValues := d.createTable(table, dbType) b.WriteString(tableSQL) reg, _ := regexp.Compile("[']") // inserts for i := range d.data { b.WriteString("INSERT INTO " + table + " VALUES(" + strconv.Itoa(i+1) + ", "...
[ "func", "(", "d", "*", "Dataset", ")", "sql", "(", "table", ",", "dbType", "string", ")", "*", "Exportable", "{", "b", ":=", "newBuffer", "(", ")", "\n\n", "tableSQL", ",", "columnTypes", ",", "columnValues", ":=", "d", ".", "createTable", "(", "table"...
// sql returns a string representing a suite of SQL commands // recreating the Dataset into a table.
[ "sql", "returns", "a", "string", "representing", "a", "suite", "of", "SQL", "commands", "recreating", "the", "Dataset", "into", "a", "table", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_sql.go#L88-L120
146,387
jacobsa/ogletest
expect_that.go
expectThat
func expectThat( x interface{}, m oglematchers.Matcher, depth int, errorParts []interface{}) (passed bool) { // Check whether the value matches. If it does, we are finished. matcherErr := m.Matches(x) if matcherErr == nil { passed = true return } var r FailureRecord // Get information about the call sit...
go
func expectThat( x interface{}, m oglematchers.Matcher, depth int, errorParts []interface{}) (passed bool) { // Check whether the value matches. If it does, we are finished. matcherErr := m.Matches(x) if matcherErr == nil { passed = true return } var r FailureRecord // Get information about the call sit...
[ "func", "expectThat", "(", "x", "interface", "{", "}", ",", "m", "oglematchers", ".", "Matcher", ",", "depth", "int", ",", "errorParts", "[", "]", "interface", "{", "}", ")", "(", "passed", "bool", ")", "{", "// Check whether the value matches. If it does, we ...
// The generalized form of ExpectThat. depth is the distance on the stack // between the caller's frame and the user's frame. Returns passed iff the // match succeeded.
[ "The", "generalized", "form", "of", "ExpectThat", ".", "depth", "is", "the", "distance", "on", "the", "stack", "between", "the", "caller", "s", "frame", "and", "the", "user", "s", "frame", ".", "Returns", "passed", "iff", "the", "match", "succeeded", "." ]
80d50a735a1108a2aeb7abc4a988d183f20c5292
https://github.com/jacobsa/ogletest/blob/80d50a735a1108a2aeb7abc4a988d183f20c5292/expect_that.go#L48-L100
146,388
agrison/go-tablib
tablib_xml.go
XML
func (d *Databook) XML() (*Exportable, error) { b := newBuffer() b.WriteString("<databook>\n") for _, s := range d.sheets { b.WriteString(" <sheet>\n <title>" + s.title + "</title>\n ") row, err := s.dataset.XMLWithTagNamePrefixIndent("row", " ", " ") if err != nil { return nil, err } b.Wri...
go
func (d *Databook) XML() (*Exportable, error) { b := newBuffer() b.WriteString("<databook>\n") for _, s := range d.sheets { b.WriteString(" <sheet>\n <title>" + s.title + "</title>\n ") row, err := s.dataset.XMLWithTagNamePrefixIndent("row", " ", " ") if err != nil { return nil, err } b.Wri...
[ "func", "(", "d", "*", "Databook", ")", "XML", "(", ")", "(", "*", "Exportable", ",", "error", ")", "{", "b", ":=", "newBuffer", "(", ")", "\n", "b", ".", "WriteString", "(", "\"", "\\n", "\"", ")", "\n", "for", "_", ",", "s", ":=", "range", ...
// XML returns a XML representation of the Databook as an Exportable.
[ "XML", "returns", "a", "XML", "representation", "of", "the", "Databook", "as", "an", "Exportable", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_xml.go#L14-L28
146,389
agrison/go-tablib
tablib_xml.go
XMLWithTagNamePrefixIndent
func (d *Dataset) XMLWithTagNamePrefixIndent(tagName, prefix, indent string) (*Exportable, error) { back := d.Dict() exportable := newExportable(newBuffer()) exportable.buffer.WriteString("<dataset>\n") for _, r := range back { m := mxj.Map(r.(map[string]interface{})) if err := m.XmlIndentWriter(exportable.buf...
go
func (d *Dataset) XMLWithTagNamePrefixIndent(tagName, prefix, indent string) (*Exportable, error) { back := d.Dict() exportable := newExportable(newBuffer()) exportable.buffer.WriteString("<dataset>\n") for _, r := range back { m := mxj.Map(r.(map[string]interface{})) if err := m.XmlIndentWriter(exportable.buf...
[ "func", "(", "d", "*", "Dataset", ")", "XMLWithTagNamePrefixIndent", "(", "tagName", ",", "prefix", ",", "indent", "string", ")", "(", "*", "Exportable", ",", "error", ")", "{", "back", ":=", "d", ".", "Dict", "(", ")", "\n\n", "exportable", ":=", "new...
// XMLWithTagNamePrefixIndent returns a XML representation with custom tag, prefix and indent.
[ "XMLWithTagNamePrefixIndent", "returns", "a", "XML", "representation", "with", "custom", "tag", "prefix", "and", "indent", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_xml.go#L31-L45
146,390
agrison/go-tablib
tablib_xml.go
LoadXML
func LoadXML(input []byte) (*Dataset, error) { m, _, err := mxj.NewMapXmlReaderRaw(bytes.NewReader(input)) if err != nil { return nil, err } // this seems quite a bit hacky datasetNode, _ := m.ValueForPath("dataset") rowNode := datasetNode.(map[string]interface{})["row"].([]interface{}) back := make([]map[st...
go
func LoadXML(input []byte) (*Dataset, error) { m, _, err := mxj.NewMapXmlReaderRaw(bytes.NewReader(input)) if err != nil { return nil, err } // this seems quite a bit hacky datasetNode, _ := m.ValueForPath("dataset") rowNode := datasetNode.(map[string]interface{})["row"].([]interface{}) back := make([]map[st...
[ "func", "LoadXML", "(", "input", "[", "]", "byte", ")", "(", "*", "Dataset", ",", "error", ")", "{", "m", ",", "_", ",", "err", ":=", "mxj", ".", "NewMapXmlReaderRaw", "(", "bytes", ".", "NewReader", "(", "input", ")", ")", "\n", "if", "err", "!=...
// LoadXML loads a Dataset from an XML source.
[ "LoadXML", "loads", "a", "Dataset", "from", "an", "XML", "source", "." ]
4930582c22eec7bfc0e5b47e0246d5048a78fe49
https://github.com/agrison/go-tablib/blob/4930582c22eec7bfc0e5b47e0246d5048a78fe49/tablib_xml.go#L48-L64
146,391
koki/json
jsonutil/obj.go
GetOnlyMapEntry
func GetOnlyMapEntry(obj map[string]interface{}) (string, interface{}, error) { if len(obj) != 1 { return "", nil, errutil.InvalidInstanceErrorf(obj, "expected only one entry") } for key, val := range obj { return key, val, nil } panic("unreachable") return "", nil, fmt.Errorf("unreachable") }
go
func GetOnlyMapEntry(obj map[string]interface{}) (string, interface{}, error) { if len(obj) != 1 { return "", nil, errutil.InvalidInstanceErrorf(obj, "expected only one entry") } for key, val := range obj { return key, val, nil } panic("unreachable") return "", nil, fmt.Errorf("unreachable") }
[ "func", "GetOnlyMapEntry", "(", "obj", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "string", ",", "interface", "{", "}", ",", "error", ")", "{", "if", "len", "(", "obj", ")", "!=", "1", "{", "return", "\"", "\"", ",", "nil", ",", ...
// GetOnlyMapEntry get the only entry from a map. Error if the map doesn't contain exactly one entry.
[ "GetOnlyMapEntry", "get", "the", "only", "entry", "from", "a", "map", ".", "Error", "if", "the", "map", "doesn", "t", "contain", "exactly", "one", "entry", "." ]
e521cbda08e38a4d446cf3df04f927a6da8c002d
https://github.com/koki/json/blob/e521cbda08e38a4d446cf3df04f927a6da8c002d/jsonutil/obj.go#L12-L23
146,392
koki/json
jsonutil/obj.go
ExtraneousFieldPaths
func ExtraneousFieldPaths(data map[string]interface{}, parsed interface{}) ([][]string, error) { unparsed, err := MarshalMap(parsed) if err != nil { return nil, err } return ExtraneousMapPaths([]string{}, data, unparsed), nil }
go
func ExtraneousFieldPaths(data map[string]interface{}, parsed interface{}) ([][]string, error) { unparsed, err := MarshalMap(parsed) if err != nil { return nil, err } return ExtraneousMapPaths([]string{}, data, unparsed), nil }
[ "func", "ExtraneousFieldPaths", "(", "data", "map", "[", "string", "]", "interface", "{", "}", ",", "parsed", "interface", "{", "}", ")", "(", "[", "]", "[", "]", "string", ",", "error", ")", "{", "unparsed", ",", "err", ":=", "MarshalMap", "(", "par...
// ExtraneousFieldPaths finds paths in "data" that aren't in "parsed" by serializing // "parsed" to a dictionary and recursively comparing its fields to those of "data".
[ "ExtraneousFieldPaths", "finds", "paths", "in", "data", "that", "aren", "t", "in", "parsed", "by", "serializing", "parsed", "to", "a", "dictionary", "and", "recursively", "comparing", "its", "fields", "to", "those", "of", "data", "." ]
e521cbda08e38a4d446cf3df04f927a6da8c002d
https://github.com/koki/json/blob/e521cbda08e38a4d446cf3df04f927a6da8c002d/jsonutil/obj.go#L76-L83
146,393
piotrkowalczuk/ntypes
ntypes.go
BytesArrayOr
func (ba *BytesArray) BytesArrayOr(or [][]byte) [][]byte { switch { case ba == nil: return or case !ba.Valid: return or default: return ba.BytesArray } }
go
func (ba *BytesArray) BytesArrayOr(or [][]byte) [][]byte { switch { case ba == nil: return or case !ba.Valid: return or default: return ba.BytesArray } }
[ "func", "(", "ba", "*", "BytesArray", ")", "BytesArrayOr", "(", "or", "[", "]", "[", "]", "byte", ")", "[", "]", "[", "]", "byte", "{", "switch", "{", "case", "ba", "==", "nil", ":", "return", "or", "\n", "case", "!", "ba", ".", "Valid", ":", ...
// BytesArrayOr returns given slice if receiver is nil or invalid.
[ "BytesArrayOr", "returns", "given", "slice", "if", "receiver", "is", "nil", "or", "invalid", "." ]
15ae4dd32dbf658695648fdc52750c9c73223b71
https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L99-L108
146,394
piotrkowalczuk/ntypes
ntypes.go
StringOr
func (s *String) StringOr(or string) string { switch { case s == nil: return or case !s.Valid: return or default: return s.Chars } }
go
func (s *String) StringOr(or string) string { switch { case s == nil: return or case !s.Valid: return or default: return s.Chars } }
[ "func", "(", "s", "*", "String", ")", "StringOr", "(", "or", "string", ")", "string", "{", "switch", "{", "case", "s", "==", "nil", ":", "return", "or", "\n", "case", "!", "s", ".", "Valid", ":", "return", "or", "\n", "default", ":", "return", "s...
// StringOr returns given string value if receiver is nil or invalid.
[ "StringOr", "returns", "given", "string", "value", "if", "receiver", "is", "nil", "or", "invalid", "." ]
15ae4dd32dbf658695648fdc52750c9c73223b71
https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L116-L125
146,395
piotrkowalczuk/ntypes
ntypes.go
StringArrayOr
func (sa *StringArray) StringArrayOr(or []string) []string { switch { case sa == nil: return or case !sa.Valid: return or default: return sa.StringArray } }
go
func (sa *StringArray) StringArrayOr(or []string) []string { switch { case sa == nil: return or case !sa.Valid: return or default: return sa.StringArray } }
[ "func", "(", "sa", "*", "StringArray", ")", "StringArrayOr", "(", "or", "[", "]", "string", ")", "[", "]", "string", "{", "switch", "{", "case", "sa", "==", "nil", ":", "return", "or", "\n", "case", "!", "sa", ".", "Valid", ":", "return", "or", "...
// StringArrayOr returns given slice if receiver is nil or invalid.
[ "StringArrayOr", "returns", "given", "slice", "if", "receiver", "is", "nil", "or", "invalid", "." ]
15ae4dd32dbf658695648fdc52750c9c73223b71
https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L226-L235
146,396
piotrkowalczuk/ntypes
ntypes.go
Int64Or
func (i *Int64) Int64Or(or int64) int64 { if i == nil { return or } if !i.Valid { return or } return i.Int64 }
go
func (i *Int64) Int64Or(or int64) int64 { if i == nil { return or } if !i.Valid { return or } return i.Int64 }
[ "func", "(", "i", "*", "Int64", ")", "Int64Or", "(", "or", "int64", ")", "int64", "{", "if", "i", "==", "nil", "{", "return", "or", "\n", "}", "\n", "if", "!", "i", ".", "Valid", "{", "return", "or", "\n", "}", "\n\n", "return", "i", ".", "In...
// Int64Or returns given int64 value if receiver is nil or invalid.
[ "Int64Or", "returns", "given", "int64", "value", "if", "receiver", "is", "nil", "or", "invalid", "." ]
15ae4dd32dbf658695648fdc52750c9c73223b71
https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L243-L252
146,397
piotrkowalczuk/ntypes
ntypes.go
Int64ArrayOr
func (ia *Int64Array) Int64ArrayOr(or []int64) []int64 { switch { case ia == nil: return or case !ia.Valid: return or default: return ia.Int64Array } }
go
func (ia *Int64Array) Int64ArrayOr(or []int64) []int64 { switch { case ia == nil: return or case !ia.Valid: return or default: return ia.Int64Array } }
[ "func", "(", "ia", "*", "Int64Array", ")", "Int64ArrayOr", "(", "or", "[", "]", "int64", ")", "[", "]", "int64", "{", "switch", "{", "case", "ia", "==", "nil", ":", "return", "or", "\n", "case", "!", "ia", ".", "Valid", ":", "return", "or", "\n",...
// Int64ArrayOr returns given slice if receiver is nil or invalid.
[ "Int64ArrayOr", "returns", "given", "slice", "if", "receiver", "is", "nil", "or", "invalid", "." ]
15ae4dd32dbf658695648fdc52750c9c73223b71
https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L349-L358
146,398
piotrkowalczuk/ntypes
ntypes.go
Int32Or
func (i *Int32) Int32Or(or int32) int32 { if i == nil { return or } if !i.Valid { return or } return i.Int32 }
go
func (i *Int32) Int32Or(or int32) int32 { if i == nil { return or } if !i.Valid { return or } return i.Int32 }
[ "func", "(", "i", "*", "Int32", ")", "Int32Or", "(", "or", "int32", ")", "int32", "{", "if", "i", "==", "nil", "{", "return", "or", "\n", "}", "\n", "if", "!", "i", ".", "Valid", "{", "return", "or", "\n", "}", "\n\n", "return", "i", ".", "In...
// Int32Or returns given int32 value if receiver is nil or invalid.
[ "Int32Or", "returns", "given", "int32", "value", "if", "receiver", "is", "nil", "or", "invalid", "." ]
15ae4dd32dbf658695648fdc52750c9c73223b71
https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L366-L375
146,399
piotrkowalczuk/ntypes
ntypes.go
Int32ArrayOr
func (ia *Int32Array) Int32ArrayOr(or []int32) []int32 { switch { case ia == nil: return or case !ia.Valid: return or default: return ia.Int32Array } }
go
func (ia *Int32Array) Int32ArrayOr(or []int32) []int32 { switch { case ia == nil: return or case !ia.Valid: return or default: return ia.Int32Array } }
[ "func", "(", "ia", "*", "Int32Array", ")", "Int32ArrayOr", "(", "or", "[", "]", "int32", ")", "[", "]", "int32", "{", "switch", "{", "case", "ia", "==", "nil", ":", "return", "or", "\n", "case", "!", "ia", ".", "Valid", ":", "return", "or", "\n",...
// Int32ArrayOr returns given slice if receiver is nil or invalid.
[ "Int32ArrayOr", "returns", "given", "slice", "if", "receiver", "is", "nil", "or", "invalid", "." ]
15ae4dd32dbf658695648fdc52750c9c73223b71
https://github.com/piotrkowalczuk/ntypes/blob/15ae4dd32dbf658695648fdc52750c9c73223b71/ntypes.go#L455-L464