id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c18000
!= nil) { Logger.Panicf("Abort: %s: %s %s", msg, revErr, err) } }
c18001
if strings.HasPrefix(relSrcPath, ".") { if info.IsDir() { return filepath.SkipDir } return nil } // Create a subdirectory if necessary. if info.IsDir() { err := os.MkdirAll(filepath.Join(destDir, relSrcPath), 0777) if !os.IsExist(err) { return NewBuildIfError(err, "Failed to create direc...
c18002
strings.TrimLeft(srcPath[len(srcDir):], string(os.PathSeparator)), Size: info.Size(), Mode: int64(info.Mode()), ModTime: info.ModTime(), }) if err != nil { return NewBuildIfError(err, "Failed to write tar entry header", "file", srcPath) } _, err = io.Copy(tarWriter, srcFile) if err != nil ...
c18003
{ _ = dir.Close() }() results, _ := dir.Readdir(1) return len(results) == 0 }
c18004
package","using",appImportPath, "remote",revelImportPath) revelPkg, err := build.Default.Import(revelImportPath, appPkgDir, build.FindOnly) if err != nil { Logger.Info("Resolved called Seeking remote package","using",appImportPath, "remote",revelImportPath) packageResolver(revelImportPath) revelPkg, err = buil...
c18005
value, _ = strconv.Atoi(input) } return value }
c18006
if !v.Newer(start) || v.Newer(end) { continue } // Framework is older then 0.20, turn on historic mode if i == 0 { c.HistoricMode = true } return nil } return errors.New("Tool out of date - do a 'go get -u github.com/revel/cmd/revel'") }
c18007
v.Major > o.Major } return false }
c18008
if v.Minor != o.Minor { return v.Minor > o.Minor } return false }
c18009
v.Minor != o.Minor { return v.Minor > o.Minor } if v.Maintenance != o.Maintenance { return v.Maintenance > o.Maintenance } return false }
c18010
v.Prefix, v.Major, v.Minor, v.Maintenance, v.Suffix) }
c18011
v.Major, v.Minor, v.Maintenance, v.Suffix, v.BuildDate, v.MinGoVersion) }
c18012
a thread safe manner update the flag so that a request for // /favicon.ico is allowed atomic.CompareAndSwapInt32(&lastRequestHadError, 1, 0) // Reverse proxy the request. // (Need special code for websockets, courtesy of bradfitz) if strings.EqualFold(r.Header.Get("Upgrade"), "websocket") { h.proxyWebsocket(w,...
c18013
getFreePort() } serverURL, _ := url.ParseRequestURI(fmt.Sprintf(scheme+"://%s:%d", addr, port)) serverHarness := &Harness{ port: port, serverHost: serverURL.String()[len(scheme+"://"):], proxy: httputil.NewSingleHostReverseProxy(serverURL), mutex: &sync.Mutex{}, paths: paths, useP...
c18014
} if h.useProxy { h.app.Port = h.port if err2 := h.app.Cmd(h.runMode).Start(h.config); err2 != nil { utils.Logger.Error("Could not start application", "error", err2) if err,k :=err2.(*utils.Error);k { return err } return &utils.Error{ Title: "App failed to start up", Description: er...
c18015
!utils.ContainsString(doNotWatch, info.Name()) }
c18016
h.paths.HTTPPort = getFreePort() } addr := fmt.Sprintf("%s:%d", h.paths.HTTPAddr, h.paths.HTTPPort) utils.Logger.Infof("Proxy server is listening on %s", addr) var err error if h.paths.HTTPSsl { err = http.ListenAndServeTLS( addr, h.paths.HTTPSslCert, h.paths.HTTPSslKey, h) ...
c18017
= conn.Addr().(*net.TCPAddr).Port err = conn.Close() if err != nil { utils.Logger.Fatal("Unable to close port", "error", err) } return port }
c18018
pkgIdent.Name, selectorExpr.Sel.Name } } return "", "" }() // If a typename wasn't found, skip it. if typeName == "" { continue } // Find the import path for this type. // If it was referenced without a package name, use the current package import path. // Else, look up the package's impor...
c18019
append(srcInfo1.InitImportPaths, srcInfo2.InitImportPaths...) for k, v := range srcInfo2.ValidationKeys { if _, ok := srcInfo1.ValidationKeys[k]; ok { utils.Logger.Warn("Warn: Key conflict when scanning validation calls:", "key", k) continue } srcInfo1.ValidationKeys[k] = v } return srcInfo1 }
c18020
b = &BuildError{} b.Message = message b.Args = args b.Stack = logger.NewCallStack() Logger.Info("Stack", "stack", b.Stack) return b }
c18021
return berr } else { args = append(args, "error", err.Error()) b = NewBuildError(message, args...) } } return }
c18022
if rootImportPath == "" { utils.Logger.Info("Skipping empty code path", "path", root) continue } pc.root, pc.rootImportPath = root, rootImportPath // Start walking the directory tree. compileError = utils.Walk(root, pc.processPath) if compileError != nil { return } } return pc.srcInfo, compile...
c18023
for i := range pkgs { if len(i) > 6 { if string(i[len(i)-5:]) == "_test" { delete(pkgs, i) } } } // If there is no code in this directory, skip it. if len(pkgs) == 0 { return nil } // There should be only one package in this directory. if len(pkgs) > 1 { for i := range pkgs { println("Foun...
c18024
structSpecs = appendStruct(fname, structSpecs, pkgImportPath, pkg, decl, imports, fset) } // If this is a func... (ignore nil for external (non-Go) function) if funcDecl, ok := decl.(*ast.FuncDecl); ok && funcDecl.Body != nil { // Scan it for validation calls lineKeys := GetValidationKeys(fname, fse...
c18025
fset.Position(decl.Pos()).Filename, fset.Position(decl.Pos()).Line) return } spec = genDecl.Specs[0].(*ast.TypeSpec) _, found = spec.Type.(*ast.StructType) return }
c18026
&App{BinaryPath: binPath, Paths: paths, Port: paths.HTTPPort} }
c18027
a.Port, runMode, a.Paths) return a.cmd }
c18028
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} }
c18029
output // err.MetaError = listeningWriter.getLastOutput() return err case <-time.After(60 * time.Second): println("Revel proxy is listening, point your browser to :", c.Run.Port) utils.Logger.Error("Killing revel server process did not respond after wait timeout.", "processid", cmd.Process.Pid) cmd.Kill() ...
c18030
{ utils.Logger.Fatal("Error running:", "error", err) } }
c18031
ch := make(chan bool, 1) go func() { s, err := cmd.Process.Wait() defer func() { ch <- true }() if err != nil { utils.Logger.Info("Wait failed for process ", "error", err) } if s != nil { utils.Logger.Info("Revel App exited", "state", s.String()) } }() // Use a timer to ensure t...
c18032
&& bytes.Contains(p, []byte("Listening on")) { w.notifyReady <- true w.notifyReady = nil } } if w.notifyReady!=nil { w.buffer.Write(p) } return w.dest.Write(p) }
c18033
paths.Config.StringDefault("watch.mode", "normal") == "eager", timerMutex: &sync.Mutex{}, refreshChannel: make(chan *utils.Error, 10), refreshChannelCount: 0, } }
c18034
} w.notifyMutex.Unlock() } else { // Run refresh in parallel go func() { w.notifyInProcess(listener) }() } } case <-watcher.Errors: continue } } }
c18035
even if a panic occurs defer func() { for x := 0; x < w.refreshChannelCount; x++ { w.refreshChannel <- err } w.refreshChannelCount = 0 w.refreshTimer = nil w.timerMutex.Unlock() }() err = listener.Refresh() if err != nil { utils.Logger.Info("Watcher: Recording error last build, setting rebuild on",...
c18036
cmdClean.Long) return false } c.Clean.ImportPath = args[0] return true }
c18037
_, dir := range purgeDirs { fmt.Println("Removing:", dir) err = os.RemoveAll(dir) if err != nil { utils.Logger.Error("Failed to clean dir", "error", err) return } } return err }
c18038
= alphaNumeric[rand.Intn(len(alphaNumeric))] } return string(chars) }
c18039
it. if !c.New.Vendored { _, err = build.Import(model.RevelImportPath, "", build.FindOnly) if err != nil { //// Go get the revel project err = c.PackageResolver(model.RevelImportPath) if err != nil { return utils.NewBuildIfError(err, "Failed to fetch revel "+model.RevelImportPath) } } } c.AppN...
c18040
sp.String()) } case "git": fallthrough case "http": fallthrough case "https": if err := newLoadFromGit(c, sp); err != nil { return err } default: utils.Logger.Fatal("Unsupported skeleton schema ", "path", c.New.SkeletonPath) } // TODO check to see if the path needs to be extracted }...
c18041
if len(pathpart) > 1 { outputPath = filepath.Join(targetPath, filepath.Join(strings.Split(pathpart[1], string('/'))...)) } outputPath, _ = filepath.Abs(outputPath) if !strings.HasPrefix(outputPath, targetPath) { utils.Logger.Fatal("Unusual target path outside root path", "target", outputPath, "root", targetPath...
c18042
} fmt.Fprintf(os.Stderr, format, args...) panic(format) // Panic instead of os.Exit so that deferred will run. }
c18043
uid, } c.logf("You are currently using the v2 version analytics-go, which is being deprecated. Please update to v3 as soon as you can https://segment.com/docs/sources/server/go/#migrating-from-v2") c.upcond.L = &c.upmtx return c }
c18044
'userId'.") } if msg.PreviousId == "" { return errors.New("You must pass a 'previousId'.") } msg.Type = "alias" c.queue(msg) return nil }
c18045
'anonymousId' or 'userId'.") } msg.Type = "page" c.queue(msg) return nil }
c18046
if msg.UserId == "" && msg.AnonymousId == "" { return errors.New("You must pass either an 'anonymousId' or 'userId'.") } msg.Type = "group" c.queue(msg) return nil }
c18047
msg.UserId == "" && msg.AnonymousId == "" { return errors.New("You must pass either an 'anonymousId' or 'userId'.") } msg.Type = "track" c.queue(msg) return nil }
c18048
msg.setMessageId(c.uid()) msg.setTimestamp(timestamp(c.now())) c.msgs <- msg }
c18049
close(c.msgs) <-c.shutdown return nil }
c18050
return fmt.Errorf("error marshalling msgs: %s", err) } for i := 0; i < 10; i++ { if err = c.upload(b); err == nil { return nil } Backo.Sleep(i) } return err }
c18051
400 { c.verbose("response %s", res.Status) return nil } body, err := ioutil.ReadAll(res.Body) if err != nil { return fmt.Errorf("error reading response body: %s", err) } return fmt.Errorf("response %s: %d – %s", res.Status, res.StatusCode, string(body)) }
c18052
c.verbose("interval reached - flushing %d", len(msgs)) c.sendAsync(msgs) msgs = make([]interface{}, 0, c.Size) } else { c.verbose("interval reached – nothing to send") } case <-c.quit: tick.Stop() c.verbose("exit requested – draining msgs") // drain the msg channel. for msg := range ...
c18053
{ if c.Verbose { c.Logger.Printf(msg, args...) } }
c18054
...interface{}) { c.Logger.Printf(msg, args...) }
c18055
== "" { m.Timestamp = s } }
c18056
== "" { m.MessageId = s } }
c18057
to create unique index for translations key & locale, got: %v\n", err.Error()) } return &Backend{DB: db} }
c18058
[]*i18n.Translation) { backend.DB.Find(&translations) return translations }
c18059
Assign(Translation{Value: t.Value}). FirstOrCreate(&Translation{}).Error }
c18060
t.Key, Locale: t.Locale}).Delete(&Translation{}).Error }
c18061
if fileInfo.Mode().IsRegular() { files = append(files, p) } } } } for _, file := range files { if content, err := ioutil.ReadFile(file); err == nil { backend.contents = append(backend.contents, content) } } return backend }
c18062
range files { if content, err := ioutil.ReadFile(file); err == nil { backend.contents = append(backend.contents, content) } } return backend }
c18063
backend.contents = append(backend.contents, walkFilesystem(fs, nil, "/")...) } return backend }
c18064
= append(translations, loadTranslationsFromYaml(item.Key.(string) /* locale */, item.Value, []string{})...) } } return translations, err }
c18065
if results, err := backend.LoadYAMLContent(content); err == nil { translations = append(translations, results...) } else { panic(err) } } return translations }
c18066
memory.New()} i18n.loadToCacheStore() return i18n }
c18067
{ i18n.cacheStore = cacheStore i18n.loadToCacheStore() }
c18068
{ return i18n.cacheStore.Set(cacheKey(translation.Locale, translation.Key), translation) }
c18069
i18n.AddTranslation(translation) return nil } } return errors.New("failed to save translation") }
c18070
return i18n.cacheStore.Delete(cacheKey(translation.Locale, translation.Key)) }
c18071
Resource: i18n.Resource, FallbackLocales: i18n.FallbackLocales, fallbackLocales: i18n.fallbackLocales} }
c18072
i18n.Backends, Resource: i18n.Resource, FallbackLocales: i18n.FallbackLocales, fallbackLocales: locale} }
c18073
== "" { // If not initialized var defaultBackend Backend if len(i18n.Backends) > 0 { defaultBackend = i18n.Backends[0] } translation = Translation{Key: translationKey, Value: value, Locale: locale, Backend: defaultBackend} // Save translation i18n.SaveTranslation(&translation) } ...
c18074
template.FuncMap { return template.FuncMap{ "t": InlineEdit(I18n, locale, enableInlineEdit), } }
c18075
} else { value = I18n.T(locale, key) } // Append inline-edit script/tag if isInline { var editType string if len(value) > 25 { editType = "data-type=\"textarea\"" } prefix := I18n.Resource.GetAdmin().GetRouter().Prefix assetsTag := fmt.Sprintf("<script data-prefix=\"%v\" src=\"%v/assets/ja...
c18076
if b.Format != nil { newB.Format = &Format{ NumChannels: b.Format.NumChannels, SampleRate: b.Format.SampleRate, } } return newB }
c18077
NumChannels: b.Format.NumChannels, SampleRate: b.Format.SampleRate, } } return newB }
c18078
for i := 0; i < len(b.F32); i++ { out[i] = int8(b.F32[i]) } case DataTypeF64: out = make([]int8, len(b.F64)) for i := 0; i < len(b.F64); i++ { out[i] = int8(b.F64[i]) } } return out }
c18079
bitDepth := b.calculateIntBitDepth() factor := math.Pow(2, 8*float64(bitDepth/8)-1) out = make([]float64, len(b.I16)) for i := 0; i < len(b.I16); i++ { out[i] = float64(int64(b.I16[i])) / factor } case DataTypeF32: out = make([]float64, len(b.F32)) for i := 0; i < len(b.F32); i++ { out[i] = float64...
c18080
default: // This method is only meant to be used on int buffers. return bitDepth } bitDepth = 8 if max > 127 { bitDepth = 16 } // greater than int16, expecting int24 if max > 32767 { bitDepth = 24 } // int 32 if max > 8388607 { bitDepth = 32 } // int 64 if max > 4294967295 { bitDepth = 64 } ...
c18081
newB.SourceBitDepth = buf.SourceBitDepth factor := math.Pow(2, float64(buf.SourceBitDepth)-1) for i := 0; i < len(buf.Data); i++ { newB.Data[i] = float32(float64(buf.Data[i]) / factor) } newB.Format = &Format{ NumChannels: buf.Format.NumChannels, SampleRate: buf.Format.SampleRate, } return newB }
c18082
i = (uint32(b[2]) << 23) | (uint32(b[3]) << 15) | (uint32(b[4]) << 7) | (uint32(b[5]) >> 1) i >>= (29 - uint32(b[1])) return int(i) }
c18083
uint(fsMant) fMant = math.Ldexp(fMant-fsMant, 32) fsMant = math.Floor(fMant) loMant = uint(fsMant) } } b[0] = byte(expon >> 8) b[1] = byte(expon) b[2] = byte(hiMant >> 24) b[3] = byte(hiMant >> 16) b[4] = byte(hiMant >> 8) b[5] = byte(hiMant) b[6] = byte(loMant >> 24) b[7] = byte(loMant >> 16) b[...
c18084
<< 0 output |= uint32(bytes[1]) << 8 output |= uint32(bytes[0]) << 16 return output }
c18085
| int32(0xFF&bytes[1])<<8 | int32(0xFF&bytes[2]) if (ss & 0x800000) > 0 { ss |= ^0xffffff } return ss }
c18086
int32(bytes[2])<<16 if (ss & 0x800000) > 0 { ss |= ^0xffffff } return ss }
c18087
= byte(n >> 8) bytes[2] = byte(n >> 0) return bytes }
c18088
0 { n |= ^0xffffff } bytes[2] = byte(n >> 16) bytes[1] = byte(n >> 8) bytes[0] = byte(n >> 0) return bytes }
c18089
0 { n |= ^0xffffff } bytes[0] = byte(n >> 16) bytes[1] = byte(n >> 8) bytes[2] = byte(n >> 0) return bytes }
c18090
&Format{ NumChannels: buf.Format.NumChannels, SampleRate: buf.Format.SampleRate, } return newB }
c18091
return pattern, s.TracingHandler(name, handler) }
c18092
WriteHeader: func(next httpsnoop.WriteHeaderFunc) httpsnoop.WriteHeaderFunc { return func(code int) { next(code) span.SetTag(string(ext.HTTPStatusCode), code) } }, } // Add hooks to response writer wrappedWriter := httpsnoop.Wrap(w, hooks) // Serve original handler handle...
c18093
err := s.tracer.Inject(span.Context(), ot.HTTPHeaders, headersCarrier); err != nil { return nil, err } res, err = client.Do(req.WithContext(context.Background())) span.SetTag(string(ext.SpanKind), string(ext.SpanKindRPCClientEnum)) span.SetTag(string(ext.PeerHostname), req.Host) span.SetTag(string(ext.HTTPUrl...
c18094
ctx := context.WithValue(req.Context(), "parentSpan", span) f(span, ctx) }) }
c18095
-1) for key, value := range meta { metaBuffer.WriteString(" ineum('meta', '" + key + "', '" + value + "');\n") } snippet = strings.Replace(snippet, "$meta", metaBuffer.String(), -1) return snippet }
c18096
binary.Read(buf, binary.LittleEndian, &signedID); err == nil { // The success case return signedID, nil } log.debug(err) } else { log.debug(err) } } else { log.debug(err) } return int64(0), errors.New("context corrupted; could not convert value") }
c18097
octet of IP Address string(gateway[4:6]), // second octet string(gateway[2:4]), // third octet string(gateway[0:2]), // last octet } { octet, err := strconv.ParseUint(hexOctet, 16, 8) if err != nil { return "", err } octets[i] = uint8(octet) } return fmt.Sprintf("%v.%v.%v.%v", octets[0], octets[1...
c18098
SendServiceEvent("", title, text, sev, duration) } else { SendServiceEvent(sensor.serviceName, title, text, sev, duration) } }
c18099
int(sev), Plugin: ServicePlugin, ID: service, Host: ServiceHost, Duration: int(duration / time.Millisecond), }) }