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
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
18,000
revel/cmd
utils/file.go
PanicOnError
func PanicOnError(err error, msg string) { if revErr, ok := err.(*Error); (ok && revErr != nil) || (!ok && err != nil) { Logger.Panicf("Abort: %s: %s %s", msg, revErr, err) } }
go
func PanicOnError(err error, msg string) { if revErr, ok := err.(*Error); (ok && revErr != nil) || (!ok && err != nil) { Logger.Panicf("Abort: %s: %s %s", msg, revErr, err) } }
[ "func", "PanicOnError", "(", "err", "error", ",", "msg", "string", ")", "{", "if", "revErr", ",", "ok", ":=", "err", ".", "(", "*", "Error", ")", ";", "(", "ok", "&&", "revErr", "!=", "nil", ")", "||", "(", "!", "ok", "&&", "err", "!=", "nil", ...
// Called if panic
[ "Called", "if", "panic" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/utils/file.go#L152-L156
18,001
revel/cmd
utils/file.go
CopyDir
func CopyDir(destDir, srcDir string, data map[string]interface{}) error { if !DirExists(srcDir) { return nil } return fsWalk(srcDir, srcDir, func(srcPath string, info os.FileInfo, err error) error { // Get the relative path from the source base, and the corresponding path in // the dest directory. relSrcPath...
go
func CopyDir(destDir, srcDir string, data map[string]interface{}) error { if !DirExists(srcDir) { return nil } return fsWalk(srcDir, srcDir, func(srcPath string, info os.FileInfo, err error) error { // Get the relative path from the source base, and the corresponding path in // the dest directory. relSrcPath...
[ "func", "CopyDir", "(", "destDir", ",", "srcDir", "string", ",", "data", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "if", "!", "DirExists", "(", "srcDir", ")", "{", "return", "nil", "\n", "}", "\n", "return", "fsWalk", "(", ...
// copyDir copies a directory tree over to a new directory. Any files ending in // ".template" are treated as a Go template and rendered using the given data. // Additionally, the trailing ".template" is stripped from the file name. // Also, dot files and dot directories are skipped.
[ "copyDir", "copies", "a", "directory", "tree", "over", "to", "a", "new", "directory", ".", "Any", "files", "ending", "in", ".", "template", "are", "treated", "as", "a", "Go", "template", "and", "rendered", "using", "the", "given", "data", ".", "Additionall...
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/utils/file.go#L162-L199
18,002
revel/cmd
utils/file.go
TarGzDir
func TarGzDir(destFilename, srcDir string) (name string, err error) { zipFile, err := os.Create(destFilename) if err != nil { return "", NewBuildIfError(err, "Failed to create archive", "file", destFilename) } defer func() { _ = zipFile.Close() }() gzipWriter := gzip.NewWriter(zipFile) defer func() { _ =...
go
func TarGzDir(destFilename, srcDir string) (name string, err error) { zipFile, err := os.Create(destFilename) if err != nil { return "", NewBuildIfError(err, "Failed to create archive", "file", destFilename) } defer func() { _ = zipFile.Close() }() gzipWriter := gzip.NewWriter(zipFile) defer func() { _ =...
[ "func", "TarGzDir", "(", "destFilename", ",", "srcDir", "string", ")", "(", "name", "string", ",", "err", "error", ")", "{", "zipFile", ",", "err", ":=", "os", ".", "Create", "(", "destFilename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\...
// Tar gz the folder
[ "Tar", "gz", "the", "folder" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/utils/file.go#L247-L300
18,003
revel/cmd
utils/file.go
Empty
func Empty(dirname string) bool { dir, err := os.Open(dirname) if err != nil { Logger.Infof("error opening directory: %s", err) } defer func() { _ = dir.Close() }() results, _ := dir.Readdir(1) return len(results) == 0 }
go
func Empty(dirname string) bool { dir, err := os.Open(dirname) if err != nil { Logger.Infof("error opening directory: %s", err) } defer func() { _ = dir.Close() }() results, _ := dir.Readdir(1) return len(results) == 0 }
[ "func", "Empty", "(", "dirname", "string", ")", "bool", "{", "dir", ",", "err", ":=", "os", ".", "Open", "(", "dirname", ")", "\n", "if", "err", "!=", "nil", "{", "Logger", ".", "Infof", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "defer...
// empty returns true if the given directory is empty. // the directory must exist.
[ "empty", "returns", "true", "if", "the", "given", "directory", "is", "empty", ".", "the", "directory", "must", "exist", "." ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/utils/file.go#L310-L320
18,004
revel/cmd
utils/file.go
FindSrcPaths
func FindSrcPaths(appImportPath, revelImportPath string, packageResolver func(pkgName string) error) (appSourcePath, revelSourcePath string, err error) { var ( gopaths = filepath.SplitList(build.Default.GOPATH) goroot = build.Default.GOROOT ) if len(gopaths) == 0 { err = errors.New("GOPATH environment variab...
go
func FindSrcPaths(appImportPath, revelImportPath string, packageResolver func(pkgName string) error) (appSourcePath, revelSourcePath string, err error) { var ( gopaths = filepath.SplitList(build.Default.GOPATH) goroot = build.Default.GOROOT ) if len(gopaths) == 0 { err = errors.New("GOPATH environment variab...
[ "func", "FindSrcPaths", "(", "appImportPath", ",", "revelImportPath", "string", ",", "packageResolver", "func", "(", "pkgName", "string", ")", "error", ")", "(", "appSourcePath", ",", "revelSourcePath", "string", ",", "err", "error", ")", "{", "var", "(", "gop...
// Find the full source dir for the import path, uses the build.Default.GOPATH to search for the directory
[ "Find", "the", "full", "source", "dir", "for", "the", "import", "path", "uses", "the", "build", ".", "Default", ".", "GOPATH", "to", "search", "for", "the", "directory" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/utils/file.go#L323-L368
18,005
revel/cmd
model/version.go
intOrZero
func (v *Version) intOrZero(input string) (value int) { if input != "" { value, _ = strconv.Atoi(input) } return value }
go
func (v *Version) intOrZero(input string) (value int) { if input != "" { value, _ = strconv.Atoi(input) } return value }
[ "func", "(", "v", "*", "Version", ")", "intOrZero", "(", "input", "string", ")", "(", "value", "int", ")", "{", "if", "input", "!=", "\"", "\"", "{", "value", ",", "_", "=", "strconv", ".", "Atoi", "(", "input", ")", "\n", "}", "\n", "return", ...
// Returns 0 or an int value for the string, errors are returned as 0
[ "Returns", "0", "or", "an", "int", "value", "for", "the", "string", "errors", "are", "returned", "as", "0" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/version.go#L58-L63
18,006
revel/cmd
model/version.go
CompatibleFramework
func (v *Version) CompatibleFramework(c *CommandConfig) error { for i, rv := range frameworkCompatibleRangeList { start, _ := ParseVersion(rv[0]) end, _ := ParseVersion(rv[1]) if !v.Newer(start) || v.Newer(end) { continue } // Framework is older then 0.20, turn on historic mode if i == 0 { c.Historic...
go
func (v *Version) CompatibleFramework(c *CommandConfig) error { for i, rv := range frameworkCompatibleRangeList { start, _ := ParseVersion(rv[0]) end, _ := ParseVersion(rv[1]) if !v.Newer(start) || v.Newer(end) { continue } // Framework is older then 0.20, turn on historic mode if i == 0 { c.Historic...
[ "func", "(", "v", "*", "Version", ")", "CompatibleFramework", "(", "c", "*", "CommandConfig", ")", "error", "{", "for", "i", ",", "rv", ":=", "range", "frameworkCompatibleRangeList", "{", "start", ",", "_", ":=", "ParseVersion", "(", "rv", "[", "0", "]",...
// Returns true if this major revision is compatible
[ "Returns", "true", "if", "this", "major", "revision", "is", "compatible" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/version.go#L66-L80
18,007
revel/cmd
model/version.go
MajorNewer
func (v *Version) MajorNewer(o *Version) bool { if v.Major != o.Major { return v.Major > o.Major } return false }
go
func (v *Version) MajorNewer(o *Version) bool { if v.Major != o.Major { return v.Major > o.Major } return false }
[ "func", "(", "v", "*", "Version", ")", "MajorNewer", "(", "o", "*", "Version", ")", "bool", "{", "if", "v", ".", "Major", "!=", "o", ".", "Major", "{", "return", "v", ".", "Major", ">", "o", ".", "Major", "\n", "}", "\n", "return", "false", "\n...
// Returns true if this major revision is newer then the passed in
[ "Returns", "true", "if", "this", "major", "revision", "is", "newer", "then", "the", "passed", "in" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/version.go#L83-L88
18,008
revel/cmd
model/version.go
MinorNewer
func (v *Version) MinorNewer(o *Version) bool { if v.Major != o.Major { return v.Major > o.Major } if v.Minor != o.Minor { return v.Minor > o.Minor } return false }
go
func (v *Version) MinorNewer(o *Version) bool { if v.Major != o.Major { return v.Major > o.Major } if v.Minor != o.Minor { return v.Minor > o.Minor } return false }
[ "func", "(", "v", "*", "Version", ")", "MinorNewer", "(", "o", "*", "Version", ")", "bool", "{", "if", "v", ".", "Major", "!=", "o", ".", "Major", "{", "return", "v", ".", "Major", ">", "o", ".", "Major", "\n", "}", "\n", "if", "v", ".", "Min...
// Returns true if this major or major and minor revision is newer then the value passed in
[ "Returns", "true", "if", "this", "major", "or", "major", "and", "minor", "revision", "is", "newer", "then", "the", "value", "passed", "in" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/version.go#L91-L99
18,009
revel/cmd
model/version.go
Newer
func (v *Version) Newer(o *Version) bool { if v.Major != o.Major { return v.Major > o.Major } if v.Minor != o.Minor { return v.Minor > o.Minor } if v.Maintenance != o.Maintenance { return v.Maintenance > o.Maintenance } return false }
go
func (v *Version) Newer(o *Version) bool { if v.Major != o.Major { return v.Major > o.Major } if v.Minor != o.Minor { return v.Minor > o.Minor } if v.Maintenance != o.Maintenance { return v.Maintenance > o.Maintenance } return false }
[ "func", "(", "v", "*", "Version", ")", "Newer", "(", "o", "*", "Version", ")", "bool", "{", "if", "v", ".", "Major", "!=", "o", ".", "Major", "{", "return", "v", ".", "Major", ">", "o", ".", "Major", "\n", "}", "\n", "if", "v", ".", "Minor", ...
// Returns true if the version is newer then the current on
[ "Returns", "true", "if", "the", "version", "is", "newer", "then", "the", "current", "on" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/version.go#L102-L113
18,010
revel/cmd
model/version.go
VersionString
func (v *Version) VersionString() string { return fmt.Sprintf("%s%d.%d.%d%s", v.Prefix, v.Major, v.Minor, v.Maintenance, v.Suffix) }
go
func (v *Version) VersionString() string { return fmt.Sprintf("%s%d.%d.%d%s", v.Prefix, v.Major, v.Minor, v.Maintenance, v.Suffix) }
[ "func", "(", "v", "*", "Version", ")", "VersionString", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "v", ".", "Prefix", ",", "v", ".", "Major", ",", "v", ".", "Minor", ",", "v", ".", "Maintenance", ",", "v", ...
// Convert the version to a string
[ "Convert", "the", "version", "to", "a", "string" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/version.go#L116-L118
18,011
revel/cmd
model/version.go
String
func (v *Version) String() string { return fmt.Sprintf("Version: %s%d.%d.%d%s\nBuild Date: %s\n Minimium Go Version: %s", v.Prefix, v.Major, v.Minor, v.Maintenance, v.Suffix, v.BuildDate, v.MinGoVersion) }
go
func (v *Version) String() string { return fmt.Sprintf("Version: %s%d.%d.%d%s\nBuild Date: %s\n Minimium Go Version: %s", v.Prefix, v.Major, v.Minor, v.Maintenance, v.Suffix, v.BuildDate, v.MinGoVersion) }
[ "func", "(", "v", "*", "Version", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\\n", "\"", ",", "v", ".", "Prefix", ",", "v", ".", "Major", ",", "v", ".", "Minor", ",", "v", ".", "Maintenance", ","...
// Convert the version build date and go version to a string
[ "Convert", "the", "version", "build", "date", "and", "go", "version", "to", "a", "string" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/version.go#L121-L124
18,012
revel/cmd
harness/harness.go
ServeHTTP
func (h *Harness) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Don't rebuild the app for favicon requests. if lastRequestHadError > 0 && r.URL.Path == "/favicon.ico" { return } // Flush any change events and rebuild app if necessary. // Render an error page if the rebuild / restart failed. err := h.w...
go
func (h *Harness) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Don't rebuild the app for favicon requests. if lastRequestHadError > 0 && r.URL.Path == "/favicon.ico" { return } // Flush any change events and rebuild app if necessary. // Render an error page if the rebuild / restart failed. err := h.w...
[ "func", "(", "h", "*", "Harness", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "// Don't rebuild the app for favicon requests.", "if", "lastRequestHadError", ">", "0", "&&", "r", ".", "URL", ".",...
// ServeHTTP handles all requests. // It checks for changes to app, rebuilds if necessary, and forwards the request.
[ "ServeHTTP", "handles", "all", "requests", ".", "It", "checks", "for", "changes", "to", "app", "rebuilds", "if", "necessary", "and", "forwards", "the", "request", "." ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/harness.go#L120-L148
18,013
revel/cmd
harness/harness.go
NewHarness
func NewHarness(c *model.CommandConfig, paths *model.RevelContainer, runMode string, noProxy bool) *Harness { // Get a template loader to render errors. // Prefer the app's views/errors directory, and fall back to the stock error pages. //revel.MainTemplateLoader = revel.NewTemplateLoader( // []string{filepath.Join...
go
func NewHarness(c *model.CommandConfig, paths *model.RevelContainer, runMode string, noProxy bool) *Harness { // Get a template loader to render errors. // Prefer the app's views/errors directory, and fall back to the stock error pages. //revel.MainTemplateLoader = revel.NewTemplateLoader( // []string{filepath.Join...
[ "func", "NewHarness", "(", "c", "*", "model", ".", "CommandConfig", ",", "paths", "*", "model", ".", "RevelContainer", ",", "runMode", "string", ",", "noProxy", "bool", ")", "*", "Harness", "{", "// Get a template loader to render errors.", "// Prefer the app's view...
// NewHarness method returns a reverse proxy that forwards requests // to the given port.
[ "NewHarness", "method", "returns", "a", "reverse", "proxy", "that", "forwards", "requests", "to", "the", "given", "port", "." ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/harness.go#L152-L198
18,014
revel/cmd
harness/harness.go
Refresh
func (h *Harness) Refresh() (err *utils.Error) { // Allow only one thread to rebuild the process // If multiple requests to rebuild are queued only the last one is executed on // So before a build is started we wait for a second to determine if // more requests for a build are triggered. // Once no more requests a...
go
func (h *Harness) Refresh() (err *utils.Error) { // Allow only one thread to rebuild the process // If multiple requests to rebuild are queued only the last one is executed on // So before a build is started we wait for a second to determine if // more requests for a build are triggered. // Once no more requests a...
[ "func", "(", "h", "*", "Harness", ")", "Refresh", "(", ")", "(", "err", "*", "utils", ".", "Error", ")", "{", "// Allow only one thread to rebuild the process", "// If multiple requests to rebuild are queued only the last one is executed on", "// So before a build is started we...
// Refresh method rebuilds the Revel application and run it on the given port. // called by the watcher
[ "Refresh", "method", "rebuilds", "the", "Revel", "application", "and", "run", "it", "on", "the", "given", "port", ".", "called", "by", "the", "watcher" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/harness.go#L202-L247
18,015
revel/cmd
harness/harness.go
WatchDir
func (h *Harness) WatchDir(info os.FileInfo) bool { return !utils.ContainsString(doNotWatch, info.Name()) }
go
func (h *Harness) WatchDir(info os.FileInfo) bool { return !utils.ContainsString(doNotWatch, info.Name()) }
[ "func", "(", "h", "*", "Harness", ")", "WatchDir", "(", "info", "os", ".", "FileInfo", ")", "bool", "{", "return", "!", "utils", ".", "ContainsString", "(", "doNotWatch", ",", "info", ".", "Name", "(", ")", ")", "\n", "}" ]
// WatchDir method returns false to file matches with doNotWatch // otheriwse true
[ "WatchDir", "method", "returns", "false", "to", "file", "matches", "with", "doNotWatch", "otheriwse", "true" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/harness.go#L251-L253
18,016
revel/cmd
harness/harness.go
Run
func (h *Harness) Run() { var paths []string if h.paths.Config.BoolDefault("watch.gopath", false) { gopaths := filepath.SplitList(build.Default.GOPATH) paths = append(paths, gopaths...) } paths = append(paths, h.paths.CodePaths...) h.watcher = watcher.NewWatcher(h.paths, false) h.watcher.Listen(h, paths...) ...
go
func (h *Harness) Run() { var paths []string if h.paths.Config.BoolDefault("watch.gopath", false) { gopaths := filepath.SplitList(build.Default.GOPATH) paths = append(paths, gopaths...) } paths = append(paths, h.paths.CodePaths...) h.watcher = watcher.NewWatcher(h.paths, false) h.watcher.Listen(h, paths...) ...
[ "func", "(", "h", "*", "Harness", ")", "Run", "(", ")", "{", "var", "paths", "[", "]", "string", "\n", "if", "h", ".", "paths", ".", "Config", ".", "BoolDefault", "(", "\"", "\"", ",", "false", ")", "{", "gopaths", ":=", "filepath", ".", "SplitLi...
// Run the harness, which listens for requests and proxies them to the app // server, which it runs and rebuilds as necessary.
[ "Run", "the", "harness", "which", "listens", "for", "requests", "and", "proxies", "them", "to", "the", "app", "server", "which", "it", "runs", "and", "rebuilds", "as", "necessary", "." ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/harness.go#L263-L307
18,017
revel/cmd
harness/harness.go
getFreePort
func getFreePort() (port int) { conn, err := net.Listen("tcp", ":0") if err != nil { utils.Logger.Fatal("Unable to fetch a freee port address", "error", err) } port = conn.Addr().(*net.TCPAddr).Port err = conn.Close() if err != nil { utils.Logger.Fatal("Unable to close port", "error", err) } return port }
go
func getFreePort() (port int) { conn, err := net.Listen("tcp", ":0") if err != nil { utils.Logger.Fatal("Unable to fetch a freee port address", "error", err) } port = conn.Addr().(*net.TCPAddr).Port err = conn.Close() if err != nil { utils.Logger.Fatal("Unable to close port", "error", err) } return port }
[ "func", "getFreePort", "(", ")", "(", "port", "int", ")", "{", "conn", ",", "err", ":=", "net", ".", "Listen", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "utils", ".", "Logger", ".", "Fatal", "(", "\"", "\"", ...
// Find an unused port
[ "Find", "an", "unused", "port" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/harness.go#L310-L322
18,018
revel/cmd
parser/appends.go
appendStruct
func appendStruct(fileName string, specs []*model.TypeInfo, pkgImportPath string, pkg *ast.Package, decl ast.Decl, imports map[string]string, fset *token.FileSet) []*model.TypeInfo { // Filter out non-Struct type declarations. spec, found := getStructTypeDecl(decl, fset) if !found { return specs } structType :=...
go
func appendStruct(fileName string, specs []*model.TypeInfo, pkgImportPath string, pkg *ast.Package, decl ast.Decl, imports map[string]string, fset *token.FileSet) []*model.TypeInfo { // Filter out non-Struct type declarations. spec, found := getStructTypeDecl(decl, fset) if !found { return specs } structType :=...
[ "func", "appendStruct", "(", "fileName", "string", ",", "specs", "[", "]", "*", "model", ".", "TypeInfo", ",", "pkgImportPath", "string", ",", "pkg", "*", "ast", ".", "Package", ",", "decl", "ast", ".", "Decl", ",", "imports", "map", "[", "string", "]"...
// If this Decl is a struct type definition, it is summarized and added to specs. // Else, specs is returned unchanged.
[ "If", "this", "Decl", "is", "a", "struct", "type", "definition", "it", "is", "summarized", "and", "added", "to", "specs", ".", "Else", "specs", "is", "returned", "unchanged", "." ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/parser/appends.go#L12-L90
18,019
revel/cmd
parser/appends.go
appendSourceInfo
func appendSourceInfo(srcInfo1, srcInfo2 *model.SourceInfo) *model.SourceInfo { if srcInfo1 == nil { return srcInfo2 } srcInfo1.StructSpecs = append(srcInfo1.StructSpecs, srcInfo2.StructSpecs...) srcInfo1.InitImportPaths = append(srcInfo1.InitImportPaths, srcInfo2.InitImportPaths...) for k, v := range srcInfo2....
go
func appendSourceInfo(srcInfo1, srcInfo2 *model.SourceInfo) *model.SourceInfo { if srcInfo1 == nil { return srcInfo2 } srcInfo1.StructSpecs = append(srcInfo1.StructSpecs, srcInfo2.StructSpecs...) srcInfo1.InitImportPaths = append(srcInfo1.InitImportPaths, srcInfo2.InitImportPaths...) for k, v := range srcInfo2....
[ "func", "appendSourceInfo", "(", "srcInfo1", ",", "srcInfo2", "*", "model", ".", "SourceInfo", ")", "*", "model", ".", "SourceInfo", "{", "if", "srcInfo1", "==", "nil", "{", "return", "srcInfo2", "\n", "}", "\n\n", "srcInfo1", ".", "StructSpecs", "=", "app...
// Combine the 2 source info models into one
[ "Combine", "the", "2", "source", "info", "models", "into", "one" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/parser/appends.go#L208-L223
18,020
revel/cmd
utils/build_error.go
NewBuildError
func NewBuildError(message string, args ...interface{}) (b *BuildError) { Logger.Info(message, args...) b = &BuildError{} b.Message = message b.Args = args b.Stack = logger.NewCallStack() Logger.Info("Stack", "stack", b.Stack) return b }
go
func NewBuildError(message string, args ...interface{}) (b *BuildError) { Logger.Info(message, args...) b = &BuildError{} b.Message = message b.Args = args b.Stack = logger.NewCallStack() Logger.Info("Stack", "stack", b.Stack) return b }
[ "func", "NewBuildError", "(", "message", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "b", "*", "BuildError", ")", "{", "Logger", ".", "Info", "(", "message", ",", "args", "...", ")", "\n", "b", "=", "&", "BuildError", "{", "}", "...
// Returns a new builed error
[ "Returns", "a", "new", "builed", "error" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/utils/build_error.go#L17-L25
18,021
revel/cmd
utils/build_error.go
NewBuildIfError
func NewBuildIfError(err error, message string, args ...interface{}) (b error) { if err != nil { if berr, ok := err.(*BuildError); ok { // This is already a build error so just append the args berr.Args = append(berr.Args, args...) return berr } else { args = append(args, "error", err.Error()) b = N...
go
func NewBuildIfError(err error, message string, args ...interface{}) (b error) { if err != nil { if berr, ok := err.(*BuildError); ok { // This is already a build error so just append the args berr.Args = append(berr.Args, args...) return berr } else { args = append(args, "error", err.Error()) b = N...
[ "func", "NewBuildIfError", "(", "err", "error", ",", "message", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "b", "error", ")", "{", "if", "err", "!=", "nil", "{", "if", "berr", ",", "ok", ":=", "err", ".", "(", "*", "BuildError",...
// Returns a new BuildError if err is not nil
[ "Returns", "a", "new", "BuildError", "if", "err", "is", "not", "nil" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/utils/build_error.go#L28-L40
18,022
revel/cmd
parser/reflect.go
ProcessSource
func ProcessSource(paths *model.RevelContainer) (_ *model.SourceInfo, compileError error) { pc := &processContainer{paths: paths} for _, root := range paths.CodePaths { rootImportPath := importPathFromPath(root, paths.BasePath) if rootImportPath == "" { utils.Logger.Info("Skipping empty code path", "path", roo...
go
func ProcessSource(paths *model.RevelContainer) (_ *model.SourceInfo, compileError error) { pc := &processContainer{paths: paths} for _, root := range paths.CodePaths { rootImportPath := importPathFromPath(root, paths.BasePath) if rootImportPath == "" { utils.Logger.Info("Skipping empty code path", "path", roo...
[ "func", "ProcessSource", "(", "paths", "*", "model", ".", "RevelContainer", ")", "(", "_", "*", "model", ".", "SourceInfo", ",", "compileError", "error", ")", "{", "pc", ":=", "&", "processContainer", "{", "paths", ":", "paths", "}", "\n", "for", "_", ...
// ProcessSource parses the app controllers directory and // returns a list of the controller types found. // Otherwise CompileError if the parsing fails.
[ "ProcessSource", "parses", "the", "app", "controllers", "directory", "and", "returns", "a", "list", "of", "the", "controller", "types", "found", ".", "Otherwise", "CompileError", "if", "the", "parsing", "fails", "." ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/parser/reflect.go#L37-L55
18,023
revel/cmd
parser/reflect.go
processPath
func (pc *processContainer) processPath(path string, info os.FileInfo, err error) error { if err != nil { utils.Logger.Error("Error scanning app source:", "error", err) return nil } if !info.IsDir() || info.Name() == "tmp" { return nil } // Get the import path of the package. pkgImportPath := pc.rootImpor...
go
func (pc *processContainer) processPath(path string, info os.FileInfo, err error) error { if err != nil { utils.Logger.Error("Error scanning app source:", "error", err) return nil } if !info.IsDir() || info.Name() == "tmp" { return nil } // Get the import path of the package. pkgImportPath := pc.rootImpor...
[ "func", "(", "pc", "*", "processContainer", ")", "processPath", "(", "path", "string", ",", "info", "os", ".", "FileInfo", ",", "err", "error", ")", "error", "{", "if", "err", "!=", "nil", "{", "utils", ".", "Logger", ".", "Error", "(", "\"", "\"", ...
// Called during the "walk process"
[ "Called", "during", "the", "walk", "process" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/parser/reflect.go#L58-L147
18,024
revel/cmd
parser/reflect.go
processPackage
func processPackage(fset *token.FileSet, pkgImportPath, pkgPath string, pkg *ast.Package) *model.SourceInfo { var ( structSpecs []*model.TypeInfo initImportPaths []string methodSpecs = make(methodMap) validationKeys = make(map[string]map[int]string) scanControllers = strings.HasSuffix(pkgImportPath...
go
func processPackage(fset *token.FileSet, pkgImportPath, pkgPath string, pkg *ast.Package) *model.SourceInfo { var ( structSpecs []*model.TypeInfo initImportPaths []string methodSpecs = make(methodMap) validationKeys = make(map[string]map[int]string) scanControllers = strings.HasSuffix(pkgImportPath...
[ "func", "processPackage", "(", "fset", "*", "token", ".", "FileSet", ",", "pkgImportPath", ",", "pkgPath", "string", ",", "pkg", "*", "ast", ".", "Package", ")", "*", "model", ".", "SourceInfo", "{", "var", "(", "structSpecs", "[", "]", "*", "model", "...
// Process a single package within a file
[ "Process", "a", "single", "package", "within", "a", "file" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/parser/reflect.go#L150-L208
18,025
revel/cmd
parser/reflect.go
getStructTypeDecl
func getStructTypeDecl(decl ast.Decl, fset *token.FileSet) (spec *ast.TypeSpec, found bool) { genDecl, ok := decl.(*ast.GenDecl) if !ok { return } if genDecl.Tok != token.TYPE { return } if len(genDecl.Specs) == 0 { utils.Logger.Warn("Warn: Surprising: %s:%d Decl contains no specifications", fset.Position...
go
func getStructTypeDecl(decl ast.Decl, fset *token.FileSet) (spec *ast.TypeSpec, found bool) { genDecl, ok := decl.(*ast.GenDecl) if !ok { return } if genDecl.Tok != token.TYPE { return } if len(genDecl.Specs) == 0 { utils.Logger.Warn("Warn: Surprising: %s:%d Decl contains no specifications", fset.Position...
[ "func", "getStructTypeDecl", "(", "decl", "ast", ".", "Decl", ",", "fset", "*", "token", ".", "FileSet", ")", "(", "spec", "*", "ast", ".", "TypeSpec", ",", "found", "bool", ")", "{", "genDecl", ",", "ok", ":=", "decl", ".", "(", "*", "ast", ".", ...
// getStructTypeDecl checks if the given decl is a type declaration for a // struct. If so, the TypeSpec is returned.
[ "getStructTypeDecl", "checks", "if", "the", "given", "decl", "is", "a", "type", "declaration", "for", "a", "struct", ".", "If", "so", "the", "TypeSpec", "is", "returned", "." ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/parser/reflect.go#L228-L247
18,026
revel/cmd
harness/app.go
NewApp
func NewApp(binPath string, paths *model.RevelContainer) *App { return &App{BinaryPath: binPath, Paths: paths, Port: paths.HTTPPort} }
go
func NewApp(binPath string, paths *model.RevelContainer) *App { return &App{BinaryPath: binPath, Paths: paths, Port: paths.HTTPPort} }
[ "func", "NewApp", "(", "binPath", "string", ",", "paths", "*", "model", ".", "RevelContainer", ")", "*", "App", "{", "return", "&", "App", "{", "BinaryPath", ":", "binPath", ",", "Paths", ":", "paths", ",", "Port", ":", "paths", ".", "HTTPPort", "}", ...
// NewApp returns app instance with binary path in it
[ "NewApp", "returns", "app", "instance", "with", "binary", "path", "in", "it" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/app.go#L31-L33
18,027
revel/cmd
harness/app.go
Cmd
func (a *App) Cmd(runMode string) AppCmd { a.cmd = NewAppCmd(a.BinaryPath, a.Port, runMode, a.Paths) return a.cmd }
go
func (a *App) Cmd(runMode string) AppCmd { a.cmd = NewAppCmd(a.BinaryPath, a.Port, runMode, a.Paths) return a.cmd }
[ "func", "(", "a", "*", "App", ")", "Cmd", "(", "runMode", "string", ")", "AppCmd", "{", "a", ".", "cmd", "=", "NewAppCmd", "(", "a", ".", "BinaryPath", ",", "a", ".", "Port", ",", "runMode", ",", "a", ".", "Paths", ")", "\n", "return", "a", "."...
// Cmd returns a command to run the app server using the current configuration.
[ "Cmd", "returns", "a", "command", "to", "run", "the", "app", "server", "using", "the", "current", "configuration", "." ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/app.go#L36-L39
18,028
revel/cmd
harness/app.go
NewAppCmd
func NewAppCmd(binPath string, port int, runMode string, paths *model.RevelContainer) AppCmd { cmd := exec.Command(binPath, fmt.Sprintf("-port=%d", port), fmt.Sprintf("-importPath=%s", paths.ImportPath), fmt.Sprintf("-runMode=%s", runMode)) cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr return AppCmd{cmd} }
go
func NewAppCmd(binPath string, port int, runMode string, paths *model.RevelContainer) AppCmd { cmd := exec.Command(binPath, fmt.Sprintf("-port=%d", port), fmt.Sprintf("-importPath=%s", paths.ImportPath), fmt.Sprintf("-runMode=%s", runMode)) cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr return AppCmd{cmd} }
[ "func", "NewAppCmd", "(", "binPath", "string", ",", "port", "int", ",", "runMode", "string", ",", "paths", "*", "model", ".", "RevelContainer", ")", "AppCmd", "{", "cmd", ":=", "exec", ".", "Command", "(", "binPath", ",", "fmt", ".", "Sprintf", "(", "\...
// NewAppCmd returns the AppCmd with parameters initialized for running app
[ "NewAppCmd", "returns", "the", "AppCmd", "with", "parameters", "initialized", "for", "running", "app" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/app.go#L53-L60
18,029
revel/cmd
harness/app.go
Start
func (cmd AppCmd) Start(c *model.CommandConfig) error { listeningWriter := &startupListeningWriter{os.Stdout, make(chan bool), c, &bytes.Buffer{}} cmd.Stdout = listeningWriter utils.Logger.Info("Exec app:", "path", cmd.Path, "args", cmd.Args, "dir", cmd.Dir, "env", cmd.Env) utils.CmdInit(cmd.Cmd, c.AppPath) if err...
go
func (cmd AppCmd) Start(c *model.CommandConfig) error { listeningWriter := &startupListeningWriter{os.Stdout, make(chan bool), c, &bytes.Buffer{}} cmd.Stdout = listeningWriter utils.Logger.Info("Exec app:", "path", cmd.Path, "args", cmd.Args, "dir", cmd.Dir, "env", cmd.Env) utils.CmdInit(cmd.Cmd, c.AppPath) if err...
[ "func", "(", "cmd", "AppCmd", ")", "Start", "(", "c", "*", "model", ".", "CommandConfig", ")", "error", "{", "listeningWriter", ":=", "&", "startupListeningWriter", "{", "os", ".", "Stdout", ",", "make", "(", "chan", "bool", ")", ",", "c", ",", "&", ...
// Start the app server, and wait until it is ready to serve requests.
[ "Start", "the", "app", "server", "and", "wait", "until", "it", "is", "ready", "to", "serve", "requests", "." ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/app.go#L63-L91
18,030
revel/cmd
harness/app.go
Run
func (cmd AppCmd) Run() { utils.Logger.Info("Exec app:", "path", cmd.Path, "args", cmd.Args) if err := cmd.Cmd.Run(); err != nil { utils.Logger.Fatal("Error running:", "error", err) } }
go
func (cmd AppCmd) Run() { utils.Logger.Info("Exec app:", "path", cmd.Path, "args", cmd.Args) if err := cmd.Cmd.Run(); err != nil { utils.Logger.Fatal("Error running:", "error", err) } }
[ "func", "(", "cmd", "AppCmd", ")", "Run", "(", ")", "{", "utils", ".", "Logger", ".", "Info", "(", "\"", "\"", ",", "\"", "\"", ",", "cmd", ".", "Path", ",", "\"", "\"", ",", "cmd", ".", "Args", ")", "\n", "if", "err", ":=", "cmd", ".", "Cm...
// Run the app server inline. Never returns.
[ "Run", "the", "app", "server", "inline", ".", "Never", "returns", "." ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/app.go#L94-L99
18,031
revel/cmd
harness/app.go
Kill
func (cmd AppCmd) Kill() { if cmd.Cmd != nil && (cmd.ProcessState == nil || !cmd.ProcessState.Exited()) { // Windows appears to send the kill to all threads, shutting down the // server before this can, this check will ensure the process is still running if _, err := os.FindProcess(int(cmd.Process.Pid));err!=ni...
go
func (cmd AppCmd) Kill() { if cmd.Cmd != nil && (cmd.ProcessState == nil || !cmd.ProcessState.Exited()) { // Windows appears to send the kill to all threads, shutting down the // server before this can, this check will ensure the process is still running if _, err := os.FindProcess(int(cmd.Process.Pid));err!=ni...
[ "func", "(", "cmd", "AppCmd", ")", "Kill", "(", ")", "{", "if", "cmd", ".", "Cmd", "!=", "nil", "&&", "(", "cmd", ".", "ProcessState", "==", "nil", "||", "!", "cmd", ".", "ProcessState", ".", "Exited", "(", ")", ")", "{", "// Windows appears to send ...
// Kill terminates the app server if it's running.
[ "Kill", "terminates", "the", "app", "server", "if", "it", "s", "running", "." ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/app.go#L102-L161
18,032
revel/cmd
harness/app.go
Write
func (w *startupListeningWriter) Write(p []byte) (int, error) { if w.notifyReady != nil && bytes.Contains(p, []byte("Revel engine is listening on")) { w.notifyReady <- true w.notifyReady = nil } if w.c.HistoricMode { if w.notifyReady != nil && bytes.Contains(p, []byte("Listening on")) { w.notifyReady <- tru...
go
func (w *startupListeningWriter) Write(p []byte) (int, error) { if w.notifyReady != nil && bytes.Contains(p, []byte("Revel engine is listening on")) { w.notifyReady <- true w.notifyReady = nil } if w.c.HistoricMode { if w.notifyReady != nil && bytes.Contains(p, []byte("Listening on")) { w.notifyReady <- tru...
[ "func", "(", "w", "*", "startupListeningWriter", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "w", ".", "notifyReady", "!=", "nil", "&&", "bytes", ".", "Contains", "(", "p", ",", "[", "]", "byte", "(", ...
// Writes to this output stream
[ "Writes", "to", "this", "output", "stream" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/app.go#L190-L205
18,033
revel/cmd
watcher/watcher.go
NewWatcher
func NewWatcher(paths *model.RevelContainer, eagerRefresh bool) *Watcher { return &Watcher{ forceRefresh: true, lastError: -1, paths: paths, refreshTimerMS: time.Duration(paths.Config.IntDefault("watch.rebuild.delay", 10)), eagerRefresh: eagerRefresh || paths.DevMode && paths.Config.Bo...
go
func NewWatcher(paths *model.RevelContainer, eagerRefresh bool) *Watcher { return &Watcher{ forceRefresh: true, lastError: -1, paths: paths, refreshTimerMS: time.Duration(paths.Config.IntDefault("watch.rebuild.delay", 10)), eagerRefresh: eagerRefresh || paths.DevMode && paths.Config.Bo...
[ "func", "NewWatcher", "(", "paths", "*", "model", ".", "RevelContainer", ",", "eagerRefresh", "bool", ")", "*", "Watcher", "{", "return", "&", "Watcher", "{", "forceRefresh", ":", "true", ",", "lastError", ":", "-", "1", ",", "paths", ":", "paths", ",", ...
// Creates a new watched based on the container
[ "Creates", "a", "new", "watched", "based", "on", "the", "container" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/watcher/watcher.go#L53-L67
18,034
revel/cmd
watcher/watcher.go
NotifyWhenUpdated
func (w *Watcher) NotifyWhenUpdated(listener Listener, watcher *fsnotify.Watcher) { for { select { case ev := <-watcher.Events: if w.rebuildRequired(ev, listener) { if w.serial { // Serialize listener.Refresh() calls. w.notifyMutex.Lock() if err := listener.Refresh(); err != nil { uti...
go
func (w *Watcher) NotifyWhenUpdated(listener Listener, watcher *fsnotify.Watcher) { for { select { case ev := <-watcher.Events: if w.rebuildRequired(ev, listener) { if w.serial { // Serialize listener.Refresh() calls. w.notifyMutex.Lock() if err := listener.Refresh(); err != nil { uti...
[ "func", "(", "w", "*", "Watcher", ")", "NotifyWhenUpdated", "(", "listener", "Listener", ",", "watcher", "*", "fsnotify", ".", "Watcher", ")", "{", "for", "{", "select", "{", "case", "ev", ":=", "<-", "watcher", ".", "Events", ":", "if", "w", ".", "r...
// NotifyWhenUpdated notifies the watcher when a file event is received.
[ "NotifyWhenUpdated", "notifies", "the", "watcher", "when", "a", "file", "event", "is", "received", "." ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/watcher/watcher.go#L152-L177
18,035
revel/cmd
watcher/watcher.go
notifyInProcess
func (w *Watcher) notifyInProcess(listener Listener) (err *utils.Error) { shouldReturn := false // This code block ensures that either a timer is created // or that a process would be added the the h.refreshChannel func() { w.timerMutex.Lock() defer w.timerMutex.Unlock() // If we are in the process of a rebui...
go
func (w *Watcher) notifyInProcess(listener Listener) (err *utils.Error) { shouldReturn := false // This code block ensures that either a timer is created // or that a process would be added the the h.refreshChannel func() { w.timerMutex.Lock() defer w.timerMutex.Unlock() // If we are in the process of a rebui...
[ "func", "(", "w", "*", "Watcher", ")", "notifyInProcess", "(", "listener", "Listener", ")", "(", "err", "*", "utils", ".", "Error", ")", "{", "shouldReturn", ":=", "false", "\n", "// This code block ensures that either a timer is created", "// or that a process would ...
// Build a queue for refresh notifications // this will not return until one of the queue completes
[ "Build", "a", "queue", "for", "refresh", "notifications", "this", "will", "not", "return", "until", "one", "of", "the", "queue", "completes" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/watcher/watcher.go#L232-L279
18,036
revel/cmd
revel/clean.go
updateCleanConfig
func updateCleanConfig(c *model.CommandConfig, args []string) bool { c.Index = model.CLEAN if len(args) == 0 { fmt.Fprintf(os.Stderr, cmdClean.Long) return false } c.Clean.ImportPath = args[0] return true }
go
func updateCleanConfig(c *model.CommandConfig, args []string) bool { c.Index = model.CLEAN if len(args) == 0 { fmt.Fprintf(os.Stderr, cmdClean.Long) return false } c.Clean.ImportPath = args[0] return true }
[ "func", "updateCleanConfig", "(", "c", "*", "model", ".", "CommandConfig", ",", "args", "[", "]", "string", ")", "bool", "{", "c", ".", "Index", "=", "model", ".", "CLEAN", "\n", "if", "len", "(", "args", ")", "==", "0", "{", "fmt", ".", "Fprintf",...
// Update the clean command configuration, using old method
[ "Update", "the", "clean", "command", "configuration", "using", "old", "method" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/clean.go#L38-L46
18,037
revel/cmd
revel/clean.go
cleanApp
func cleanApp(c *model.CommandConfig) (err error) { appPkg, err := build.Import(c.ImportPath, "", build.FindOnly) if err != nil { utils.Logger.Fatal("Abort: Failed to find import path:", "error", err) } purgeDirs := []string{ filepath.Join(appPkg.Dir, "app", "tmp"), filepath.Join(appPkg.Dir, "app", "routes")...
go
func cleanApp(c *model.CommandConfig) (err error) { appPkg, err := build.Import(c.ImportPath, "", build.FindOnly) if err != nil { utils.Logger.Fatal("Abort: Failed to find import path:", "error", err) } purgeDirs := []string{ filepath.Join(appPkg.Dir, "app", "tmp"), filepath.Join(appPkg.Dir, "app", "routes")...
[ "func", "cleanApp", "(", "c", "*", "model", ".", "CommandConfig", ")", "(", "err", "error", ")", "{", "appPkg", ",", "err", ":=", "build", ".", "Import", "(", "c", ".", "ImportPath", ",", "\"", "\"", ",", "build", ".", "FindOnly", ")", "\n", "if", ...
// Clean the source directory of generated files
[ "Clean", "the", "source", "directory", "of", "generated", "files" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/clean.go#L49-L69
18,038
revel/cmd
revel/new.go
generateSecret
func generateSecret() string { chars := make([]byte, 64) for i := 0; i < 64; i++ { chars[i] = alphaNumeric[rand.Intn(len(alphaNumeric))] } return string(chars) }
go
func generateSecret() string { chars := make([]byte, 64) for i := 0; i < 64; i++ { chars[i] = alphaNumeric[rand.Intn(len(alphaNumeric))] } return string(chars) }
[ "func", "generateSecret", "(", ")", "string", "{", "chars", ":=", "make", "(", "[", "]", "byte", ",", "64", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "64", ";", "i", "++", "{", "chars", "[", "i", "]", "=", "alphaNumeric", "[", "rand", ...
// Generate a secret key
[ "Generate", "a", "secret", "key" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/new.go#L163-L169
18,039
revel/cmd
revel/new.go
setApplicationPath
func setApplicationPath(c *model.CommandConfig) (err error) { // revel/revel#1014 validate relative path, we cannot use built-in functions // since Go import path is valid relative path too. // so check basic part of the path, which is "." if filepath.IsAbs(c.ImportPath) || strings.HasPrefix(c.ImportPath, ".") { ...
go
func setApplicationPath(c *model.CommandConfig) (err error) { // revel/revel#1014 validate relative path, we cannot use built-in functions // since Go import path is valid relative path too. // so check basic part of the path, which is "." if filepath.IsAbs(c.ImportPath) || strings.HasPrefix(c.ImportPath, ".") { ...
[ "func", "setApplicationPath", "(", "c", "*", "model", ".", "CommandConfig", ")", "(", "err", "error", ")", "{", "// revel/revel#1014 validate relative path, we cannot use built-in functions", "// since Go import path is valid relative path too.", "// so check basic part of the path, ...
// Sets the applicaiton path
[ "Sets", "the", "applicaiton", "path" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/new.go#L172-L197
18,040
revel/cmd
revel/new.go
setSkeletonPath
func setSkeletonPath(c *model.CommandConfig) (err error) { if len(c.New.SkeletonPath) == 0 { c.New.SkeletonPath = "https://" + RevelSkeletonsImportPath + ":basic/bootstrap4" } // First check to see the protocol of the string sp, err := url.Parse(c.New.SkeletonPath) if err == nil { utils.Logger.Info("Detected ...
go
func setSkeletonPath(c *model.CommandConfig) (err error) { if len(c.New.SkeletonPath) == 0 { c.New.SkeletonPath = "https://" + RevelSkeletonsImportPath + ":basic/bootstrap4" } // First check to see the protocol of the string sp, err := url.Parse(c.New.SkeletonPath) if err == nil { utils.Logger.Info("Detected ...
[ "func", "setSkeletonPath", "(", "c", "*", "model", ".", "CommandConfig", ")", "(", "err", "error", ")", "{", "if", "len", "(", "c", ".", "New", ".", "SkeletonPath", ")", "==", "0", "{", "c", ".", "New", ".", "SkeletonPath", "=", "\"", "\"", "+", ...
// Set the skeleton path
[ "Set", "the", "skeleton", "path" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/new.go#L200-L245
18,041
revel/cmd
revel/new.go
newLoadFromGit
func newLoadFromGit(c *model.CommandConfig, sp *url.URL) (err error) { // This method indicates we need to fetch from a repository using git // Execute "git clone get <pkg>" targetPath := filepath.Join(os.TempDir(), "revel", "skeleton") os.RemoveAll(targetPath) pathpart := strings.Split(sp.Path, ":") getCmd := ex...
go
func newLoadFromGit(c *model.CommandConfig, sp *url.URL) (err error) { // This method indicates we need to fetch from a repository using git // Execute "git clone get <pkg>" targetPath := filepath.Join(os.TempDir(), "revel", "skeleton") os.RemoveAll(targetPath) pathpart := strings.Split(sp.Path, ":") getCmd := ex...
[ "func", "newLoadFromGit", "(", "c", "*", "model", ".", "CommandConfig", ",", "sp", "*", "url", ".", "URL", ")", "(", "err", "error", ")", "{", "// This method indicates we need to fetch from a repository using git", "// Execute \"git clone get <pkg>\"", "targetPath", ":...
// Load skeleton from git
[ "Load", "skeleton", "from", "git" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/new.go#L248-L271
18,042
revel/cmd
utils/log.go
Retry
func Retry(format string, args ...interface{}) { // Ensure the user's command prompt starts on the next line. if !strings.HasSuffix(format, "\n") { format += "\n" } fmt.Fprintf(os.Stderr, format, args...) panic(format) // Panic instead of os.Exit so that deferred will run. }
go
func Retry(format string, args ...interface{}) { // Ensure the user's command prompt starts on the next line. if !strings.HasSuffix(format, "\n") { format += "\n" } fmt.Fprintf(os.Stderr, format, args...) panic(format) // Panic instead of os.Exit so that deferred will run. }
[ "func", "Retry", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "// Ensure the user's command prompt starts on the next line.", "if", "!", "strings", ".", "HasSuffix", "(", "format", ",", "\"", "\\n", "\"", ")", "{", "format", "+...
// This function is to throw a panic that may be caught by the packger so it can perform the needed // imports
[ "This", "function", "is", "to", "throw", "a", "panic", "that", "may", "be", "caught", "by", "the", "packger", "so", "it", "can", "perform", "the", "needed", "imports" ]
149f9f992be9b0957fb1ffeda43c14a123ceb43a
https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/utils/log.go#L35-L42
18,043
segmentio/analytics-go
analytics.go
New
func New(key string) *Client { c := &Client{ Endpoint: Endpoint, Interval: 5 * time.Second, Size: 250, Logger: log.New(os.Stderr, "segment ", log.LstdFlags), Verbose: false, Client: *http.DefaultClient, key: key, msgs: make(chan interface{}, 100), quit: make(chan struct{}), sh...
go
func New(key string) *Client { c := &Client{ Endpoint: Endpoint, Interval: 5 * time.Second, Size: 250, Logger: log.New(os.Stderr, "segment ", log.LstdFlags), Verbose: false, Client: *http.DefaultClient, key: key, msgs: make(chan interface{}, 100), quit: make(chan struct{}), sh...
[ "func", "New", "(", "key", "string", ")", "*", "Client", "{", "c", ":=", "&", "Client", "{", "Endpoint", ":", "Endpoint", ",", "Interval", ":", "5", "*", "time", ".", "Second", ",", "Size", ":", "250", ",", "Logger", ":", "log", ".", "New", "(", ...
// New client with write key.
[ "New", "client", "with", "write", "key", "." ]
8999d38db33a06d54813976725d47e18b4e3191c
https://github.com/segmentio/analytics-go/blob/8999d38db33a06d54813976725d47e18b4e3191c/analytics.go#L139-L159
18,044
segmentio/analytics-go
analytics.go
Alias
func (c *Client) Alias(msg *Alias) error { if msg.UserId == "" { return errors.New("You must pass a 'userId'.") } if msg.PreviousId == "" { return errors.New("You must pass a 'previousId'.") } msg.Type = "alias" c.queue(msg) return nil }
go
func (c *Client) Alias(msg *Alias) error { if msg.UserId == "" { return errors.New("You must pass a 'userId'.") } if msg.PreviousId == "" { return errors.New("You must pass a 'previousId'.") } msg.Type = "alias" c.queue(msg) return nil }
[ "func", "(", "c", "*", "Client", ")", "Alias", "(", "msg", "*", "Alias", ")", "error", "{", "if", "msg", ".", "UserId", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "msg", ".", "PreviousI...
// Alias buffers an "alias" message.
[ "Alias", "buffers", "an", "alias", "message", "." ]
8999d38db33a06d54813976725d47e18b4e3191c
https://github.com/segmentio/analytics-go/blob/8999d38db33a06d54813976725d47e18b4e3191c/analytics.go#L162-L175
18,045
segmentio/analytics-go
analytics.go
Page
func (c *Client) Page(msg *Page) error { if msg.UserId == "" && msg.AnonymousId == "" { return errors.New("You must pass either an 'anonymousId' or 'userId'.") } msg.Type = "page" c.queue(msg) return nil }
go
func (c *Client) Page(msg *Page) error { if msg.UserId == "" && msg.AnonymousId == "" { return errors.New("You must pass either an 'anonymousId' or 'userId'.") } msg.Type = "page" c.queue(msg) return nil }
[ "func", "(", "c", "*", "Client", ")", "Page", "(", "msg", "*", "Page", ")", "error", "{", "if", "msg", ".", "UserId", "==", "\"", "\"", "&&", "msg", ".", "AnonymousId", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")"...
// Page buffers an "page" message.
[ "Page", "buffers", "an", "page", "message", "." ]
8999d38db33a06d54813976725d47e18b4e3191c
https://github.com/segmentio/analytics-go/blob/8999d38db33a06d54813976725d47e18b4e3191c/analytics.go#L178-L187
18,046
segmentio/analytics-go
analytics.go
Group
func (c *Client) Group(msg *Group) error { if msg.GroupId == "" { return errors.New("You must pass a 'groupId'.") } if msg.UserId == "" && msg.AnonymousId == "" { return errors.New("You must pass either an 'anonymousId' or 'userId'.") } msg.Type = "group" c.queue(msg) return nil }
go
func (c *Client) Group(msg *Group) error { if msg.GroupId == "" { return errors.New("You must pass a 'groupId'.") } if msg.UserId == "" && msg.AnonymousId == "" { return errors.New("You must pass either an 'anonymousId' or 'userId'.") } msg.Type = "group" c.queue(msg) return nil }
[ "func", "(", "c", "*", "Client", ")", "Group", "(", "msg", "*", "Group", ")", "error", "{", "if", "msg", ".", "GroupId", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "msg", ".", "UserId",...
// Group buffers an "group" message.
[ "Group", "buffers", "an", "group", "message", "." ]
8999d38db33a06d54813976725d47e18b4e3191c
https://github.com/segmentio/analytics-go/blob/8999d38db33a06d54813976725d47e18b4e3191c/analytics.go#L190-L203
18,047
segmentio/analytics-go
analytics.go
Track
func (c *Client) Track(msg *Track) error { if msg.Event == "" { return errors.New("You must pass 'event'.") } if msg.UserId == "" && msg.AnonymousId == "" { return errors.New("You must pass either an 'anonymousId' or 'userId'.") } msg.Type = "track" c.queue(msg) return nil }
go
func (c *Client) Track(msg *Track) error { if msg.Event == "" { return errors.New("You must pass 'event'.") } if msg.UserId == "" && msg.AnonymousId == "" { return errors.New("You must pass either an 'anonymousId' or 'userId'.") } msg.Type = "track" c.queue(msg) return nil }
[ "func", "(", "c", "*", "Client", ")", "Track", "(", "msg", "*", "Track", ")", "error", "{", "if", "msg", ".", "Event", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "msg", ".", "UserId", ...
// Track buffers an "track" message.
[ "Track", "buffers", "an", "track", "message", "." ]
8999d38db33a06d54813976725d47e18b4e3191c
https://github.com/segmentio/analytics-go/blob/8999d38db33a06d54813976725d47e18b4e3191c/analytics.go#L218-L231
18,048
segmentio/analytics-go
analytics.go
queue
func (c *Client) queue(msg message) { c.once.Do(c.startLoop) msg.setMessageId(c.uid()) msg.setTimestamp(timestamp(c.now())) c.msgs <- msg }
go
func (c *Client) queue(msg message) { c.once.Do(c.startLoop) msg.setMessageId(c.uid()) msg.setTimestamp(timestamp(c.now())) c.msgs <- msg }
[ "func", "(", "c", "*", "Client", ")", "queue", "(", "msg", "message", ")", "{", "c", ".", "once", ".", "Do", "(", "c", ".", "startLoop", ")", "\n", "msg", ".", "setMessageId", "(", "c", ".", "uid", "(", ")", ")", "\n", "msg", ".", "setTimestamp...
// Queue message.
[ "Queue", "message", "." ]
8999d38db33a06d54813976725d47e18b4e3191c
https://github.com/segmentio/analytics-go/blob/8999d38db33a06d54813976725d47e18b4e3191c/analytics.go#L238-L243
18,049
segmentio/analytics-go
analytics.go
Close
func (c *Client) Close() error { c.once.Do(c.startLoop) c.quit <- struct{}{} close(c.msgs) <-c.shutdown return nil }
go
func (c *Client) Close() error { c.once.Do(c.startLoop) c.quit <- struct{}{} close(c.msgs) <-c.shutdown return nil }
[ "func", "(", "c", "*", "Client", ")", "Close", "(", ")", "error", "{", "c", ".", "once", ".", "Do", "(", "c", ".", "startLoop", ")", "\n", "c", ".", "quit", "<-", "struct", "{", "}", "{", "}", "\n", "close", "(", "c", ".", "msgs", ")", "\n"...
// Close and flush metrics.
[ "Close", "and", "flush", "metrics", "." ]
8999d38db33a06d54813976725d47e18b4e3191c
https://github.com/segmentio/analytics-go/blob/8999d38db33a06d54813976725d47e18b4e3191c/analytics.go#L246-L252
18,050
segmentio/analytics-go
analytics.go
send
func (c *Client) send(msgs []interface{}) error { if len(msgs) == 0 { return nil } batch := new(Batch) batch.Messages = msgs batch.MessageId = c.uid() batch.SentAt = timestamp(c.now()) batch.Context = DefaultContext b, err := json.Marshal(batch) if err != nil { return fmt.Errorf("error marshalling msgs: ...
go
func (c *Client) send(msgs []interface{}) error { if len(msgs) == 0 { return nil } batch := new(Batch) batch.Messages = msgs batch.MessageId = c.uid() batch.SentAt = timestamp(c.now()) batch.Context = DefaultContext b, err := json.Marshal(batch) if err != nil { return fmt.Errorf("error marshalling msgs: ...
[ "func", "(", "c", "*", "Client", ")", "send", "(", "msgs", "[", "]", "interface", "{", "}", ")", "error", "{", "if", "len", "(", "msgs", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "batch", ":=", "new", "(", "Batch", ")", "\n", "...
// Send batch request.
[ "Send", "batch", "request", "." ]
8999d38db33a06d54813976725d47e18b4e3191c
https://github.com/segmentio/analytics-go/blob/8999d38db33a06d54813976725d47e18b4e3191c/analytics.go#L276-L300
18,051
segmentio/analytics-go
analytics.go
upload
func (c *Client) upload(b []byte) error { url := c.Endpoint + "/v1/batch" req, err := http.NewRequest("POST", url, bytes.NewReader(b)) if err != nil { return fmt.Errorf("error creating request: %s", err) } req.Header.Add("User-Agent", "analytics-go (version: "+Version+")") req.Header.Add("Content-Type", "appli...
go
func (c *Client) upload(b []byte) error { url := c.Endpoint + "/v1/batch" req, err := http.NewRequest("POST", url, bytes.NewReader(b)) if err != nil { return fmt.Errorf("error creating request: %s", err) } req.Header.Add("User-Agent", "analytics-go (version: "+Version+")") req.Header.Add("Content-Type", "appli...
[ "func", "(", "c", "*", "Client", ")", "upload", "(", "b", "[", "]", "byte", ")", "error", "{", "url", ":=", "c", ".", "Endpoint", "+", "\"", "\"", "\n", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "url", ",", "by...
// Upload serialized batch message.
[ "Upload", "serialized", "batch", "message", "." ]
8999d38db33a06d54813976725d47e18b4e3191c
https://github.com/segmentio/analytics-go/blob/8999d38db33a06d54813976725d47e18b4e3191c/analytics.go#L303-L332
18,052
segmentio/analytics-go
analytics.go
loop
func (c *Client) loop() { var msgs []interface{} tick := time.NewTicker(c.Interval) for { select { case msg := <-c.msgs: c.verbose("buffer (%d/%d) %v", len(msgs), c.Size, msg) msgs = append(msgs, msg) if len(msgs) == c.Size { c.verbose("exceeded %d messages – flushing", c.Size) c.sendAsync(msgs...
go
func (c *Client) loop() { var msgs []interface{} tick := time.NewTicker(c.Interval) for { select { case msg := <-c.msgs: c.verbose("buffer (%d/%d) %v", len(msgs), c.Size, msg) msgs = append(msgs, msg) if len(msgs) == c.Size { c.verbose("exceeded %d messages – flushing", c.Size) c.sendAsync(msgs...
[ "func", "(", "c", "*", "Client", ")", "loop", "(", ")", "{", "var", "msgs", "[", "]", "interface", "{", "}", "\n", "tick", ":=", "time", ".", "NewTicker", "(", "c", ".", "Interval", ")", "\n\n", "for", "{", "select", "{", "case", "msg", ":=", "...
// Batch loop.
[ "Batch", "loop", "." ]
8999d38db33a06d54813976725d47e18b4e3191c
https://github.com/segmentio/analytics-go/blob/8999d38db33a06d54813976725d47e18b4e3191c/analytics.go#L335-L373
18,053
segmentio/analytics-go
analytics.go
verbose
func (c *Client) verbose(msg string, args ...interface{}) { if c.Verbose { c.Logger.Printf(msg, args...) } }
go
func (c *Client) verbose(msg string, args ...interface{}) { if c.Verbose { c.Logger.Printf(msg, args...) } }
[ "func", "(", "c", "*", "Client", ")", "verbose", "(", "msg", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "c", ".", "Verbose", "{", "c", ".", "Logger", ".", "Printf", "(", "msg", ",", "args", "...", ")", "\n", "}", "\n",...
// Verbose log.
[ "Verbose", "log", "." ]
8999d38db33a06d54813976725d47e18b4e3191c
https://github.com/segmentio/analytics-go/blob/8999d38db33a06d54813976725d47e18b4e3191c/analytics.go#L376-L380
18,054
segmentio/analytics-go
analytics.go
logf
func (c *Client) logf(msg string, args ...interface{}) { c.Logger.Printf(msg, args...) }
go
func (c *Client) logf(msg string, args ...interface{}) { c.Logger.Printf(msg, args...) }
[ "func", "(", "c", "*", "Client", ")", "logf", "(", "msg", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "c", ".", "Logger", ".", "Printf", "(", "msg", ",", "args", "...", ")", "\n", "}" ]
// Unconditional log.
[ "Unconditional", "log", "." ]
8999d38db33a06d54813976725d47e18b4e3191c
https://github.com/segmentio/analytics-go/blob/8999d38db33a06d54813976725d47e18b4e3191c/analytics.go#L383-L385
18,055
segmentio/analytics-go
analytics.go
setTimestamp
func (m *Message) setTimestamp(s string) { if m.Timestamp == "" { m.Timestamp = s } }
go
func (m *Message) setTimestamp(s string) { if m.Timestamp == "" { m.Timestamp = s } }
[ "func", "(", "m", "*", "Message", ")", "setTimestamp", "(", "s", "string", ")", "{", "if", "m", ".", "Timestamp", "==", "\"", "\"", "{", "m", ".", "Timestamp", "=", "s", "\n", "}", "\n", "}" ]
// Set message timestamp if one is not already set.
[ "Set", "message", "timestamp", "if", "one", "is", "not", "already", "set", "." ]
8999d38db33a06d54813976725d47e18b4e3191c
https://github.com/segmentio/analytics-go/blob/8999d38db33a06d54813976725d47e18b4e3191c/analytics.go#L388-L392
18,056
segmentio/analytics-go
analytics.go
setMessageId
func (m *Message) setMessageId(s string) { if m.MessageId == "" { m.MessageId = s } }
go
func (m *Message) setMessageId(s string) { if m.MessageId == "" { m.MessageId = s } }
[ "func", "(", "m", "*", "Message", ")", "setMessageId", "(", "s", "string", ")", "{", "if", "m", ".", "MessageId", "==", "\"", "\"", "{", "m", ".", "MessageId", "=", "s", "\n", "}", "\n", "}" ]
// Set message id.
[ "Set", "message", "id", "." ]
8999d38db33a06d54813976725d47e18b4e3191c
https://github.com/segmentio/analytics-go/blob/8999d38db33a06d54813976725d47e18b4e3191c/analytics.go#L395-L399
18,057
qor/i18n
backends/database/database.go
New
func New(db *gorm.DB) i18n.Backend { db.AutoMigrate(&Translation{}) if err := db.Model(&Translation{}).AddUniqueIndex("idx_translations_key_with_locale", "locale", "key").Error; err != nil { fmt.Printf("Failed to create unique index for translations key & locale, got: %v\n", err.Error()) } return &Backend{DB: db}...
go
func New(db *gorm.DB) i18n.Backend { db.AutoMigrate(&Translation{}) if err := db.Model(&Translation{}).AddUniqueIndex("idx_translations_key_with_locale", "locale", "key").Error; err != nil { fmt.Printf("Failed to create unique index for translations key & locale, got: %v\n", err.Error()) } return &Backend{DB: db}...
[ "func", "New", "(", "db", "*", "gorm", ".", "DB", ")", "i18n", ".", "Backend", "{", "db", ".", "AutoMigrate", "(", "&", "Translation", "{", "}", ")", "\n", "if", "err", ":=", "db", ".", "Model", "(", "&", "Translation", "{", "}", ")", ".", "Add...
// New new DB backend for I18n
[ "New", "new", "DB", "backend", "for", "I18n" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/backends/database/database.go#L18-L24
18,058
qor/i18n
backends/database/database.go
LoadTranslations
func (backend *Backend) LoadTranslations() (translations []*i18n.Translation) { backend.DB.Find(&translations) return translations }
go
func (backend *Backend) LoadTranslations() (translations []*i18n.Translation) { backend.DB.Find(&translations) return translations }
[ "func", "(", "backend", "*", "Backend", ")", "LoadTranslations", "(", ")", "(", "translations", "[", "]", "*", "i18n", ".", "Translation", ")", "{", "backend", ".", "DB", ".", "Find", "(", "&", "translations", ")", "\n", "return", "translations", "\n", ...
// LoadTranslations load translations from DB backend
[ "LoadTranslations", "load", "translations", "from", "DB", "backend" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/backends/database/database.go#L32-L35
18,059
qor/i18n
backends/database/database.go
SaveTranslation
func (backend *Backend) SaveTranslation(t *i18n.Translation) error { return backend.DB.Where(Translation{Key: t.Key, Locale: t.Locale}). Assign(Translation{Value: t.Value}). FirstOrCreate(&Translation{}).Error }
go
func (backend *Backend) SaveTranslation(t *i18n.Translation) error { return backend.DB.Where(Translation{Key: t.Key, Locale: t.Locale}). Assign(Translation{Value: t.Value}). FirstOrCreate(&Translation{}).Error }
[ "func", "(", "backend", "*", "Backend", ")", "SaveTranslation", "(", "t", "*", "i18n", ".", "Translation", ")", "error", "{", "return", "backend", ".", "DB", ".", "Where", "(", "Translation", "{", "Key", ":", "t", ".", "Key", ",", "Locale", ":", "t",...
// SaveTranslation save translation into DB backend
[ "SaveTranslation", "save", "translation", "into", "DB", "backend" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/backends/database/database.go#L38-L42
18,060
qor/i18n
backends/database/database.go
DeleteTranslation
func (backend *Backend) DeleteTranslation(t *i18n.Translation) error { return backend.DB.Where(Translation{Key: t.Key, Locale: t.Locale}).Delete(&Translation{}).Error }
go
func (backend *Backend) DeleteTranslation(t *i18n.Translation) error { return backend.DB.Where(Translation{Key: t.Key, Locale: t.Locale}).Delete(&Translation{}).Error }
[ "func", "(", "backend", "*", "Backend", ")", "DeleteTranslation", "(", "t", "*", "i18n", ".", "Translation", ")", "error", "{", "return", "backend", ".", "DB", ".", "Where", "(", "Translation", "{", "Key", ":", "t", ".", "Key", ",", "Locale", ":", "t...
// DeleteTranslation delete translation into DB backend
[ "DeleteTranslation", "delete", "translation", "into", "DB", "backend" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/backends/database/database.go#L45-L47
18,061
qor/i18n
backends/yaml/yaml.go
New
func New(paths ...string) *Backend { backend := &Backend{} var files []string for _, p := range paths { if file, err := os.Open(p); err == nil { defer file.Close() if fileInfo, err := file.Stat(); err == nil { if fileInfo.IsDir() { yamlFiles, _ := filepath.Glob(filepath.Join(p, "*.yaml")) file...
go
func New(paths ...string) *Backend { backend := &Backend{} var files []string for _, p := range paths { if file, err := os.Open(p); err == nil { defer file.Close() if fileInfo, err := file.Stat(); err == nil { if fileInfo.IsDir() { yamlFiles, _ := filepath.Glob(filepath.Join(p, "*.yaml")) file...
[ "func", "New", "(", "paths", "...", "string", ")", "*", "Backend", "{", "backend", ":=", "&", "Backend", "{", "}", "\n\n", "var", "files", "[", "]", "string", "\n", "for", "_", ",", "p", ":=", "range", "paths", "{", "if", "file", ",", "err", ":="...
// New new YAML backend for I18n
[ "New", "new", "YAML", "backend", "for", "I18n" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/backends/yaml/yaml.go#L19-L45
18,062
qor/i18n
backends/yaml/yaml.go
NewWithWalk
func NewWithWalk(paths ...string) i18n.Backend { backend := &Backend{} var files []string for _, p := range paths { filepath.Walk(p, func(path string, fileInfo os.FileInfo, err error) error { if isYamlFile(fileInfo) { files = append(files, path) } return nil }) } for _, file := range files { if...
go
func NewWithWalk(paths ...string) i18n.Backend { backend := &Backend{} var files []string for _, p := range paths { filepath.Walk(p, func(path string, fileInfo os.FileInfo, err error) error { if isYamlFile(fileInfo) { files = append(files, path) } return nil }) } for _, file := range files { if...
[ "func", "NewWithWalk", "(", "paths", "...", "string", ")", "i18n", ".", "Backend", "{", "backend", ":=", "&", "Backend", "{", "}", "\n\n", "var", "files", "[", "]", "string", "\n", "for", "_", ",", "p", ":=", "range", "paths", "{", "filepath", ".", ...
// NewWithWalk has the same functionality as New but uses filepath.Walk to find all the translation files recursively.
[ "NewWithWalk", "has", "the", "same", "functionality", "as", "New", "but", "uses", "filepath", ".", "Walk", "to", "find", "all", "the", "translation", "files", "recursively", "." ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/backends/yaml/yaml.go#L48-L67
18,063
qor/i18n
backends/yaml/yaml.go
NewWithFilesystem
func NewWithFilesystem(fss ...http.FileSystem) i18n.Backend { backend := &Backend{} for _, fs := range fss { backend.contents = append(backend.contents, walkFilesystem(fs, nil, "/")...) } return backend }
go
func NewWithFilesystem(fss ...http.FileSystem) i18n.Backend { backend := &Backend{} for _, fs := range fss { backend.contents = append(backend.contents, walkFilesystem(fs, nil, "/")...) } return backend }
[ "func", "NewWithFilesystem", "(", "fss", "...", "http", ".", "FileSystem", ")", "i18n", ".", "Backend", "{", "backend", ":=", "&", "Backend", "{", "}", "\n\n", "for", "_", ",", "fs", ":=", "range", "fss", "{", "backend", ".", "contents", "=", "append",...
// NewWithFilesystem initializes a backend that reads translation files from an http.FileSystem.
[ "NewWithFilesystem", "initializes", "a", "backend", "that", "reads", "translation", "files", "from", "an", "http", ".", "FileSystem", "." ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/backends/yaml/yaml.go#L114-L121
18,064
qor/i18n
backends/yaml/yaml.go
LoadYAMLContent
func (backend *Backend) LoadYAMLContent(content []byte) (translations []*i18n.Translation, err error) { var slice yaml.MapSlice if err = yaml.Unmarshal(content, &slice); err == nil { for _, item := range slice { translations = append(translations, loadTranslationsFromYaml(item.Key.(string) /* locale */, item.Va...
go
func (backend *Backend) LoadYAMLContent(content []byte) (translations []*i18n.Translation, err error) { var slice yaml.MapSlice if err = yaml.Unmarshal(content, &slice); err == nil { for _, item := range slice { translations = append(translations, loadTranslationsFromYaml(item.Key.(string) /* locale */, item.Va...
[ "func", "(", "backend", "*", "Backend", ")", "LoadYAMLContent", "(", "content", "[", "]", "byte", ")", "(", "translations", "[", "]", "*", "i18n", ".", "Translation", ",", "err", "error", ")", "{", "var", "slice", "yaml", ".", "MapSlice", "\n\n", "if",...
// LoadYAMLContent load YAML content
[ "LoadYAMLContent", "load", "YAML", "content" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/backends/yaml/yaml.go#L147-L157
18,065
qor/i18n
backends/yaml/yaml.go
LoadTranslations
func (backend *Backend) LoadTranslations() (translations []*i18n.Translation) { for _, content := range backend.contents { if results, err := backend.LoadYAMLContent(content); err == nil { translations = append(translations, results...) } else { panic(err) } } return translations }
go
func (backend *Backend) LoadTranslations() (translations []*i18n.Translation) { for _, content := range backend.contents { if results, err := backend.LoadYAMLContent(content); err == nil { translations = append(translations, results...) } else { panic(err) } } return translations }
[ "func", "(", "backend", "*", "Backend", ")", "LoadTranslations", "(", ")", "(", "translations", "[", "]", "*", "i18n", ".", "Translation", ")", "{", "for", "_", ",", "content", ":=", "range", "backend", ".", "contents", "{", "if", "results", ",", "err"...
// LoadTranslations load translations from YAML backend
[ "LoadTranslations", "load", "translations", "from", "YAML", "backend" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/backends/yaml/yaml.go#L160-L169
18,066
qor/i18n
i18n.go
New
func New(backends ...Backend) *I18n { i18n := &I18n{Backends: backends, cacheStore: memory.New()} i18n.loadToCacheStore() return i18n }
go
func New(backends ...Backend) *I18n { i18n := &I18n{Backends: backends, cacheStore: memory.New()} i18n.loadToCacheStore() return i18n }
[ "func", "New", "(", "backends", "...", "Backend", ")", "*", "I18n", "{", "i18n", ":=", "&", "I18n", "{", "Backends", ":", "backends", ",", "cacheStore", ":", "memory", ".", "New", "(", ")", "}", "\n", "i18n", ".", "loadToCacheStore", "(", ")", "\n", ...
// New initialize I18n with backends
[ "New", "initialize", "I18n", "with", "backends" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/i18n.go#L58-L62
18,067
qor/i18n
i18n.go
SetCacheStore
func (i18n *I18n) SetCacheStore(cacheStore cache.CacheStoreInterface) { i18n.cacheStore = cacheStore i18n.loadToCacheStore() }
go
func (i18n *I18n) SetCacheStore(cacheStore cache.CacheStoreInterface) { i18n.cacheStore = cacheStore i18n.loadToCacheStore() }
[ "func", "(", "i18n", "*", "I18n", ")", "SetCacheStore", "(", "cacheStore", "cache", ".", "CacheStoreInterface", ")", "{", "i18n", ".", "cacheStore", "=", "cacheStore", "\n", "i18n", ".", "loadToCacheStore", "(", ")", "\n", "}" ]
// SetCacheStore set i18n's cache store
[ "SetCacheStore", "set", "i18n", "s", "cache", "store" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/i18n.go#L65-L68
18,068
qor/i18n
i18n.go
AddTranslation
func (i18n *I18n) AddTranslation(translation *Translation) error { return i18n.cacheStore.Set(cacheKey(translation.Locale, translation.Key), translation) }
go
func (i18n *I18n) AddTranslation(translation *Translation) error { return i18n.cacheStore.Set(cacheKey(translation.Locale, translation.Key), translation) }
[ "func", "(", "i18n", "*", "I18n", ")", "AddTranslation", "(", "translation", "*", "Translation", ")", "error", "{", "return", "i18n", ".", "cacheStore", ".", "Set", "(", "cacheKey", "(", "translation", ".", "Locale", ",", "translation", ".", "Key", ")", ...
// AddTranslation add translation
[ "AddTranslation", "add", "translation" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/i18n.go#L97-L99
18,069
qor/i18n
i18n.go
SaveTranslation
func (i18n *I18n) SaveTranslation(translation *Translation) error { for _, backend := range i18n.Backends { if backend.SaveTranslation(translation) == nil { i18n.AddTranslation(translation) return nil } } return errors.New("failed to save translation") }
go
func (i18n *I18n) SaveTranslation(translation *Translation) error { for _, backend := range i18n.Backends { if backend.SaveTranslation(translation) == nil { i18n.AddTranslation(translation) return nil } } return errors.New("failed to save translation") }
[ "func", "(", "i18n", "*", "I18n", ")", "SaveTranslation", "(", "translation", "*", "Translation", ")", "error", "{", "for", "_", ",", "backend", ":=", "range", "i18n", ".", "Backends", "{", "if", "backend", ".", "SaveTranslation", "(", "translation", ")", ...
// SaveTranslation save translation
[ "SaveTranslation", "save", "translation" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/i18n.go#L102-L111
18,070
qor/i18n
i18n.go
DeleteTranslation
func (i18n *I18n) DeleteTranslation(translation *Translation) (err error) { for _, backend := range i18n.Backends { backend.DeleteTranslation(translation) } return i18n.cacheStore.Delete(cacheKey(translation.Locale, translation.Key)) }
go
func (i18n *I18n) DeleteTranslation(translation *Translation) (err error) { for _, backend := range i18n.Backends { backend.DeleteTranslation(translation) } return i18n.cacheStore.Delete(cacheKey(translation.Locale, translation.Key)) }
[ "func", "(", "i18n", "*", "I18n", ")", "DeleteTranslation", "(", "translation", "*", "Translation", ")", "(", "err", "error", ")", "{", "for", "_", ",", "backend", ":=", "range", "i18n", ".", "Backends", "{", "backend", ".", "DeleteTranslation", "(", "tr...
// DeleteTranslation delete translation
[ "DeleteTranslation", "delete", "translation" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/i18n.go#L114-L120
18,071
qor/i18n
i18n.go
Scope
func (i18n *I18n) Scope(scope string) admin.I18n { return &I18n{cacheStore: i18n.cacheStore, scope: scope, value: i18n.value, Backends: i18n.Backends, Resource: i18n.Resource, FallbackLocales: i18n.FallbackLocales, fallbackLocales: i18n.fallbackLocales} }
go
func (i18n *I18n) Scope(scope string) admin.I18n { return &I18n{cacheStore: i18n.cacheStore, scope: scope, value: i18n.value, Backends: i18n.Backends, Resource: i18n.Resource, FallbackLocales: i18n.FallbackLocales, fallbackLocales: i18n.fallbackLocales} }
[ "func", "(", "i18n", "*", "I18n", ")", "Scope", "(", "scope", "string", ")", "admin", ".", "I18n", "{", "return", "&", "I18n", "{", "cacheStore", ":", "i18n", ".", "cacheStore", ",", "scope", ":", "scope", ",", "value", ":", "i18n", ".", "value", "...
// Scope i18n scope
[ "Scope", "i18n", "scope" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/i18n.go#L123-L125
18,072
qor/i18n
i18n.go
Fallbacks
func (i18n *I18n) Fallbacks(locale ...string) admin.I18n { return &I18n{cacheStore: i18n.cacheStore, scope: i18n.scope, value: i18n.value, Backends: i18n.Backends, Resource: i18n.Resource, FallbackLocales: i18n.FallbackLocales, fallbackLocales: locale} }
go
func (i18n *I18n) Fallbacks(locale ...string) admin.I18n { return &I18n{cacheStore: i18n.cacheStore, scope: i18n.scope, value: i18n.value, Backends: i18n.Backends, Resource: i18n.Resource, FallbackLocales: i18n.FallbackLocales, fallbackLocales: locale} }
[ "func", "(", "i18n", "*", "I18n", ")", "Fallbacks", "(", "locale", "...", "string", ")", "admin", ".", "I18n", "{", "return", "&", "I18n", "{", "cacheStore", ":", "i18n", ".", "cacheStore", ",", "scope", ":", "i18n", ".", "scope", ",", "value", ":", ...
// Fallbacks fallback to locale if translation doesn't exist in specified locale
[ "Fallbacks", "fallback", "to", "locale", "if", "translation", "doesn", "t", "exist", "in", "specified", "locale" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/i18n.go#L133-L135
18,073
qor/i18n
i18n.go
T
func (i18n *I18n) T(locale, key string, args ...interface{}) template.HTML { var ( value = i18n.value translationKey = key fallbackLocales = i18n.fallbackLocales ) if locale == "" { locale = Default } if locales, ok := i18n.FallbackLocales[locale]; ok { fallbackLocales = append(fallbackLocal...
go
func (i18n *I18n) T(locale, key string, args ...interface{}) template.HTML { var ( value = i18n.value translationKey = key fallbackLocales = i18n.fallbackLocales ) if locale == "" { locale = Default } if locales, ok := i18n.FallbackLocales[locale]; ok { fallbackLocales = append(fallbackLocal...
[ "func", "(", "i18n", "*", "I18n", ")", "T", "(", "locale", ",", "key", "string", ",", "args", "...", "interface", "{", "}", ")", "template", ".", "HTML", "{", "var", "(", "value", "=", "i18n", ".", "value", "\n", "translationKey", "=", "key", "\n",...
// T translate with locale, key and arguments
[ "T", "translate", "with", "locale", "key", "and", "arguments" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/i18n.go#L138-L193
18,074
qor/i18n
inline_edit/inline_edit.go
FuncMap
func FuncMap(I18n *i18n.I18n, locale string, enableInlineEdit bool) template.FuncMap { return template.FuncMap{ "t": InlineEdit(I18n, locale, enableInlineEdit), } }
go
func FuncMap(I18n *i18n.I18n, locale string, enableInlineEdit bool) template.FuncMap { return template.FuncMap{ "t": InlineEdit(I18n, locale, enableInlineEdit), } }
[ "func", "FuncMap", "(", "I18n", "*", "i18n", ".", "I18n", ",", "locale", "string", ",", "enableInlineEdit", "bool", ")", "template", ".", "FuncMap", "{", "return", "template", ".", "FuncMap", "{", "\"", "\"", ":", "InlineEdit", "(", "I18n", ",", "locale"...
// FuncMap generate func map for inline edit
[ "FuncMap", "generate", "func", "map", "for", "inline", "edit" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/inline_edit/inline_edit.go#L16-L20
18,075
qor/i18n
inline_edit/inline_edit.go
InlineEdit
func InlineEdit(I18n *i18n.I18n, locale string, isInline bool) func(string, ...interface{}) template.HTML { return func(key string, args ...interface{}) template.HTML { // Get Translation Value var value template.HTML var defaultValue string if len(args) > 0 { if args[0] == nil { defaultValue = key }...
go
func InlineEdit(I18n *i18n.I18n, locale string, isInline bool) func(string, ...interface{}) template.HTML { return func(key string, args ...interface{}) template.HTML { // Get Translation Value var value template.HTML var defaultValue string if len(args) > 0 { if args[0] == nil { defaultValue = key }...
[ "func", "InlineEdit", "(", "I18n", "*", "i18n", ".", "I18n", ",", "locale", "string", ",", "isInline", "bool", ")", "func", "(", "string", ",", "...", "interface", "{", "}", ")", "template", ".", "HTML", "{", "return", "func", "(", "key", "string", "...
// InlineEdit enable inline edit
[ "InlineEdit", "enable", "inline", "edit" ]
f7206d223bcd503538783d387b61ed5720264b7b
https://github.com/qor/i18n/blob/f7206d223bcd503538783d387b61ed5720264b7b/inline_edit/inline_edit.go#L23-L51
18,076
go-audio/audio
pcm_buffer.go
AsFloatBuffer
func (b *PCMBuffer) AsFloatBuffer() *FloatBuffer { newB := &FloatBuffer{} newB.Data = b.AsF64() if b.Format != nil { newB.Format = &Format{ NumChannels: b.Format.NumChannels, SampleRate: b.Format.SampleRate, } } return newB }
go
func (b *PCMBuffer) AsFloatBuffer() *FloatBuffer { newB := &FloatBuffer{} newB.Data = b.AsF64() if b.Format != nil { newB.Format = &Format{ NumChannels: b.Format.NumChannels, SampleRate: b.Format.SampleRate, } } return newB }
[ "func", "(", "b", "*", "PCMBuffer", ")", "AsFloatBuffer", "(", ")", "*", "FloatBuffer", "{", "newB", ":=", "&", "FloatBuffer", "{", "}", "\n", "newB", ".", "Data", "=", "b", ".", "AsF64", "(", ")", "\n", "if", "b", ".", "Format", "!=", "nil", "{"...
// AsFloatBuffer returns a copy of this buffer but with data converted to floats.
[ "AsFloatBuffer", "returns", "a", "copy", "of", "this", "buffer", "but", "with", "data", "converted", "to", "floats", "." ]
7b2a6ca214808c64326280ac13268af853543f0b
https://github.com/go-audio/audio/blob/7b2a6ca214808c64326280ac13268af853543f0b/pcm_buffer.go#L96-L106
18,077
go-audio/audio
pcm_buffer.go
AsIntBuffer
func (b *PCMBuffer) AsIntBuffer() *IntBuffer { newB := &IntBuffer{} newB.Data = b.AsInt() if b.Format != nil { newB.Format = &Format{ NumChannels: b.Format.NumChannels, SampleRate: b.Format.SampleRate, } } return newB }
go
func (b *PCMBuffer) AsIntBuffer() *IntBuffer { newB := &IntBuffer{} newB.Data = b.AsInt() if b.Format != nil { newB.Format = &Format{ NumChannels: b.Format.NumChannels, SampleRate: b.Format.SampleRate, } } return newB }
[ "func", "(", "b", "*", "PCMBuffer", ")", "AsIntBuffer", "(", ")", "*", "IntBuffer", "{", "newB", ":=", "&", "IntBuffer", "{", "}", "\n", "newB", ".", "Data", "=", "b", ".", "AsInt", "(", ")", "\n", "if", "b", ".", "Format", "!=", "nil", "{", "n...
// AsIntBuffer returns a copy of this buffer but with data truncated to Ints.
[ "AsIntBuffer", "returns", "a", "copy", "of", "this", "buffer", "but", "with", "data", "truncated", "to", "Ints", "." ]
7b2a6ca214808c64326280ac13268af853543f0b
https://github.com/go-audio/audio/blob/7b2a6ca214808c64326280ac13268af853543f0b/pcm_buffer.go#L122-L132
18,078
go-audio/audio
pcm_buffer.go
AsI8
func (b *PCMBuffer) AsI8() (out []int8) { if b == nil { return nil } switch b.DataType { case DataTypeI8: return b.I8 case DataTypeI16: out = make([]int8, len(b.I16)) for i := 0; i < len(b.I16); i++ { out[i] = int8(b.I16[i]) } case DataTypeI32: out = make([]int8, len(b.I32)) for i := 0; i < len(b...
go
func (b *PCMBuffer) AsI8() (out []int8) { if b == nil { return nil } switch b.DataType { case DataTypeI8: return b.I8 case DataTypeI16: out = make([]int8, len(b.I16)) for i := 0; i < len(b.I16); i++ { out[i] = int8(b.I16[i]) } case DataTypeI32: out = make([]int8, len(b.I32)) for i := 0; i < len(b...
[ "func", "(", "b", "*", "PCMBuffer", ")", "AsI8", "(", ")", "(", "out", "[", "]", "int8", ")", "{", "if", "b", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "switch", "b", ".", "DataType", "{", "case", "DataTypeI8", ":", "return", "b", "."...
// AsI8 returns the buffer's samples as int8 sample values. // If the buffer isn't in this format, a copy is created and converted. // Note that converting might result in loss of resolution.
[ "AsI8", "returns", "the", "buffer", "s", "samples", "as", "int8", "sample", "values", ".", "If", "the", "buffer", "isn", "t", "in", "this", "format", "a", "copy", "is", "created", "and", "converted", ".", "Note", "that", "converting", "might", "result", ...
7b2a6ca214808c64326280ac13268af853543f0b
https://github.com/go-audio/audio/blob/7b2a6ca214808c64326280ac13268af853543f0b/pcm_buffer.go#L137-L166
18,079
go-audio/audio
pcm_buffer.go
AsF64
func (b *PCMBuffer) AsF64() (out []float64) { if b == nil { return nil } switch b.DataType { case DataTypeI8: bitDepth := b.calculateIntBitDepth() factor := math.Pow(2, 8*float64(bitDepth/8)-1) out = make([]float64, len(b.I8)) for i := 0; i < len(b.I8); i++ { out[i] = float64(int64(b.I8[i])) / factor ...
go
func (b *PCMBuffer) AsF64() (out []float64) { if b == nil { return nil } switch b.DataType { case DataTypeI8: bitDepth := b.calculateIntBitDepth() factor := math.Pow(2, 8*float64(bitDepth/8)-1) out = make([]float64, len(b.I8)) for i := 0; i < len(b.I8); i++ { out[i] = float64(int64(b.I8[i])) / factor ...
[ "func", "(", "b", "*", "PCMBuffer", ")", "AsF64", "(", ")", "(", "out", "[", "]", "float64", ")", "{", "if", "b", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "switch", "b", ".", "DataType", "{", "case", "DataTypeI8", ":", "bitDepth", ":="...
// AsF64 returns the buffer's samples as float64 sample values. // If the buffer isn't in this format, a copy is created and converted. // Note that converting might result in unexpected truncations.
[ "AsF64", "returns", "the", "buffer", "s", "samples", "as", "float64", "sample", "values", ".", "If", "the", "buffer", "isn", "t", "in", "this", "format", "a", "copy", "is", "created", "and", "converted", ".", "Note", "that", "converting", "might", "result"...
7b2a6ca214808c64326280ac13268af853543f0b
https://github.com/go-audio/audio/blob/7b2a6ca214808c64326280ac13268af853543f0b/pcm_buffer.go#L291-L326
18,080
go-audio/audio
pcm_buffer.go
calculateIntBitDepth
func (b *PCMBuffer) calculateIntBitDepth() uint8 { if b == nil { return 0 } bitDepth := b.SourceBitDepth if bitDepth != 0 { return bitDepth } var max int64 switch b.DataType { case DataTypeI8: var i8max int8 for _, s := range b.I8 { if s > i8max { i8max = s } } max = int64(i8max) case Dat...
go
func (b *PCMBuffer) calculateIntBitDepth() uint8 { if b == nil { return 0 } bitDepth := b.SourceBitDepth if bitDepth != 0 { return bitDepth } var max int64 switch b.DataType { case DataTypeI8: var i8max int8 for _, s := range b.I8 { if s > i8max { i8max = s } } max = int64(i8max) case Dat...
[ "func", "(", "b", "*", "PCMBuffer", ")", "calculateIntBitDepth", "(", ")", "uint8", "{", "if", "b", "==", "nil", "{", "return", "0", "\n", "}", "\n", "bitDepth", ":=", "b", ".", "SourceBitDepth", "\n", "if", "bitDepth", "!=", "0", "{", "return", "bit...
// calculateIntBithDepth looks at the int values in the buffer and returns // the required lowest bit depth.
[ "calculateIntBithDepth", "looks", "at", "the", "int", "values", "in", "the", "buffer", "and", "returns", "the", "required", "lowest", "bit", "depth", "." ]
7b2a6ca214808c64326280ac13268af853543f0b
https://github.com/go-audio/audio/blob/7b2a6ca214808c64326280ac13268af853543f0b/pcm_buffer.go#L405-L461
18,081
go-audio/audio
int_buffer.go
AsFloat32Buffer
func (buf *IntBuffer) AsFloat32Buffer() *Float32Buffer { newB := &Float32Buffer{} newB.Data = make([]float32, len(buf.Data)) max := int64(0) // try to guess the bit depths without knowing the source if buf.SourceBitDepth == 0 { for _, s := range buf.Data { if int64(s) > max { max = int64(s) } } buf...
go
func (buf *IntBuffer) AsFloat32Buffer() *Float32Buffer { newB := &Float32Buffer{} newB.Data = make([]float32, len(buf.Data)) max := int64(0) // try to guess the bit depths without knowing the source if buf.SourceBitDepth == 0 { for _, s := range buf.Data { if int64(s) > max { max = int64(s) } } buf...
[ "func", "(", "buf", "*", "IntBuffer", ")", "AsFloat32Buffer", "(", ")", "*", "Float32Buffer", "{", "newB", ":=", "&", "Float32Buffer", "{", "}", "\n", "newB", ".", "Data", "=", "make", "(", "[", "]", "float32", ",", "len", "(", "buf", ".", "Data", ...
// AsFloat32Buffer returns a copy of this buffer but with data converted to float 32.
[ "AsFloat32Buffer", "returns", "a", "copy", "of", "this", "buffer", "but", "with", "data", "converted", "to", "float", "32", "." ]
7b2a6ca214808c64326280ac13268af853543f0b
https://github.com/go-audio/audio/blob/7b2a6ca214808c64326280ac13268af853543f0b/int_buffer.go#L36-L74
18,082
go-audio/audio
conv.go
IEEEFloatToInt
func IEEEFloatToInt(b [10]byte) int { var i uint32 // Negative number if (b[0] & 0x80) == 1 { return 0 } // Less than 1 if b[0] <= 0x3F { return 1 } // Too big if b[0] > 0x40 { return 67108864 } // Still too big if b[0] == 0x40 && b[1] > 0x1C { return 800000000 } i = (uint32(b[2]) << 23) | (ui...
go
func IEEEFloatToInt(b [10]byte) int { var i uint32 // Negative number if (b[0] & 0x80) == 1 { return 0 } // Less than 1 if b[0] <= 0x3F { return 1 } // Too big if b[0] > 0x40 { return 67108864 } // Still too big if b[0] == 0x40 && b[1] > 0x1C { return 800000000 } i = (uint32(b[2]) << 23) | (ui...
[ "func", "IEEEFloatToInt", "(", "b", "[", "10", "]", "byte", ")", "int", "{", "var", "i", "uint32", "\n", "// Negative number", "if", "(", "b", "[", "0", "]", "&", "0x80", ")", "==", "1", "{", "return", "0", "\n", "}", "\n\n", "// Less than 1", "if"...
// IEEEFloatToInt converts a 10 byte IEEE float into an int.
[ "IEEEFloatToInt", "converts", "a", "10", "byte", "IEEE", "float", "into", "an", "int", "." ]
7b2a6ca214808c64326280ac13268af853543f0b
https://github.com/go-audio/audio/blob/7b2a6ca214808c64326280ac13268af853543f0b/conv.go#L23-L49
18,083
go-audio/audio
conv.go
IntToIEEEFloat
func IntToIEEEFloat(i int) [10]byte { b := [10]byte{} num := float64(i) var sign int var expon int var fMant, fsMant float64 var hiMant, loMant uint if num < 0 { sign = 0x8000 } else { sign = 0 } if num == 0 { expon = 0 hiMant = 0 loMant = 0 } else { fMant, expon = math.Frexp(num) if (expon ...
go
func IntToIEEEFloat(i int) [10]byte { b := [10]byte{} num := float64(i) var sign int var expon int var fMant, fsMant float64 var hiMant, loMant uint if num < 0 { sign = 0x8000 } else { sign = 0 } if num == 0 { expon = 0 hiMant = 0 loMant = 0 } else { fMant, expon = math.Frexp(num) if (expon ...
[ "func", "IntToIEEEFloat", "(", "i", "int", ")", "[", "10", "]", "byte", "{", "b", ":=", "[", "10", "]", "byte", "{", "}", "\n", "num", ":=", "float64", "(", "i", ")", "\n\n", "var", "sign", "int", "\n", "var", "expon", "int", "\n", "var", "fMan...
// IntToIEEEFloat converts an int into a 10 byte IEEE float.
[ "IntToIEEEFloat", "converts", "an", "int", "into", "a", "10", "byte", "IEEE", "float", "." ]
7b2a6ca214808c64326280ac13268af853543f0b
https://github.com/go-audio/audio/blob/7b2a6ca214808c64326280ac13268af853543f0b/conv.go#L52-L105
18,084
go-audio/audio
conv.go
Uint24to32
func Uint24to32(bytes []byte) uint32 { var output uint32 output |= uint32(bytes[2]) << 0 output |= uint32(bytes[1]) << 8 output |= uint32(bytes[0]) << 16 return output }
go
func Uint24to32(bytes []byte) uint32 { var output uint32 output |= uint32(bytes[2]) << 0 output |= uint32(bytes[1]) << 8 output |= uint32(bytes[0]) << 16 return output }
[ "func", "Uint24to32", "(", "bytes", "[", "]", "byte", ")", "uint32", "{", "var", "output", "uint32", "\n", "output", "|=", "uint32", "(", "bytes", "[", "2", "]", ")", "<<", "0", "\n", "output", "|=", "uint32", "(", "bytes", "[", "1", "]", ")", "<...
// Uint24to32 converts a 3 byte uint23 into a uint32 // BigEndian!
[ "Uint24to32", "converts", "a", "3", "byte", "uint23", "into", "a", "uint32", "BigEndian!" ]
7b2a6ca214808c64326280ac13268af853543f0b
https://github.com/go-audio/audio/blob/7b2a6ca214808c64326280ac13268af853543f0b/conv.go#L109-L116
18,085
go-audio/audio
conv.go
Int24BETo32
func Int24BETo32(bytes []byte) int32 { if len(bytes) < 3 { return 0 } ss := int32(0xFF&bytes[0])<<16 | int32(0xFF&bytes[1])<<8 | int32(0xFF&bytes[2]) if (ss & 0x800000) > 0 { ss |= ^0xffffff } return ss }
go
func Int24BETo32(bytes []byte) int32 { if len(bytes) < 3 { return 0 } ss := int32(0xFF&bytes[0])<<16 | int32(0xFF&bytes[1])<<8 | int32(0xFF&bytes[2]) if (ss & 0x800000) > 0 { ss |= ^0xffffff } return ss }
[ "func", "Int24BETo32", "(", "bytes", "[", "]", "byte", ")", "int32", "{", "if", "len", "(", "bytes", ")", "<", "3", "{", "return", "0", "\n", "}", "\n", "ss", ":=", "int32", "(", "0xFF", "&", "bytes", "[", "0", "]", ")", "<<", "16", "|", "int...
// Int24BETo32 converts an int24 value from 3 bytes into an int32 value
[ "Int24BETo32", "converts", "an", "int24", "value", "from", "3", "bytes", "into", "an", "int32", "value" ]
7b2a6ca214808c64326280ac13268af853543f0b
https://github.com/go-audio/audio/blob/7b2a6ca214808c64326280ac13268af853543f0b/conv.go#L119-L129
18,086
go-audio/audio
conv.go
Int24LETo32
func Int24LETo32(bytes []byte) int32 { if len(bytes) < 3 { return 0 } ss := int32(bytes[0]) | int32(bytes[1])<<8 | int32(bytes[2])<<16 if (ss & 0x800000) > 0 { ss |= ^0xffffff } return ss }
go
func Int24LETo32(bytes []byte) int32 { if len(bytes) < 3 { return 0 } ss := int32(bytes[0]) | int32(bytes[1])<<8 | int32(bytes[2])<<16 if (ss & 0x800000) > 0 { ss |= ^0xffffff } return ss }
[ "func", "Int24LETo32", "(", "bytes", "[", "]", "byte", ")", "int32", "{", "if", "len", "(", "bytes", ")", "<", "3", "{", "return", "0", "\n", "}", "\n", "ss", ":=", "int32", "(", "bytes", "[", "0", "]", ")", "|", "int32", "(", "bytes", "[", "...
// Int24LETo32 converts an int24 value from 3 bytes into an int32 value
[ "Int24LETo32", "converts", "an", "int24", "value", "from", "3", "bytes", "into", "an", "int32", "value" ]
7b2a6ca214808c64326280ac13268af853543f0b
https://github.com/go-audio/audio/blob/7b2a6ca214808c64326280ac13268af853543f0b/conv.go#L132-L142
18,087
go-audio/audio
conv.go
Uint32toUint24Bytes
func Uint32toUint24Bytes(n uint32) []byte { bytes := make([]byte, 3) bytes[0] = byte(n >> 16) bytes[1] = byte(n >> 8) bytes[2] = byte(n >> 0) return bytes }
go
func Uint32toUint24Bytes(n uint32) []byte { bytes := make([]byte, 3) bytes[0] = byte(n >> 16) bytes[1] = byte(n >> 8) bytes[2] = byte(n >> 0) return bytes }
[ "func", "Uint32toUint24Bytes", "(", "n", "uint32", ")", "[", "]", "byte", "{", "bytes", ":=", "make", "(", "[", "]", "byte", ",", "3", ")", "\n", "bytes", "[", "0", "]", "=", "byte", "(", "n", ">>", "16", ")", "\n", "bytes", "[", "1", "]", "=...
// Uint32toUint24Bytes converts a uint32 into a 3 byte uint24 representation
[ "Uint32toUint24Bytes", "converts", "a", "uint32", "into", "a", "3", "byte", "uint24", "representation" ]
7b2a6ca214808c64326280ac13268af853543f0b
https://github.com/go-audio/audio/blob/7b2a6ca214808c64326280ac13268af853543f0b/conv.go#L145-L152
18,088
go-audio/audio
conv.go
Int32toInt24LEBytes
func Int32toInt24LEBytes(n int32) []byte { bytes := make([]byte, 3) if (n & 0x800000) > 0 { n |= ^0xffffff } bytes[2] = byte(n >> 16) bytes[1] = byte(n >> 8) bytes[0] = byte(n >> 0) return bytes }
go
func Int32toInt24LEBytes(n int32) []byte { bytes := make([]byte, 3) if (n & 0x800000) > 0 { n |= ^0xffffff } bytes[2] = byte(n >> 16) bytes[1] = byte(n >> 8) bytes[0] = byte(n >> 0) return bytes }
[ "func", "Int32toInt24LEBytes", "(", "n", "int32", ")", "[", "]", "byte", "{", "bytes", ":=", "make", "(", "[", "]", "byte", ",", "3", ")", "\n", "if", "(", "n", "&", "0x800000", ")", ">", "0", "{", "n", "|=", "^", "0xffffff", "\n", "}", "\n", ...
// Int32toInt24LEBytes converts an int32 into a little endian 3 byte int24 representation
[ "Int32toInt24LEBytes", "converts", "an", "int32", "into", "a", "little", "endian", "3", "byte", "int24", "representation" ]
7b2a6ca214808c64326280ac13268af853543f0b
https://github.com/go-audio/audio/blob/7b2a6ca214808c64326280ac13268af853543f0b/conv.go#L155-L164
18,089
go-audio/audio
conv.go
Int32toInt24BEBytes
func Int32toInt24BEBytes(n int32) []byte { bytes := make([]byte, 3) if (n & 0x800000) > 0 { n |= ^0xffffff } bytes[0] = byte(n >> 16) bytes[1] = byte(n >> 8) bytes[2] = byte(n >> 0) return bytes }
go
func Int32toInt24BEBytes(n int32) []byte { bytes := make([]byte, 3) if (n & 0x800000) > 0 { n |= ^0xffffff } bytes[0] = byte(n >> 16) bytes[1] = byte(n >> 8) bytes[2] = byte(n >> 0) return bytes }
[ "func", "Int32toInt24BEBytes", "(", "n", "int32", ")", "[", "]", "byte", "{", "bytes", ":=", "make", "(", "[", "]", "byte", ",", "3", ")", "\n", "if", "(", "n", "&", "0x800000", ")", ">", "0", "{", "n", "|=", "^", "0xffffff", "\n", "}", "\n", ...
// Int32toInt24BEBytes converts an int32 into a big endian 3 byte int24 representation
[ "Int32toInt24BEBytes", "converts", "an", "int32", "into", "a", "big", "endian", "3", "byte", "int24", "representation" ]
7b2a6ca214808c64326280ac13268af853543f0b
https://github.com/go-audio/audio/blob/7b2a6ca214808c64326280ac13268af853543f0b/conv.go#L167-L177
18,090
go-audio/audio
float_buffer.go
AsFloatBuffer
func (buf *Float32Buffer) AsFloatBuffer() *FloatBuffer { newB := &FloatBuffer{} newB.Data = make([]float64, len(buf.Data)) for i := 0; i < len(buf.Data); i++ { newB.Data[i] = float64(buf.Data[i]) } newB.Format = &Format{ NumChannels: buf.Format.NumChannels, SampleRate: buf.Format.SampleRate, } return newB...
go
func (buf *Float32Buffer) AsFloatBuffer() *FloatBuffer { newB := &FloatBuffer{} newB.Data = make([]float64, len(buf.Data)) for i := 0; i < len(buf.Data); i++ { newB.Data[i] = float64(buf.Data[i]) } newB.Format = &Format{ NumChannels: buf.Format.NumChannels, SampleRate: buf.Format.SampleRate, } return newB...
[ "func", "(", "buf", "*", "Float32Buffer", ")", "AsFloatBuffer", "(", ")", "*", "FloatBuffer", "{", "newB", ":=", "&", "FloatBuffer", "{", "}", "\n", "newB", ".", "Data", "=", "make", "(", "[", "]", "float64", ",", "len", "(", "buf", ".", "Data", ")...
// AsFloatBuffer implements the Buffer interface and returns a float64 version of itself.
[ "AsFloatBuffer", "implements", "the", "Buffer", "interface", "and", "returns", "a", "float64", "version", "of", "itself", "." ]
7b2a6ca214808c64326280ac13268af853543f0b
https://github.com/go-audio/audio/blob/7b2a6ca214808c64326280ac13268af853543f0b/float_buffer.go#L92-L103
18,091
instana/go-sensor
adapters.go
TraceHandler
func (s *Sensor) TraceHandler(name, pattern string, handler http.HandlerFunc) (string, http.HandlerFunc) { return pattern, s.TracingHandler(name, handler) }
go
func (s *Sensor) TraceHandler(name, pattern string, handler http.HandlerFunc) (string, http.HandlerFunc) { return pattern, s.TracingHandler(name, handler) }
[ "func", "(", "s", "*", "Sensor", ")", "TraceHandler", "(", "name", ",", "pattern", "string", ",", "handler", "http", ".", "HandlerFunc", ")", "(", "string", ",", "http", ".", "HandlerFunc", ")", "{", "return", "pattern", ",", "s", ".", "TracingHandler", ...
// It is similar to TracingHandler in regards, that it wraps an existing http.HandlerFunc // into a named instance to support capturing tracing information and data. It, however, // provides a neater way to register the handler with existing frameworks by returning // not only the wrapper, but also the URL-pattern to r...
[ "It", "is", "similar", "to", "TracingHandler", "in", "regards", "that", "it", "wraps", "an", "existing", "http", ".", "HandlerFunc", "into", "a", "named", "instance", "to", "support", "capturing", "tracing", "information", "and", "data", ".", "It", "however", ...
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/adapters.go#L36-L38
18,092
instana/go-sensor
adapters.go
TracingHandler
func (s *Sensor) TracingHandler(name string, handler http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { s.WithTracingContext(name, w, req, func(span ot.Span, ctx context.Context) { // Capture response code for span hooks := httpsnoop.Hooks{ WriteHeader: func(next h...
go
func (s *Sensor) TracingHandler(name string, handler http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { s.WithTracingContext(name, w, req, func(span ot.Span, ctx context.Context) { // Capture response code for span hooks := httpsnoop.Hooks{ WriteHeader: func(next h...
[ "func", "(", "s", "*", "Sensor", ")", "TracingHandler", "(", "name", "string", ",", "handler", "http", ".", "HandlerFunc", ")", "http", ".", "HandlerFunc", "{", "return", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "R...
// Wraps an existing http.HandlerFunc into a named instance to support capturing tracing // information and response data.
[ "Wraps", "an", "existing", "http", ".", "HandlerFunc", "into", "a", "named", "instance", "to", "support", "capturing", "tracing", "information", "and", "response", "data", "." ]
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/adapters.go#L42-L62
18,093
instana/go-sensor
adapters.go
TracingHttpRequest
func (s *Sensor) TracingHttpRequest(name string, parent, req *http.Request, client http.Client) (res *http.Response, err error) { var span ot.Span if parentSpan, ok := parent.Context().Value("parentSpan").(ot.Span); ok { span = s.tracer.StartSpan("client", ot.ChildOf(parentSpan.Context())) } else { span = s.trac...
go
func (s *Sensor) TracingHttpRequest(name string, parent, req *http.Request, client http.Client) (res *http.Response, err error) { var span ot.Span if parentSpan, ok := parent.Context().Value("parentSpan").(ot.Span); ok { span = s.tracer.StartSpan("client", ot.ChildOf(parentSpan.Context())) } else { span = s.trac...
[ "func", "(", "s", "*", "Sensor", ")", "TracingHttpRequest", "(", "name", "string", ",", "parent", ",", "req", "*", "http", ".", "Request", ",", "client", "http", ".", "Client", ")", "(", "res", "*", "http", ".", "Response", ",", "err", "error", ")", ...
// Wraps an existing http.Request instance into a named instance to inject tracing and span // header information into the actual HTTP wire transfer.
[ "Wraps", "an", "existing", "http", ".", "Request", "instance", "into", "a", "named", "instance", "to", "inject", "tracing", "and", "span", "header", "information", "into", "the", "actual", "HTTP", "wire", "transfer", "." ]
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/adapters.go#L66-L96
18,094
instana/go-sensor
adapters.go
WithTracingContext
func (s *Sensor) WithTracingContext(name string, w http.ResponseWriter, req *http.Request, f ContextSensitiveFunc) { s.WithTracingSpan(name, w, req, func(span ot.Span) { ctx := context.WithValue(req.Context(), "parentSpan", span) f(span, ctx) }) }
go
func (s *Sensor) WithTracingContext(name string, w http.ResponseWriter, req *http.Request, f ContextSensitiveFunc) { s.WithTracingSpan(name, w, req, func(span ot.Span) { ctx := context.WithValue(req.Context(), "parentSpan", span) f(span, ctx) }) }
[ "func", "(", "s", "*", "Sensor", ")", "WithTracingContext", "(", "name", "string", ",", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ",", "f", "ContextSensitiveFunc", ")", "{", "s", ".", "WithTracingSpan", "(", "name", ","...
// Executes the given ContextSensitiveFunc and executes it under the scope of a newly created context.Context, // that provides access to the parent span as 'parentSpan'.
[ "Executes", "the", "given", "ContextSensitiveFunc", "and", "executes", "it", "under", "the", "scope", "of", "a", "newly", "created", "context", ".", "Context", "that", "provides", "access", "to", "the", "parent", "span", "as", "parentSpan", "." ]
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/adapters.go#L152-L157
18,095
instana/go-sensor
eum.go
EumSnippet
func EumSnippet(apiKey string, traceID string, meta map[string]string) string { if len(apiKey) == 0 || len(traceID) == 0 { return "" } b, err := ioutil.ReadFile(eumTemplate) if err != nil { return "" } var snippet = string(b) var metaBuffer bytes.Buffer snippet = strings.Replace(snippet, "$apiKey", api...
go
func EumSnippet(apiKey string, traceID string, meta map[string]string) string { if len(apiKey) == 0 || len(traceID) == 0 { return "" } b, err := ioutil.ReadFile(eumTemplate) if err != nil { return "" } var snippet = string(b) var metaBuffer bytes.Buffer snippet = strings.Replace(snippet, "$apiKey", api...
[ "func", "EumSnippet", "(", "apiKey", "string", ",", "traceID", "string", ",", "meta", "map", "[", "string", "]", "string", ")", "string", "{", "if", "len", "(", "apiKey", ")", "==", "0", "||", "len", "(", "traceID", ")", "==", "0", "{", "return", "...
// EumSnippet generates javascript code to initialize JavaScript agent
[ "EumSnippet", "generates", "javascript", "code", "to", "initialize", "JavaScript", "agent" ]
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/eum.go#L12-L37
18,096
instana/go-sensor
util.go
Header2ID
func Header2ID(header string) (int64, error) { // FIXME: We're assuming LittleEndian here // Parse unsigned 64 bit hex string into unsigned 64 bit base 10 integer if unsignedID, err := strconv.ParseUint(header, 16, 64); err == nil { // Write out _unsigned_ 64bit integer to byte buffer buf := new(bytes.Buffer) ...
go
func Header2ID(header string) (int64, error) { // FIXME: We're assuming LittleEndian here // Parse unsigned 64 bit hex string into unsigned 64 bit base 10 integer if unsignedID, err := strconv.ParseUint(header, 16, 64); err == nil { // Write out _unsigned_ 64bit integer to byte buffer buf := new(bytes.Buffer) ...
[ "func", "Header2ID", "(", "header", "string", ")", "(", "int64", ",", "error", ")", "{", "// FIXME: We're assuming LittleEndian here", "// Parse unsigned 64 bit hex string into unsigned 64 bit base 10 integer", "if", "unsignedID", ",", "err", ":=", "strconv", ".", "ParseUin...
// Header2ID converts an header context value into an Instana ID. More // specifically, this converts an unsigned 64 bit hex value into a signed // 64bit integer.
[ "Header2ID", "converts", "an", "header", "context", "value", "into", "an", "Instana", "ID", ".", "More", "specifically", "this", "converts", "an", "unsigned", "64", "bit", "hex", "value", "into", "a", "signed", "64bit", "integer", "." ]
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/util.go#L54-L76
18,097
instana/go-sensor
util.go
hexGatewayToAddr
func hexGatewayToAddr(gateway []rune) (string, error) { // gateway address is encoded in reverse order in hex if len(gateway) != 8 { return "", errors.New("invalid gateway length") } var octets [4]uint8 for i, hexOctet := range [4]string{ string(gateway[6:8]), // first octet of IP Address string(gateway[4:6...
go
func hexGatewayToAddr(gateway []rune) (string, error) { // gateway address is encoded in reverse order in hex if len(gateway) != 8 { return "", errors.New("invalid gateway length") } var octets [4]uint8 for i, hexOctet := range [4]string{ string(gateway[6:8]), // first octet of IP Address string(gateway[4:6...
[ "func", "hexGatewayToAddr", "(", "gateway", "[", "]", "rune", ")", "(", "string", ",", "error", ")", "{", "// gateway address is encoded in reverse order in hex", "if", "len", "(", "gateway", ")", "!=", "8", "{", "return", "\"", "\"", ",", "errors", ".", "Ne...
// hexGatewayToAddr converts the hex representation of the gateway address to string.
[ "hexGatewayToAddr", "converts", "the", "hex", "representation", "of", "the", "gateway", "address", "to", "string", "." ]
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/util.go#L142-L164
18,098
instana/go-sensor
event.go
SendDefaultServiceEvent
func SendDefaultServiceEvent(title string, text string, sev severity, duration time.Duration) { if sensor == nil { // Since no sensor was initialized, there is no default service (as // configured on the sensor) so we send blank. SendServiceEvent("", title, text, sev, duration) } else { SendServiceEvent(senso...
go
func SendDefaultServiceEvent(title string, text string, sev severity, duration time.Duration) { if sensor == nil { // Since no sensor was initialized, there is no default service (as // configured on the sensor) so we send blank. SendServiceEvent("", title, text, sev, duration) } else { SendServiceEvent(senso...
[ "func", "SendDefaultServiceEvent", "(", "title", "string", ",", "text", "string", ",", "sev", "severity", ",", "duration", "time", ".", "Duration", ")", "{", "if", "sensor", "==", "nil", "{", "// Since no sensor was initialized, there is no default service (as", "// c...
// SendDefaultServiceEvent sends a default event which already contains the service and host
[ "SendDefaultServiceEvent", "sends", "a", "default", "event", "which", "already", "contains", "the", "service", "and", "host" ]
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/event.go#L36-L44
18,099
instana/go-sensor
event.go
SendServiceEvent
func SendServiceEvent(service string, title string, text string, sev severity, duration time.Duration) { sendEvent(&EventData{ Title: title, Text: text, Severity: int(sev), Plugin: ServicePlugin, ID: service, Host: ServiceHost, Duration: int(duration / time.Millisecond), }) }
go
func SendServiceEvent(service string, title string, text string, sev severity, duration time.Duration) { sendEvent(&EventData{ Title: title, Text: text, Severity: int(sev), Plugin: ServicePlugin, ID: service, Host: ServiceHost, Duration: int(duration / time.Millisecond), }) }
[ "func", "SendServiceEvent", "(", "service", "string", ",", "title", "string", ",", "text", "string", ",", "sev", "severity", ",", "duration", "time", ".", "Duration", ")", "{", "sendEvent", "(", "&", "EventData", "{", "Title", ":", "title", ",", "Text", ...
// SendServiceEvent send an event on a specific service
[ "SendServiceEvent", "send", "an", "event", "on", "a", "specific", "service" ]
9854c6e5d3e8c264693416ef9ee0646fa89cdc18
https://github.com/instana/go-sensor/blob/9854c6e5d3e8c264693416ef9ee0646fa89cdc18/event.go#L47-L57