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
137,200
cybozu-go/well
exec.go
CombinedOutput
func (c *LogCmd) CombinedOutput() ([]byte, error) { st := time.Now() data, err := c.Cmd.CombinedOutput() c.log(st, err, nil) return data, err }
go
func (c *LogCmd) CombinedOutput() ([]byte, error) { st := time.Now() data, err := c.Cmd.CombinedOutput() c.log(st, err, nil) return data, err }
[ "func", "(", "c", "*", "LogCmd", ")", "CombinedOutput", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "st", ":=", "time", ".", "Now", "(", ")", "\n", "data", ",", "err", ":=", "c", ".", "Cmd", ".", "CombinedOutput", "(", ")", "\n", ...
// CombinedOutput overrides exec.Cmd.CombinedOutput to record the result.
[ "CombinedOutput", "overrides", "exec", ".", "Cmd", ".", "CombinedOutput", "to", "record", "the", "result", "." ]
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/exec.go#L78-L83
137,201
cybozu-go/well
exec.go
Output
func (c *LogCmd) Output() ([]byte, error) { st := time.Now() data, err := c.Cmd.Output() if err != nil { ee, ok := err.(*exec.ExitError) if ok { c.log(st, err, ee.Stderr) return data, err } } c.log(st, err, nil) return data, err }
go
func (c *LogCmd) Output() ([]byte, error) { st := time.Now() data, err := c.Cmd.Output() if err != nil { ee, ok := err.(*exec.ExitError) if ok { c.log(st, err, ee.Stderr) return data, err } } c.log(st, err, nil) return data, err }
[ "func", "(", "c", "*", "LogCmd", ")", "Output", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "st", ":=", "time", ".", "Now", "(", ")", "\n", "data", ",", "err", ":=", "c", ".", "Cmd", ".", "Output", "(", ")", "\n", "if", "err", ...
// Output overrides exec.Cmd.Output to record the result. // If Cmd.Stderr is nil, Output logs outputs to stderr as well.
[ "Output", "overrides", "exec", ".", "Cmd", ".", "Output", "to", "record", "the", "result", ".", "If", "Cmd", ".", "Stderr", "is", "nil", "Output", "logs", "outputs", "to", "stderr", "as", "well", "." ]
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/exec.go#L87-L99
137,202
cybozu-go/well
exec.go
Run
func (c *LogCmd) Run() error { if c.Cmd.Stdout == nil && c.Cmd.Stderr == nil { _, err := c.Output() return err } st := time.Now() err := c.Cmd.Run() c.log(st, err, nil) return err }
go
func (c *LogCmd) Run() error { if c.Cmd.Stdout == nil && c.Cmd.Stderr == nil { _, err := c.Output() return err } st := time.Now() err := c.Cmd.Run() c.log(st, err, nil) return err }
[ "func", "(", "c", "*", "LogCmd", ")", "Run", "(", ")", "error", "{", "if", "c", ".", "Cmd", ".", "Stdout", "==", "nil", "&&", "c", ".", "Cmd", ".", "Stderr", "==", "nil", "{", "_", ",", "err", ":=", "c", ".", "Output", "(", ")", "\n", "retu...
// Run overrides exec.Cmd.Run to record the result. // If both Cmd.Stdout and Cmd.Stderr are nil, this calls Output // instead to log stderr.
[ "Run", "overrides", "exec", ".", "Cmd", ".", "Run", "to", "record", "the", "result", ".", "If", "both", "Cmd", ".", "Stdout", "and", "Cmd", ".", "Stderr", "are", "nil", "this", "calls", "Output", "instead", "to", "log", "stderr", "." ]
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/exec.go#L104-L114
137,203
cybozu-go/well
exec.go
Wait
func (c *LogCmd) Wait() error { st := time.Now() err := c.Cmd.Wait() c.log(st, err, nil) return err }
go
func (c *LogCmd) Wait() error { st := time.Now() err := c.Cmd.Wait() c.log(st, err, nil) return err }
[ "func", "(", "c", "*", "LogCmd", ")", "Wait", "(", ")", "error", "{", "st", ":=", "time", ".", "Now", "(", ")", "\n", "err", ":=", "c", ".", "Cmd", ".", "Wait", "(", ")", "\n", "c", ".", "log", "(", "st", ",", "err", ",", "nil", ")", "\n"...
// Wait overrides exec.Cmd.Wait to record the result.
[ "Wait", "overrides", "exec", ".", "Cmd", ".", "Wait", "to", "record", "the", "result", "." ]
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/exec.go#L117-L122
137,204
cybozu-go/well
http_17.go
ListenAndServe
func (s *HTTPServer) ListenAndServe() error { addr := s.Server.Addr if addr == "" { addr = ":http" } ln, err := net.Listen("tcp", addr) if err != nil { return err } return s.Serve(ln) }
go
func (s *HTTPServer) ListenAndServe() error { addr := s.Server.Addr if addr == "" { addr = ":http" } ln, err := net.Listen("tcp", addr) if err != nil { return err } return s.Serve(ln) }
[ "func", "(", "s", "*", "HTTPServer", ")", "ListenAndServe", "(", ")", "error", "{", "addr", ":=", "s", ".", "Server", ".", "Addr", "\n", "if", "addr", "==", "\"", "\"", "{", "addr", "=", "\"", "\"", "\n", "}", "\n", "ln", ",", "err", ":=", "net...
// ListenAndServe overrides http.Server's method. // // Unlike the original, this method returns immediately just after // starting a goroutine to accept connections. To stop listening, // call the environment's Cancel. // // ListenAndServe returns non-nil error if and only if net.Listen failed.
[ "ListenAndServe", "overrides", "http", ".", "Server", "s", "method", ".", "Unlike", "the", "original", "this", "method", "returns", "immediately", "just", "after", "starting", "a", "goroutine", "to", "accept", "connections", ".", "To", "stop", "listening", "call...
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/http_17.go#L298-L308
137,205
cybozu-go/well
http_17.go
Do
func (c *HTTPClient) Do(req *http.Request) (*http.Response, error) { ctx := req.Context() v := ctx.Value(RequestIDContextKey) if v != nil { req.Header.Set(requestIDHeader, v.(string)) } st := time.Now() resp, err := c.Client.Do(req) logger := c.Logger if logger == nil { logger = log.DefaultLogger() } if...
go
func (c *HTTPClient) Do(req *http.Request) (*http.Response, error) { ctx := req.Context() v := ctx.Value(RequestIDContextKey) if v != nil { req.Header.Set(requestIDHeader, v.(string)) } st := time.Now() resp, err := c.Client.Do(req) logger := c.Logger if logger == nil { logger = log.DefaultLogger() } if...
[ "func", "(", "c", "*", "HTTPClient", ")", "Do", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "ctx", ":=", "req", ".", "Context", "(", ")", "\n", "v", ":=", "ctx", ".", "Value", "(", ...
// Do overrides http.Client.Do. // // req's context should have been set by http.Request.WithContext // for request tracking and context-based cancelation.
[ "Do", "overrides", "http", ".", "Client", ".", "Do", ".", "req", "s", "context", "should", "have", "been", "set", "by", "http", ".", "Request", ".", "WithContext", "for", "request", "tracking", "and", "context", "-", "based", "cancelation", "." ]
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/http_17.go#L378-L414
137,206
cybozu-go/well
http_17.go
Post
func (c *HTTPClient) Post(url, bodyType string, body io.Reader) (*http.Response, error) { panic("Use Do") }
go
func (c *HTTPClient) Post(url, bodyType string, body io.Reader) (*http.Response, error) { panic("Use Do") }
[ "func", "(", "c", "*", "HTTPClient", ")", "Post", "(", "url", ",", "bodyType", "string", ",", "body", "io", ".", "Reader", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}" ]
// Post panics.
[ "Post", "panics", "." ]
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/http_17.go#L427-L429
137,207
cybozu-go/well
http_17.go
PostForm
func (c *HTTPClient) PostForm(url string, data url.Values) (*http.Response, error) { panic("Use Do") }
go
func (c *HTTPClient) PostForm(url string, data url.Values) (*http.Response, error) { panic("Use Do") }
[ "func", "(", "c", "*", "HTTPClient", ")", "PostForm", "(", "url", "string", ",", "data", "url", ".", "Values", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}" ]
// PostForm panics.
[ "PostForm", "panics", "." ]
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/http_17.go#L432-L434
137,208
cybozu-go/well
graceful_unix.go
SystemdListeners
func SystemdListeners() ([]net.Listener, error) { pid, err := strconv.Atoi(os.Getenv("LISTEN_PID")) if err != nil { return nil, err } if pid != os.Getpid() { return nil, nil } return restoreListeners("LISTEN_FDS") }
go
func SystemdListeners() ([]net.Listener, error) { pid, err := strconv.Atoi(os.Getenv("LISTEN_PID")) if err != nil { return nil, err } if pid != os.Getpid() { return nil, nil } return restoreListeners("LISTEN_FDS") }
[ "func", "SystemdListeners", "(", ")", "(", "[", "]", "net", ".", "Listener", ",", "error", ")", "{", "pid", ",", "err", ":=", "strconv", ".", "Atoi", "(", "os", ".", "Getenv", "(", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "ret...
// SystemdListeners returns listeners from systemd socket activation.
[ "SystemdListeners", "returns", "listeners", "from", "systemd", "socket", "activation", "." ]
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/graceful_unix.go#L80-L89
137,209
cybozu-go/well
graceful_unix.go
Run
func (g *Graceful) Run() { if isMaster() { env := g.Env if env == nil { env = defaultEnv } env.Go(g.runMaster) return } lns, err := restoreListeners(listenEnv) if err != nil { log.ErrorExit(err) } log.DefaultLogger().SetDefaults(map[string]interface{}{ "pid": os.Getpid(), }) log.Info("well: ne...
go
func (g *Graceful) Run() { if isMaster() { env := g.Env if env == nil { env = defaultEnv } env.Go(g.runMaster) return } lns, err := restoreListeners(listenEnv) if err != nil { log.ErrorExit(err) } log.DefaultLogger().SetDefaults(map[string]interface{}{ "pid": os.Getpid(), }) log.Info("well: ne...
[ "func", "(", "g", "*", "Graceful", ")", "Run", "(", ")", "{", "if", "isMaster", "(", ")", "{", "env", ":=", "g", ".", "Env", "\n", "if", "env", "==", "nil", "{", "env", "=", "defaultEnv", "\n", "}", "\n", "env", ".", "Go", "(", "g", ".", "r...
// Run runs the graceful restarting server. // // If this is the master process, Run starts a child process, // and installs SIGHUP handler to restarts the child process. // // If this is a child process, Run simply calls g.Serve. // // Run returns immediately in the master process, and never // returns in the child pr...
[ "Run", "runs", "the", "graceful", "restarting", "server", ".", "If", "this", "is", "the", "master", "process", "Run", "starts", "a", "child", "process", "and", "installs", "SIGHUP", "handler", "to", "restarts", "the", "child", "process", ".", "If", "this", ...
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/graceful_unix.go#L100-L123
137,210
cybozu-go/well
graceful_unix.go
runMaster
func (g *Graceful) runMaster(ctx context.Context) error { logger := log.DefaultLogger() // prepare listener files listeners, err := g.Listen() if err != nil { return err } files, err := listenerFiles(listeners) if err != nil { return err } if len(files) == 0 { return errors.New("no listener") } defer ...
go
func (g *Graceful) runMaster(ctx context.Context) error { logger := log.DefaultLogger() // prepare listener files listeners, err := g.Listen() if err != nil { return err } files, err := listenerFiles(listeners) if err != nil { return err } if len(files) == 0 { return errors.New("no listener") } defer ...
[ "func", "(", "g", "*", "Graceful", ")", "runMaster", "(", "ctx", "context", ".", "Context", ")", "error", "{", "logger", ":=", "log", ".", "DefaultLogger", "(", ")", "\n\n", "// prepare listener files", "listeners", ",", "err", ":=", "g", ".", "Listen", ...
// runMaster is the main function of the master process.
[ "runMaster", "is", "the", "main", "function", "of", "the", "master", "process", "." ]
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/graceful_unix.go#L126-L197
137,211
cybozu-go/well
env.go
Stop
func (e *Environment) Stop() { e.mu.Lock() if !e.stopped { e.stopped = true close(e.stopCh) } e.mu.Unlock() }
go
func (e *Environment) Stop() { e.mu.Lock() if !e.stopped { e.stopped = true close(e.stopCh) } e.mu.Unlock() }
[ "func", "(", "e", "*", "Environment", ")", "Stop", "(", ")", "{", "e", ".", "mu", ".", "Lock", "(", ")", "\n\n", "if", "!", "e", ".", "stopped", "{", "e", ".", "stopped", "=", "true", "\n", "close", "(", "e", ".", "stopCh", ")", "\n", "}", ...
// Stop just declares no further Go will be called. // // Calling Stop is optional if and only if Cancel is guaranteed // to be called at some point. For instance, if the program runs // until SIGINT or SIGTERM, Stop is optional.
[ "Stop", "just", "declares", "no", "further", "Go", "will", "be", "called", ".", "Calling", "Stop", "is", "optional", "if", "and", "only", "if", "Cancel", "is", "guaranteed", "to", "be", "called", "at", "some", "point", ".", "For", "instance", "if", "the"...
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/env.go#L45-L54
137,212
cybozu-go/well
env.go
Wait
func (e *Environment) Wait() error { <-e.stopCh if log.Enabled(log.LvDebug) { log.Debug("well: waiting for all goroutines to complete", nil) } e.wg.Wait() e.cancel() // in case no one calls Cancel e.mu.Lock() defer e.mu.Unlock() return e.err }
go
func (e *Environment) Wait() error { <-e.stopCh if log.Enabled(log.LvDebug) { log.Debug("well: waiting for all goroutines to complete", nil) } e.wg.Wait() e.cancel() // in case no one calls Cancel e.mu.Lock() defer e.mu.Unlock() return e.err }
[ "func", "(", "e", "*", "Environment", ")", "Wait", "(", ")", "error", "{", "<-", "e", ".", "stopCh", "\n", "if", "log", ".", "Enabled", "(", "log", ".", "LvDebug", ")", "{", "log", ".", "Debug", "(", "\"", "\"", ",", "nil", ")", "\n", "}", "\...
// Wait waits for Stop or Cancel, and for all goroutines started by // Go to finish. // // The returned err is the one passed to Cancel, or nil. // err can be tested by IsSignaled to determine whether the // program got SIGINT or SIGTERM.
[ "Wait", "waits", "for", "Stop", "or", "Cancel", "and", "for", "all", "goroutines", "started", "by", "Go", "to", "finish", ".", "The", "returned", "err", "is", "the", "one", "passed", "to", "Cancel", "or", "nil", ".", "err", "can", "be", "tested", "by",...
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/env.go#L94-L106
137,213
cybozu-go/well
env.go
GoWithID
func (e *Environment) GoWithID(f func(ctx context.Context) error) { e.Go(func(ctx context.Context) error { return f(WithRequestID(ctx, e.generator.Generate())) }) }
go
func (e *Environment) GoWithID(f func(ctx context.Context) error) { e.Go(func(ctx context.Context) error { return f(WithRequestID(ctx, e.generator.Generate())) }) }
[ "func", "(", "e", "*", "Environment", ")", "GoWithID", "(", "f", "func", "(", "ctx", "context", ".", "Context", ")", "error", ")", "{", "e", ".", "Go", "(", "func", "(", "ctx", "context", ".", "Context", ")", "error", "{", "return", "f", "(", "Wi...
// GoWithID calls Go with a context having a new request tracking ID.
[ "GoWithID", "calls", "Go", "with", "a", "context", "having", "a", "new", "request", "tracking", "ID", "." ]
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/env.go#L142-L146
137,214
cybozu-go/well
graceful_windows.go
Run
func (g *Graceful) Run() { env := g.Env if env == nil { env = defaultEnv } // prepare listener files listeners, err := g.Listen() if err != nil { env.Cancel(err) return } g.Serve(listeners) }
go
func (g *Graceful) Run() { env := g.Env if env == nil { env = defaultEnv } // prepare listener files listeners, err := g.Listen() if err != nil { env.Cancel(err) return } g.Serve(listeners) }
[ "func", "(", "g", "*", "Graceful", ")", "Run", "(", ")", "{", "env", ":=", "g", ".", "Env", "\n", "if", "env", "==", "nil", "{", "env", "=", "defaultEnv", "\n", "}", "\n\n", "// prepare listener files", "listeners", ",", "err", ":=", "g", ".", "Lis...
// Run simply calls g.Listen then g.Serve on Windows.
[ "Run", "simply", "calls", "g", ".", "Listen", "then", "g", ".", "Serve", "on", "Windows", "." ]
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/graceful_windows.go#L17-L30
137,215
cybozu-go/well
signal.go
handleSignal
func handleSignal(env *Environment) { ch := make(chan os.Signal, 2) signal.Notify(ch, stopSignals...) go func() { s := <-ch log.Warn("well: got signal", map[string]interface{}{ "signal": s.String(), }) env.Cancel(errSignaled) }() }
go
func handleSignal(env *Environment) { ch := make(chan os.Signal, 2) signal.Notify(ch, stopSignals...) go func() { s := <-ch log.Warn("well: got signal", map[string]interface{}{ "signal": s.String(), }) env.Cancel(errSignaled) }() }
[ "func", "handleSignal", "(", "env", "*", "Environment", ")", "{", "ch", ":=", "make", "(", "chan", "os", ".", "Signal", ",", "2", ")", "\n", "signal", ".", "Notify", "(", "ch", ",", "stopSignals", "...", ")", "\n\n", "go", "func", "(", ")", "{", ...
// handleSignal runs independent goroutine to cancel an environment.
[ "handleSignal", "runs", "independent", "goroutine", "to", "cancel", "an", "environment", "." ]
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/signal.go#L22-L33
137,216
cybozu-go/well
reqid.go
WithRequestID
func WithRequestID(ctx context.Context, reqid string) context.Context { return context.WithValue(ctx, RequestIDContextKey, reqid) }
go
func WithRequestID(ctx context.Context, reqid string) context.Context { return context.WithValue(ctx, RequestIDContextKey, reqid) }
[ "func", "WithRequestID", "(", "ctx", "context", ".", "Context", ",", "reqid", "string", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "RequestIDContextKey", ",", "reqid", ")", "\n", "}" ]
// WithRequestID returns a new context with a request ID as a value.
[ "WithRequestID", "returns", "a", "new", "context", "with", "a", "request", "ID", "as", "a", "value", "." ]
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/reqid.go#L20-L22
137,217
cybozu-go/well
reqid.go
BackgroundWithID
func BackgroundWithID(ctx context.Context) context.Context { id := ctx.Value(RequestIDContextKey) ctx = context.Background() if id == nil { return ctx } return WithRequestID(ctx, id.(string)) }
go
func BackgroundWithID(ctx context.Context) context.Context { id := ctx.Value(RequestIDContextKey) ctx = context.Background() if id == nil { return ctx } return WithRequestID(ctx, id.(string)) }
[ "func", "BackgroundWithID", "(", "ctx", "context", ".", "Context", ")", "context", ".", "Context", "{", "id", ":=", "ctx", ".", "Value", "(", "RequestIDContextKey", ")", "\n", "ctx", "=", "context", ".", "Background", "(", ")", "\n", "if", "id", "==", ...
// BackgroundWithID returns a new background context with an existing // request ID in ctx, if any.
[ "BackgroundWithID", "returns", "a", "new", "background", "context", "with", "an", "existing", "request", "ID", "in", "ctx", "if", "any", "." ]
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/reqid.go#L26-L33
137,218
cybozu-go/well
systemd.go
IsSystemdService
func IsSystemdService() bool { if runtime.GOOS != "linux" { return false } // https://www.freedesktop.org/software/systemd/man/systemd.exec.html#%24JOURNAL_STREAM if len(os.Getenv("JOURNAL_STREAM")) > 0 { return true } f, err := os.Open("/proc/self/cgroup") if err != nil { return false } defer f.Close(...
go
func IsSystemdService() bool { if runtime.GOOS != "linux" { return false } // https://www.freedesktop.org/software/systemd/man/systemd.exec.html#%24JOURNAL_STREAM if len(os.Getenv("JOURNAL_STREAM")) > 0 { return true } f, err := os.Open("/proc/self/cgroup") if err != nil { return false } defer f.Close(...
[ "func", "IsSystemdService", "(", ")", "bool", "{", "if", "runtime", ".", "GOOS", "!=", "\"", "\"", "{", "return", "false", "\n", "}", "\n\n", "// https://www.freedesktop.org/software/systemd/man/systemd.exec.html#%24JOURNAL_STREAM", "if", "len", "(", "os", ".", "Get...
// IsSystemdService returns true if the program runs as a systemd service.
[ "IsSystemdService", "returns", "true", "if", "the", "program", "runs", "as", "a", "systemd", "service", "." ]
cdbf0b975515ab2a1673c52308b0dd1683ebf1e0
https://github.com/cybozu-go/well/blob/cdbf0b975515ab2a1673c52308b0dd1683ebf1e0/systemd.go#L11-L45
137,219
andygrunwald/go-gerrit
events.go
getURL
func (events *EventsLogService) getURL(options *EventsLogOptions) (string, error) { parsed, err := url.Parse("/plugins/events-log/events/") if err != nil { return "", err } query := parsed.Query() if !options.From.IsZero() { query.Set("t1", options.From.Format("2006-01-02 15:04:05")) } if !options.To.IsZe...
go
func (events *EventsLogService) getURL(options *EventsLogOptions) (string, error) { parsed, err := url.Parse("/plugins/events-log/events/") if err != nil { return "", err } query := parsed.Query() if !options.From.IsZero() { query.Set("t1", options.From.Format("2006-01-02 15:04:05")) } if !options.To.IsZe...
[ "func", "(", "events", "*", "EventsLogService", ")", "getURL", "(", "options", "*", "EventsLogOptions", ")", "(", "string", ",", "error", ")", "{", "parsed", ",", "err", ":=", "url", ".", "Parse", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil",...
// getURL returns the url that should be used in the request. This will vary // depending on the options provided to GetEvents.
[ "getURL", "returns", "the", "url", "that", "should", "be", "used", "in", "the", "request", ".", "This", "will", "vary", "depending", "on", "the", "options", "provided", "to", "GetEvents", "." ]
174420ebee6cb397f25bd5623b250cff9e5aec9a
https://github.com/andygrunwald/go-gerrit/blob/174420ebee6cb397f25bd5623b250cff9e5aec9a/events.go#L89-L111
137,220
andygrunwald/go-gerrit
groups.go
getGroupInfoResponse
func (s *GroupsService) getGroupInfoResponse(u string) (*GroupInfo, *Response, error) { req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } v := new(GroupInfo) resp, err := s.client.Do(req, v) if err != nil { return nil, resp, err } return v, resp, err }
go
func (s *GroupsService) getGroupInfoResponse(u string) (*GroupInfo, *Response, error) { req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } v := new(GroupInfo) resp, err := s.client.Do(req, v) if err != nil { return nil, resp, err } return v, resp, err }
[ "func", "(", "s", "*", "GroupsService", ")", "getGroupInfoResponse", "(", "u", "string", ")", "(", "*", "GroupInfo", ",", "*", "Response", ",", "error", ")", "{", "req", ",", "err", ":=", "s", ".", "client", ".", "NewRequest", "(", "\"", "\"", ",", ...
// getGroupInfoResponse retrieved a single GroupInfo Response for a GET request
[ "getGroupInfoResponse", "retrieved", "a", "single", "GroupInfo", "Response", "for", "a", "GET", "request" ]
174420ebee6cb397f25bd5623b250cff9e5aec9a
https://github.com/andygrunwald/go-gerrit/blob/174420ebee6cb397f25bd5623b250cff9e5aec9a/groups.go#L130-L143
137,221
andygrunwald/go-gerrit
types.go
MarshalJSON
func (t Timestamp) MarshalJSON() ([]byte, error) { if t.Location() != time.UTC { return nil, errors.New("Timestamp.MarshalJSON: time zone must be UTC") } if y := t.Year(); y < 0 || 9999 < y { // RFC 3339 is clear that years are 4 digits exactly. // See golang.org/issue/4556#issuecomment-66073163 for more discu...
go
func (t Timestamp) MarshalJSON() ([]byte, error) { if t.Location() != time.UTC { return nil, errors.New("Timestamp.MarshalJSON: time zone must be UTC") } if y := t.Year(); y < 0 || 9999 < y { // RFC 3339 is clear that years are 4 digits exactly. // See golang.org/issue/4556#issuecomment-66073163 for more discu...
[ "func", "(", "t", "Timestamp", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "t", ".", "Location", "(", ")", "!=", "time", ".", "UTC", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", ...
// MarshalJSON implements the json.Marshaler interface. // The time is a quoted string in Gerrit's timestamp format. // An error is returned if t.Time time zone is not UTC.
[ "MarshalJSON", "implements", "the", "json", ".", "Marshaler", "interface", ".", "The", "time", "is", "a", "quoted", "string", "in", "Gerrit", "s", "timestamp", "format", ".", "An", "error", "is", "returned", "if", "t", ".", "Time", "time", "zone", "is", ...
174420ebee6cb397f25bd5623b250cff9e5aec9a
https://github.com/andygrunwald/go-gerrit/blob/174420ebee6cb397f25bd5623b250cff9e5aec9a/types.go#L23-L37
137,222
andygrunwald/go-gerrit
types.go
UnmarshalJSON
func (t *Timestamp) UnmarshalJSON(b []byte) error { // Ignore null, like in the main JSON package. if string(b) == "null" { return nil } var err error t.Time, err = time.Parse(`"`+timeLayout+`"`, string(b)) return err }
go
func (t *Timestamp) UnmarshalJSON(b []byte) error { // Ignore null, like in the main JSON package. if string(b) == "null" { return nil } var err error t.Time, err = time.Parse(`"`+timeLayout+`"`, string(b)) return err }
[ "func", "(", "t", "*", "Timestamp", ")", "UnmarshalJSON", "(", "b", "[", "]", "byte", ")", "error", "{", "// Ignore null, like in the main JSON package.", "if", "string", "(", "b", ")", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n", "var", "err...
// UnmarshalJSON implements the json.Unmarshaler interface. // The time is expected to be a quoted string in Gerrit's timestamp format.
[ "UnmarshalJSON", "implements", "the", "json", ".", "Unmarshaler", "interface", ".", "The", "time", "is", "expected", "to", "be", "a", "quoted", "string", "in", "Gerrit", "s", "timestamp", "format", "." ]
174420ebee6cb397f25bd5623b250cff9e5aec9a
https://github.com/andygrunwald/go-gerrit/blob/174420ebee6cb397f25bd5623b250cff9e5aec9a/types.go#L41-L49
137,223
andygrunwald/go-gerrit
gerrit.go
checkAuth
func checkAuth(client *Client) (bool, error) { _, response, err := client.Accounts.GetAccount("self") switch err { case ErrWWWAuthenticateHeaderMissing: return false, nil case ErrWWWAuthenticateHeaderNotDigest: return false, nil default: // Response could be nil if the connection outright failed // or some...
go
func checkAuth(client *Client) (bool, error) { _, response, err := client.Accounts.GetAccount("self") switch err { case ErrWWWAuthenticateHeaderMissing: return false, nil case ErrWWWAuthenticateHeaderNotDigest: return false, nil default: // Response could be nil if the connection outright failed // or some...
[ "func", "checkAuth", "(", "client", "*", "Client", ")", "(", "bool", ",", "error", ")", "{", "_", ",", "response", ",", "err", ":=", "client", ".", "Accounts", ".", "GetAccount", "(", "\"", "\"", ")", "\n", "switch", "err", "{", "case", "ErrWWWAuthen...
// checkAuth is used by NewClient to check if the current credentials are // valid. If the response is 401 Unauthorized then the error will be discarded.
[ "checkAuth", "is", "used", "by", "NewClient", "to", "check", "if", "the", "current", "credentials", "are", "valid", ".", "If", "the", "response", "is", "401", "Unauthorized", "then", "the", "error", "will", "be", "discarded", "." ]
174420ebee6cb397f25bd5623b250cff9e5aec9a
https://github.com/andygrunwald/go-gerrit/blob/174420ebee6cb397f25bd5623b250cff9e5aec9a/gerrit.go#L193-L212
137,224
andygrunwald/go-gerrit
gerrit.go
NewRequest
func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error) { // Build URL for request u, err := c.buildURLForRequest(urlStr) if err != nil { return nil, err } var buf io.ReadWriter if body != nil { buf = new(bytes.Buffer) err = json.NewEncoder(buf).Encode(body) if err != ...
go
func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error) { // Build URL for request u, err := c.buildURLForRequest(urlStr) if err != nil { return nil, err } var buf io.ReadWriter if body != nil { buf = new(bytes.Buffer) err = json.NewEncoder(buf).Encode(body) if err != ...
[ "func", "(", "c", "*", "Client", ")", "NewRequest", "(", "method", ",", "urlStr", "string", ",", "body", "interface", "{", "}", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "// Build URL for request", "u", ",", "err", ":=", "c", "."...
// NewRequest creates an API request. // A relative URL can be provided in urlStr, in which case it is resolved relative to the baseURL of the Client. // Relative URLs should always be specified without a preceding slash. // If specified, the value pointed to by body is JSON encoded and included as the request body.
[ "NewRequest", "creates", "an", "API", "request", ".", "A", "relative", "URL", "can", "be", "provided", "in", "urlStr", "in", "which", "case", "it", "is", "resolved", "relative", "to", "the", "baseURL", "of", "the", "Client", ".", "Relative", "URLs", "shoul...
174420ebee6cb397f25bd5623b250cff9e5aec9a
https://github.com/andygrunwald/go-gerrit/blob/174420ebee6cb397f25bd5623b250cff9e5aec9a/gerrit.go#L218-L254
137,225
andygrunwald/go-gerrit
gerrit.go
NewRawPutRequest
func (c *Client) NewRawPutRequest(urlStr string, body string) (*http.Request, error) { // Build URL for request u, err := c.buildURLForRequest(urlStr) if err != nil { return nil, err } buf := bytes.NewBuffer([]byte(body)) req, err := http.NewRequest("PUT", u, buf) if err != nil { return nil, err } // App...
go
func (c *Client) NewRawPutRequest(urlStr string, body string) (*http.Request, error) { // Build URL for request u, err := c.buildURLForRequest(urlStr) if err != nil { return nil, err } buf := bytes.NewBuffer([]byte(body)) req, err := http.NewRequest("PUT", u, buf) if err != nil { return nil, err } // App...
[ "func", "(", "c", "*", "Client", ")", "NewRawPutRequest", "(", "urlStr", "string", ",", "body", "string", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "// Build URL for request", "u", ",", "err", ":=", "c", ".", "buildURLForRequest", "(...
// NewRawPutRequest creates a raw PUT request and makes no attempt to encode // or marshal the body. Just passes it straight through.
[ "NewRawPutRequest", "creates", "a", "raw", "PUT", "request", "and", "makes", "no", "attempt", "to", "encode", "or", "marshal", "the", "body", ".", "Just", "passes", "it", "straight", "through", "." ]
174420ebee6cb397f25bd5623b250cff9e5aec9a
https://github.com/andygrunwald/go-gerrit/blob/174420ebee6cb397f25bd5623b250cff9e5aec9a/gerrit.go#L258-L286
137,226
andygrunwald/go-gerrit
gerrit.go
DeleteRequest
func (c *Client) DeleteRequest(urlStr string, body interface{}) (*Response, error) { req, err := c.NewRequest("DELETE", urlStr, body) if err != nil { return nil, err } return c.Do(req, nil) }
go
func (c *Client) DeleteRequest(urlStr string, body interface{}) (*Response, error) { req, err := c.NewRequest("DELETE", urlStr, body) if err != nil { return nil, err } return c.Do(req, nil) }
[ "func", "(", "c", "*", "Client", ")", "DeleteRequest", "(", "urlStr", "string", ",", "body", "interface", "{", "}", ")", "(", "*", "Response", ",", "error", ")", "{", "req", ",", "err", ":=", "c", ".", "NewRequest", "(", "\"", "\"", ",", "urlStr", ...
// DeleteRequest sends an DELETE API Request to urlStr with optional body. // It is a shorthand combination for Client.NewRequest with Client.Do. // // Relative URLs should always be specified without a preceding slash. // If specified, the value pointed to by body is JSON encoded and included as the request body.
[ "DeleteRequest", "sends", "an", "DELETE", "API", "Request", "to", "urlStr", "with", "optional", "body", ".", "It", "is", "a", "shorthand", "combination", "for", "Client", ".", "NewRequest", "with", "Client", ".", "Do", ".", "Relative", "URLs", "should", "alw...
174420ebee6cb397f25bd5623b250cff9e5aec9a
https://github.com/andygrunwald/go-gerrit/blob/174420ebee6cb397f25bd5623b250cff9e5aec9a/gerrit.go#L449-L456
137,227
andygrunwald/go-gerrit
gerrit.go
getStringResponseWithoutOptions
func getStringResponseWithoutOptions(client *Client, u string) (string, *Response, error) { v := new(string) resp, err := client.Call("GET", u, nil, v) return *v, resp, err }
go
func getStringResponseWithoutOptions(client *Client, u string) (string, *Response, error) { v := new(string) resp, err := client.Call("GET", u, nil, v) return *v, resp, err }
[ "func", "getStringResponseWithoutOptions", "(", "client", "*", "Client", ",", "u", "string", ")", "(", "string", ",", "*", "Response", ",", "error", ")", "{", "v", ":=", "new", "(", "string", ")", "\n", "resp", ",", "err", ":=", "client", ".", "Call", ...
// getStringResponseWithoutOptions retrieved a single string Response for a GET request
[ "getStringResponseWithoutOptions", "retrieved", "a", "single", "string", "Response", "for", "a", "GET", "request" ]
174420ebee6cb397f25bd5623b250cff9e5aec9a
https://github.com/andygrunwald/go-gerrit/blob/174420ebee6cb397f25bd5623b250cff9e5aec9a/gerrit.go#L560-L564
137,228
andygrunwald/go-gerrit
authentication.go
SetBasicAuth
func (s *AuthenticationService) SetBasicAuth(username, password string) { s.name = username s.secret = password s.authType = authTypeBasic }
go
func (s *AuthenticationService) SetBasicAuth(username, password string) { s.name = username s.secret = password s.authType = authTypeBasic }
[ "func", "(", "s", "*", "AuthenticationService", ")", "SetBasicAuth", "(", "username", ",", "password", "string", ")", "{", "s", ".", "name", "=", "username", "\n", "s", ".", "secret", "=", "password", "\n", "s", ".", "authType", "=", "authTypeBasic", "\n...
// SetBasicAuth sets basic parameters for HTTP Basic auth
[ "SetBasicAuth", "sets", "basic", "parameters", "for", "HTTP", "Basic", "auth" ]
174420ebee6cb397f25bd5623b250cff9e5aec9a
https://github.com/andygrunwald/go-gerrit/blob/174420ebee6cb397f25bd5623b250cff9e5aec9a/authentication.go#L49-L53
137,229
andygrunwald/go-gerrit
authentication.go
SetDigestAuth
func (s *AuthenticationService) SetDigestAuth(username, password string) { s.name = username s.secret = password s.authType = authTypeDigest }
go
func (s *AuthenticationService) SetDigestAuth(username, password string) { s.name = username s.secret = password s.authType = authTypeDigest }
[ "func", "(", "s", "*", "AuthenticationService", ")", "SetDigestAuth", "(", "username", ",", "password", "string", ")", "{", "s", ".", "name", "=", "username", "\n", "s", ".", "secret", "=", "password", "\n", "s", ".", "authType", "=", "authTypeDigest", "...
// SetDigestAuth sets digest parameters for HTTP Digest auth.
[ "SetDigestAuth", "sets", "digest", "parameters", "for", "HTTP", "Digest", "auth", "." ]
174420ebee6cb397f25bd5623b250cff9e5aec9a
https://github.com/andygrunwald/go-gerrit/blob/174420ebee6cb397f25bd5623b250cff9e5aec9a/authentication.go#L56-L60
137,230
andygrunwald/go-gerrit
authentication.go
SetCookieAuth
func (s *AuthenticationService) SetCookieAuth(name, value string) { s.name = name s.secret = value s.authType = authTypeCookie }
go
func (s *AuthenticationService) SetCookieAuth(name, value string) { s.name = name s.secret = value s.authType = authTypeCookie }
[ "func", "(", "s", "*", "AuthenticationService", ")", "SetCookieAuth", "(", "name", ",", "value", "string", ")", "{", "s", ".", "name", "=", "name", "\n", "s", ".", "secret", "=", "value", "\n", "s", ".", "authType", "=", "authTypeCookie", "\n", "}" ]
// SetCookieAuth sets basic parameters for HTTP Cookie
[ "SetCookieAuth", "sets", "basic", "parameters", "for", "HTTP", "Cookie" ]
174420ebee6cb397f25bd5623b250cff9e5aec9a
https://github.com/andygrunwald/go-gerrit/blob/174420ebee6cb397f25bd5623b250cff9e5aec9a/authentication.go#L156-L160
137,231
andygrunwald/go-gerrit
changes.go
getChangeInfoResponse
func (s *ChangesService) getChangeInfoResponse(u string, opt *ChangeOptions) (*ChangeInfo, *Response, error) { u, err := addOptions(u, opt) if err != nil { return nil, nil, err } req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } v := new(ChangeInfo) resp, err := s.clien...
go
func (s *ChangesService) getChangeInfoResponse(u string, opt *ChangeOptions) (*ChangeInfo, *Response, error) { u, err := addOptions(u, opt) if err != nil { return nil, nil, err } req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } v := new(ChangeInfo) resp, err := s.clien...
[ "func", "(", "s", "*", "ChangesService", ")", "getChangeInfoResponse", "(", "u", "string", ",", "opt", "*", "ChangeOptions", ")", "(", "*", "ChangeInfo", ",", "*", "Response", ",", "error", ")", "{", "u", ",", "err", ":=", "addOptions", "(", "u", ",", ...
// getChangeInfoResponse retrieved a single ChangeInfo Response for a GET request
[ "getChangeInfoResponse", "retrieved", "a", "single", "ChangeInfo", "Response", "for", "a", "GET", "request" ]
174420ebee6cb397f25bd5623b250cff9e5aec9a
https://github.com/andygrunwald/go-gerrit/blob/174420ebee6cb397f25bd5623b250cff9e5aec9a/changes.go#L506-L524
137,232
andygrunwald/go-gerrit
changes.go
getCommentInfoMapResponse
func (s *ChangesService) getCommentInfoMapResponse(u string) (*map[string][]CommentInfo, *Response, error) { req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } v := new(map[string][]CommentInfo) resp, err := s.client.Do(req, v) if err != nil { return nil, resp, err } ret...
go
func (s *ChangesService) getCommentInfoMapResponse(u string) (*map[string][]CommentInfo, *Response, error) { req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } v := new(map[string][]CommentInfo) resp, err := s.client.Do(req, v) if err != nil { return nil, resp, err } ret...
[ "func", "(", "s", "*", "ChangesService", ")", "getCommentInfoMapResponse", "(", "u", "string", ")", "(", "*", "map", "[", "string", "]", "[", "]", "CommentInfo", ",", "*", "Response", ",", "error", ")", "{", "req", ",", "err", ":=", "s", ".", "client...
// getCommentInfoMapResponse retrieved a map of CommentInfo Response for a GET request
[ "getCommentInfoMapResponse", "retrieved", "a", "map", "of", "CommentInfo", "Response", "for", "a", "GET", "request" ]
174420ebee6cb397f25bd5623b250cff9e5aec9a
https://github.com/andygrunwald/go-gerrit/blob/174420ebee6cb397f25bd5623b250cff9e5aec9a/changes.go#L596-L609
137,233
andygrunwald/go-gerrit
changes.go
change
func (s *ChangesService) change(tail string, changeID string, input interface{}) (*ChangeInfo, *Response, error) { u := fmt.Sprintf("changes/%s/%s", changeID, tail) req, err := s.client.NewRequest("POST", u, input) if err != nil { return nil, nil, err } v := new(ChangeInfo) resp, err := s.client.Do(req, v) if...
go
func (s *ChangesService) change(tail string, changeID string, input interface{}) (*ChangeInfo, *Response, error) { u := fmt.Sprintf("changes/%s/%s", changeID, tail) req, err := s.client.NewRequest("POST", u, input) if err != nil { return nil, nil, err } v := new(ChangeInfo) resp, err := s.client.Do(req, v) if...
[ "func", "(", "s", "*", "ChangesService", ")", "change", "(", "tail", "string", ",", "changeID", "string", ",", "input", "interface", "{", "}", ")", "(", "*", "ChangeInfo", ",", "*", "Response", ",", "error", ")", "{", "u", ":=", "fmt", ".", "Sprintf"...
// change is an internal function to consolidate code used by SubmitChange, // AbandonChange and other similar functions.
[ "change", "is", "an", "internal", "function", "to", "consolidate", "code", "used", "by", "SubmitChange", "AbandonChange", "and", "other", "similar", "functions", "." ]
174420ebee6cb397f25bd5623b250cff9e5aec9a
https://github.com/andygrunwald/go-gerrit/blob/174420ebee6cb397f25bd5623b250cff9e5aec9a/changes.go#L774-L794
137,234
gobuffalo/suite
suite.go
NewAction
func NewAction(app *buffalo.App) *Action { as := &Action{ App: app, Model: NewModel(), } return as }
go
func NewAction(app *buffalo.App) *Action { as := &Action{ App: app, Model: NewModel(), } return as }
[ "func", "NewAction", "(", "app", "*", "buffalo", ".", "App", ")", "*", "Action", "{", "as", ":=", "&", "Action", "{", "App", ":", "app", ",", "Model", ":", "NewModel", "(", ")", ",", "}", "\n", "return", "as", "\n", "}" ]
// NewAction returns new Action for given buffalo.App
[ "NewAction", "returns", "new", "Action", "for", "given", "buffalo", ".", "App" ]
917e29a4226b0b4d66176c8db37947b73eb22623
https://github.com/gobuffalo/suite/blob/917e29a4226b0b4d66176c8db37947b73eb22623/suite.go#L22-L28
137,235
evalphobia/logrus_fluent
reflect.go
ConvertToValue
func ConvertToValue(p interface{}, tagName string) interface{} { rv := toValue(p) switch rv.Kind() { case reflect.Struct: return convertFromStruct(rv.Interface(), tagName) case reflect.Map: return convertFromMap(rv, tagName) case reflect.Slice: return convertFromSlice(rv, tagName) case reflect.Chan: retur...
go
func ConvertToValue(p interface{}, tagName string) interface{} { rv := toValue(p) switch rv.Kind() { case reflect.Struct: return convertFromStruct(rv.Interface(), tagName) case reflect.Map: return convertFromMap(rv, tagName) case reflect.Slice: return convertFromSlice(rv, tagName) case reflect.Chan: retur...
[ "func", "ConvertToValue", "(", "p", "interface", "{", "}", ",", "tagName", "string", ")", "interface", "{", "}", "{", "rv", ":=", "toValue", "(", "p", ")", "\n", "switch", "rv", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Struct", ":", "re...
// ConvertToValue make map data from struct and tags
[ "ConvertToValue", "make", "map", "data", "from", "struct", "and", "tags" ]
7275750c56535517a5a7cb7603d40ffcfd0aa144
https://github.com/evalphobia/logrus_fluent/blob/7275750c56535517a5a7cb7603d40ffcfd0aa144/reflect.go#L10-L26
137,236
evalphobia/logrus_fluent
reflect.go
toValue
func toValue(p interface{}) reflect.Value { v := reflect.ValueOf(p) if v.Kind() == reflect.Ptr { v = v.Elem() } return v }
go
func toValue(p interface{}) reflect.Value { v := reflect.ValueOf(p) if v.Kind() == reflect.Ptr { v = v.Elem() } return v }
[ "func", "toValue", "(", "p", "interface", "{", "}", ")", "reflect", ".", "Value", "{", "v", ":=", "reflect", ".", "ValueOf", "(", "p", ")", "\n", "if", "v", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "v", "=", "v", ".", "Elem", ...
// toValue converts any value to reflect.Value
[ "toValue", "converts", "any", "value", "to", "reflect", ".", "Value" ]
7275750c56535517a5a7cb7603d40ffcfd0aa144
https://github.com/evalphobia/logrus_fluent/blob/7275750c56535517a5a7cb7603d40ffcfd0aa144/reflect.go#L97-L103
137,237
evalphobia/logrus_fluent
reflect.go
toType
func toType(p interface{}) reflect.Type { t := reflect.ValueOf(p).Type() if t.Kind() == reflect.Ptr { t = t.Elem() } return t }
go
func toType(p interface{}) reflect.Type { t := reflect.ValueOf(p).Type() if t.Kind() == reflect.Ptr { t = t.Elem() } return t }
[ "func", "toType", "(", "p", "interface", "{", "}", ")", "reflect", ".", "Type", "{", "t", ":=", "reflect", ".", "ValueOf", "(", "p", ")", ".", "Type", "(", ")", "\n", "if", "t", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "t", "=...
// toType converts any value to reflect.Type
[ "toType", "converts", "any", "value", "to", "reflect", ".", "Type" ]
7275750c56535517a5a7cb7603d40ffcfd0aa144
https://github.com/evalphobia/logrus_fluent/blob/7275750c56535517a5a7cb7603d40ffcfd0aa144/reflect.go#L106-L112
137,238
evalphobia/logrus_fluent
reflect.go
isZero
func isZero(v reflect.Value) bool { zero := reflect.Zero(v.Type()).Interface() value := v.Interface() return reflect.DeepEqual(value, zero) }
go
func isZero(v reflect.Value) bool { zero := reflect.Zero(v.Type()).Interface() value := v.Interface() return reflect.DeepEqual(value, zero) }
[ "func", "isZero", "(", "v", "reflect", ".", "Value", ")", "bool", "{", "zero", ":=", "reflect", ".", "Zero", "(", "v", ".", "Type", "(", ")", ")", ".", "Interface", "(", ")", "\n", "value", ":=", "v", ".", "Interface", "(", ")", "\n", "return", ...
// isZero checks the value is zero-value or not
[ "isZero", "checks", "the", "value", "is", "zero", "-", "value", "or", "not" ]
7275750c56535517a5a7cb7603d40ffcfd0aa144
https://github.com/evalphobia/logrus_fluent/blob/7275750c56535517a5a7cb7603d40ffcfd0aa144/reflect.go#L115-L119
137,239
evalphobia/logrus_fluent
reflect.go
getNameFromTag
func getNameFromTag(f reflect.StructField, tagName string) string { tag, _ := parseTag(f, tagName) if tag != "" { return tag } return f.Name }
go
func getNameFromTag(f reflect.StructField, tagName string) string { tag, _ := parseTag(f, tagName) if tag != "" { return tag } return f.Name }
[ "func", "getNameFromTag", "(", "f", "reflect", ".", "StructField", ",", "tagName", "string", ")", "string", "{", "tag", ",", "_", ":=", "parseTag", "(", "f", ",", "tagName", ")", "\n", "if", "tag", "!=", "\"", "\"", "{", "return", "tag", "\n", "}", ...
// getNameFromTag return the value in tag or field name in the struct field
[ "getNameFromTag", "return", "the", "value", "in", "tag", "or", "field", "name", "in", "the", "struct", "field" ]
7275750c56535517a5a7cb7603d40ffcfd0aa144
https://github.com/evalphobia/logrus_fluent/blob/7275750c56535517a5a7cb7603d40ffcfd0aa144/reflect.go#L122-L128
137,240
evalphobia/logrus_fluent
reflect.go
getTagValues
func getTagValues(f reflect.StructField, tag string) string { return f.Tag.Get(tag) }
go
func getTagValues(f reflect.StructField, tag string) string { return f.Tag.Get(tag) }
[ "func", "getTagValues", "(", "f", "reflect", ".", "StructField", ",", "tag", "string", ")", "string", "{", "return", "f", ".", "Tag", ".", "Get", "(", "tag", ")", "\n", "}" ]
// getTagValues returns tag value of the struct field
[ "getTagValues", "returns", "tag", "value", "of", "the", "struct", "field" ]
7275750c56535517a5a7cb7603d40ffcfd0aa144
https://github.com/evalphobia/logrus_fluent/blob/7275750c56535517a5a7cb7603d40ffcfd0aa144/reflect.go#L131-L133
137,241
evalphobia/logrus_fluent
reflect.go
parseTag
func parseTag(f reflect.StructField, tag string) (string, options) { return splitTags(getTagValues(f, tag)) }
go
func parseTag(f reflect.StructField, tag string) (string, options) { return splitTags(getTagValues(f, tag)) }
[ "func", "parseTag", "(", "f", "reflect", ".", "StructField", ",", "tag", "string", ")", "(", "string", ",", "options", ")", "{", "return", "splitTags", "(", "getTagValues", "(", "f", ",", "tag", ")", ")", "\n", "}" ]
// parseTag returns the first tag value of the struct field
[ "parseTag", "returns", "the", "first", "tag", "value", "of", "the", "struct", "field" ]
7275750c56535517a5a7cb7603d40ffcfd0aa144
https://github.com/evalphobia/logrus_fluent/blob/7275750c56535517a5a7cb7603d40ffcfd0aa144/reflect.go#L136-L138
137,242
evalphobia/logrus_fluent
reflect.go
splitTags
func splitTags(tags string) (string, options) { res := strings.Split(tags, ",") return res[0], res[1:] }
go
func splitTags(tags string) (string, options) { res := strings.Split(tags, ",") return res[0], res[1:] }
[ "func", "splitTags", "(", "tags", "string", ")", "(", "string", ",", "options", ")", "{", "res", ":=", "strings", ".", "Split", "(", "tags", ",", "\"", "\"", ")", "\n", "return", "res", "[", "0", "]", ",", "res", "[", "1", ":", "]", "\n", "}" ]
// splitTags returns the first tag value and rest slice
[ "splitTags", "returns", "the", "first", "tag", "value", "and", "rest", "slice" ]
7275750c56535517a5a7cb7603d40ffcfd0aa144
https://github.com/evalphobia/logrus_fluent/blob/7275750c56535517a5a7cb7603d40ffcfd0aa144/reflect.go#L141-L144
137,243
evalphobia/logrus_fluent
reflect.go
Has
func (t options) Has(tag string) bool { for _, opt := range t { if opt == tag { return true } } return false }
go
func (t options) Has(tag string) bool { for _, opt := range t { if opt == tag { return true } } return false }
[ "func", "(", "t", "options", ")", "Has", "(", "tag", "string", ")", "bool", "{", "for", "_", ",", "opt", ":=", "range", "t", "{", "if", "opt", "==", "tag", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// Has checks the value exists in the rest values or not
[ "Has", "checks", "the", "value", "exists", "in", "the", "rest", "values", "or", "not" ]
7275750c56535517a5a7cb7603d40ffcfd0aa144
https://github.com/evalphobia/logrus_fluent/blob/7275750c56535517a5a7cb7603d40ffcfd0aa144/reflect.go#L150-L157
137,244
evalphobia/logrus_fluent
filter.go
FilterError
func FilterError(v interface{}) interface{} { if err, ok := v.(error); ok { return err.Error() } return v }
go
func FilterError(v interface{}) interface{} { if err, ok := v.(error); ok { return err.Error() } return v }
[ "func", "FilterError", "(", "v", "interface", "{", "}", ")", "interface", "{", "}", "{", "if", "err", ",", "ok", ":=", "v", ".", "(", "error", ")", ";", "ok", "{", "return", "err", ".", "Error", "(", ")", "\n", "}", "\n", "return", "v", "\n", ...
// FilterError is a filter function to convert error type to string type.
[ "FilterError", "is", "a", "filter", "function", "to", "convert", "error", "type", "to", "string", "type", "." ]
7275750c56535517a5a7cb7603d40ffcfd0aa144
https://github.com/evalphobia/logrus_fluent/blob/7275750c56535517a5a7cb7603d40ffcfd0aa144/filter.go#L4-L9
137,245
evalphobia/logrus_fluent
fluent.go
New
func New(host string, port int) (*FluentHook, error) { return NewWithConfig(Config{ Host: host, Port: port, DefaultMessageField: MessageField, }) }
go
func New(host string, port int) (*FluentHook, error) { return NewWithConfig(Config{ Host: host, Port: port, DefaultMessageField: MessageField, }) }
[ "func", "New", "(", "host", "string", ",", "port", "int", ")", "(", "*", "FluentHook", ",", "error", ")", "{", "return", "NewWithConfig", "(", "Config", "{", "Host", ":", "host", ",", "Port", ":", "port", ",", "DefaultMessageField", ":", "MessageField", ...
// New returns initialized logrus hook for fluentd with persistent fluentd logger.
[ "New", "returns", "initialized", "logrus", "hook", "for", "fluentd", "with", "persistent", "fluentd", "logger", "." ]
7275750c56535517a5a7cb7603d40ffcfd0aa144
https://github.com/evalphobia/logrus_fluent/blob/7275750c56535517a5a7cb7603d40ffcfd0aa144/fluent.go#L50-L56
137,246
evalphobia/logrus_fluent
fluent.go
NewWithConfig
func NewWithConfig(conf Config) (*FluentHook, error) { var fd *fluent.Fluent if !conf.DisableConnectionPool { var err error fd, err = fluent.New(conf.FluentConfig()) if err != nil { return nil, err } } hook := &FluentHook{ Fluent: fd, conf: conf, levels: conf.LogLevels, ignor...
go
func NewWithConfig(conf Config) (*FluentHook, error) { var fd *fluent.Fluent if !conf.DisableConnectionPool { var err error fd, err = fluent.New(conf.FluentConfig()) if err != nil { return nil, err } } hook := &FluentHook{ Fluent: fd, conf: conf, levels: conf.LogLevels, ignor...
[ "func", "NewWithConfig", "(", "conf", "Config", ")", "(", "*", "FluentHook", ",", "error", ")", "{", "var", "fd", "*", "fluent", ".", "Fluent", "\n", "if", "!", "conf", ".", "DisableConnectionPool", "{", "var", "err", "error", "\n", "fd", ",", "err", ...
// NewWithConfig returns initialized logrus hook by config setting.
[ "NewWithConfig", "returns", "initialized", "logrus", "hook", "by", "config", "setting", "." ]
7275750c56535517a5a7cb7603d40ffcfd0aa144
https://github.com/evalphobia/logrus_fluent/blob/7275750c56535517a5a7cb7603d40ffcfd0aa144/fluent.go#L59-L95
137,247
evalphobia/logrus_fluent
fluent.go
Fire
func (hook *FluentHook) Fire(entry *logrus.Entry) error { var logger *fluent.Fluent var err error switch { case hook.Fluent != nil: logger = hook.Fluent default: logger, err = fluent.New(hook.conf.FluentConfig()) if err != nil { return err } defer logger.Close() } // Create a map for passing to Fl...
go
func (hook *FluentHook) Fire(entry *logrus.Entry) error { var logger *fluent.Fluent var err error switch { case hook.Fluent != nil: logger = hook.Fluent default: logger, err = fluent.New(hook.conf.FluentConfig()) if err != nil { return err } defer logger.Close() } // Create a map for passing to Fl...
[ "func", "(", "hook", "*", "FluentHook", ")", "Fire", "(", "entry", "*", "logrus", ".", "Entry", ")", "error", "{", "var", "logger", "*", "fluent", ".", "Fluent", "\n", "var", "err", "error", "\n\n", "switch", "{", "case", "hook", ".", "Fluent", "!=",...
// Fire is invoked by logrus and sends log to fluentd logger.
[ "Fire", "is", "invoked", "by", "logrus", "and", "sends", "log", "to", "fluentd", "logger", "." ]
7275750c56535517a5a7cb7603d40ffcfd0aa144
https://github.com/evalphobia/logrus_fluent/blob/7275750c56535517a5a7cb7603d40ffcfd0aa144/fluent.go#L149-L185
137,248
evalphobia/logrus_fluent
fluent.go
getTagAndDel
func (hook *FluentHook) getTagAndDel(entry *logrus.Entry, data logrus.Fields) string { // use static tag from if hook.tag != nil { return *hook.tag } tagField, ok := data[TagField] if !ok { return entry.Message } tag, ok := tagField.(string) if !ok { return entry.Message } // remove tag from data fie...
go
func (hook *FluentHook) getTagAndDel(entry *logrus.Entry, data logrus.Fields) string { // use static tag from if hook.tag != nil { return *hook.tag } tagField, ok := data[TagField] if !ok { return entry.Message } tag, ok := tagField.(string) if !ok { return entry.Message } // remove tag from data fie...
[ "func", "(", "hook", "*", "FluentHook", ")", "getTagAndDel", "(", "entry", "*", "logrus", ".", "Entry", ",", "data", "logrus", ".", "Fields", ")", "string", "{", "// use static tag from", "if", "hook", ".", "tag", "!=", "nil", "{", "return", "*", "hook",...
// getTagAndDel extracts tag data from log entry and custom log fields. // 1. if tag is set in the hook, use it. // 2. if tag is set in custom fields, use it. // 3. if cannot find tag data, use entry.Message as tag.
[ "getTagAndDel", "extracts", "tag", "data", "from", "log", "entry", "and", "custom", "log", "fields", ".", "1", ".", "if", "tag", "is", "set", "in", "the", "hook", "use", "it", ".", "2", ".", "if", "tag", "is", "set", "in", "custom", "fields", "use", ...
7275750c56535517a5a7cb7603d40ffcfd0aa144
https://github.com/evalphobia/logrus_fluent/blob/7275750c56535517a5a7cb7603d40ffcfd0aa144/fluent.go#L191-L210
137,249
evalphobia/logrus_fluent
config.go
FluentConfig
func (c Config) FluentConfig() fluent.Config { return fluent.Config{ FluentPort: c.Port, FluentHost: c.Host, FluentNetwork: c.FluentNetwork, FluentSocketPath: c.FluentSocketPath, Timeout: c.Timeout, WriteTimeout: c.WriteTimeout, BufferLimit: c.BufferLimit, ...
go
func (c Config) FluentConfig() fluent.Config { return fluent.Config{ FluentPort: c.Port, FluentHost: c.Host, FluentNetwork: c.FluentNetwork, FluentSocketPath: c.FluentSocketPath, Timeout: c.Timeout, WriteTimeout: c.WriteTimeout, BufferLimit: c.BufferLimit, ...
[ "func", "(", "c", "Config", ")", "FluentConfig", "(", ")", "fluent", ".", "Config", "{", "return", "fluent", ".", "Config", "{", "FluentPort", ":", "c", ".", "Port", ",", "FluentHost", ":", "c", ".", "Host", ",", "FluentNetwork", ":", "c", ".", "Flue...
// FluentConfig converts data to fluent.Config.
[ "FluentConfig", "converts", "data", "to", "fluent", ".", "Config", "." ]
7275750c56535517a5a7cb7603d40ffcfd0aa144
https://github.com/evalphobia/logrus_fluent/blob/7275750c56535517a5a7cb7603d40ffcfd0aa144/config.go#L37-L53
137,250
gobwas/pool
generic.go
Custom
func Custom(opts ...Option) *Pool { p := &Pool{ pool: make(map[int]*sync.Pool), size: pmath.Identity, } c := (*poolConfig)(p) for _, opt := range opts { opt(c) } return p }
go
func Custom(opts ...Option) *Pool { p := &Pool{ pool: make(map[int]*sync.Pool), size: pmath.Identity, } c := (*poolConfig)(p) for _, opt := range opts { opt(c) } return p }
[ "func", "Custom", "(", "opts", "...", "Option", ")", "*", "Pool", "{", "p", ":=", "&", "Pool", "{", "pool", ":", "make", "(", "map", "[", "int", "]", "*", "sync", ".", "Pool", ")", ",", "size", ":", "pmath", ".", "Identity", ",", "}", "\n\n", ...
// Custom creates new Pool with given options.
[ "Custom", "creates", "new", "Pool", "with", "given", "options", "." ]
cd2fb0a117357da7830c32f332c8520db8e2827d
https://github.com/gobwas/pool/blob/cd2fb0a117357da7830c32f332c8520db8e2827d/generic.go#L45-L57
137,251
gobwas/pool
generic.go
Put
func (p *Pool) Put(x interface{}, size int) { if pool := p.pool[size]; pool != nil { pool.Put(x) } }
go
func (p *Pool) Put(x interface{}, size int) { if pool := p.pool[size]; pool != nil { pool.Put(x) } }
[ "func", "(", "p", "*", "Pool", ")", "Put", "(", "x", "interface", "{", "}", ",", "size", "int", ")", "{", "if", "pool", ":=", "p", ".", "pool", "[", "size", "]", ";", "pool", "!=", "nil", "{", "pool", ".", "Put", "(", "x", ")", "\n", "}", ...
// Put takes x and its size for future reuse.
[ "Put", "takes", "x", "and", "its", "size", "for", "future", "reuse", "." ]
cd2fb0a117357da7830c32f332c8520db8e2827d
https://github.com/gobwas/pool/blob/cd2fb0a117357da7830c32f332c8520db8e2827d/generic.go#L71-L75
137,252
gobwas/pool
generic.go
AddSize
func (p *poolConfig) AddSize(n int) { p.pool[n] = new(sync.Pool) }
go
func (p *poolConfig) AddSize(n int) { p.pool[n] = new(sync.Pool) }
[ "func", "(", "p", "*", "poolConfig", ")", "AddSize", "(", "n", "int", ")", "{", "p", ".", "pool", "[", "n", "]", "=", "new", "(", "sync", ".", "Pool", ")", "\n", "}" ]
// AddSize adds size n to the map.
[ "AddSize", "adds", "size", "n", "to", "the", "map", "." ]
cd2fb0a117357da7830c32f332c8520db8e2827d
https://github.com/gobwas/pool/blob/cd2fb0a117357da7830c32f332c8520db8e2827d/generic.go#L80-L82
137,253
gobwas/pool
pbytes/pool.go
GetLen
func (p *Pool) GetLen(n int) []byte { return p.Get(n, n) }
go
func (p *Pool) GetLen(n int) []byte { return p.Get(n, n) }
[ "func", "(", "p", "*", "Pool", ")", "GetLen", "(", "n", "int", ")", "[", "]", "byte", "{", "return", "p", ".", "Get", "(", "n", ",", "n", ")", "\n", "}" ]
// GetLen returns probably reused slice of bytes with at least capacity of n // and exactly len of n.
[ "GetLen", "returns", "probably", "reused", "slice", "of", "bytes", "with", "at", "least", "capacity", "of", "n", "and", "exactly", "len", "of", "n", "." ]
cd2fb0a117357da7830c32f332c8520db8e2827d
https://github.com/gobwas/pool/blob/cd2fb0a117357da7830c32f332c8520db8e2827d/pbytes/pool.go#L57-L59
137,254
gobwas/pool
pbufio/pbufio.go
Get
func (wp *WriterPool) Get(w io.Writer, size int) *bufio.Writer { v, n := wp.pool.Get(size) if v != nil { bw := v.(*bufio.Writer) bw.Reset(w) return bw } return bufio.NewWriterSize(w, n) }
go
func (wp *WriterPool) Get(w io.Writer, size int) *bufio.Writer { v, n := wp.pool.Get(size) if v != nil { bw := v.(*bufio.Writer) bw.Reset(w) return bw } return bufio.NewWriterSize(w, n) }
[ "func", "(", "wp", "*", "WriterPool", ")", "Get", "(", "w", "io", ".", "Writer", ",", "size", "int", ")", "*", "bufio", ".", "Writer", "{", "v", ",", "n", ":=", "wp", ".", "pool", ".", "Get", "(", "size", ")", "\n", "if", "v", "!=", "nil", ...
// Get returns bufio.Writer whose buffer has at least size bytes.
[ "Get", "returns", "bufio", ".", "Writer", "whose", "buffer", "has", "at", "least", "size", "bytes", "." ]
cd2fb0a117357da7830c32f332c8520db8e2827d
https://github.com/gobwas/pool/blob/cd2fb0a117357da7830c32f332c8520db8e2827d/pbufio/pbufio.go#L55-L63
137,255
gobwas/pool
pbufio/pbufio.go
Put
func (wp *WriterPool) Put(bw *bufio.Writer) { // Should reset even if we do Reset() inside Get(). // This is done to prevent locking underlying io.Writer from GC. bw.Reset(nil) wp.pool.Put(bw, writerSize(bw)) }
go
func (wp *WriterPool) Put(bw *bufio.Writer) { // Should reset even if we do Reset() inside Get(). // This is done to prevent locking underlying io.Writer from GC. bw.Reset(nil) wp.pool.Put(bw, writerSize(bw)) }
[ "func", "(", "wp", "*", "WriterPool", ")", "Put", "(", "bw", "*", "bufio", ".", "Writer", ")", "{", "// Should reset even if we do Reset() inside Get().", "// This is done to prevent locking underlying io.Writer from GC.", "bw", ".", "Reset", "(", "nil", ")", "\n", "w...
// Put takes ownership of bufio.Writer for further reuse.
[ "Put", "takes", "ownership", "of", "bufio", ".", "Writer", "for", "further", "reuse", "." ]
cd2fb0a117357da7830c32f332c8520db8e2827d
https://github.com/gobwas/pool/blob/cd2fb0a117357da7830c32f332c8520db8e2827d/pbufio/pbufio.go#L66-L71
137,256
gobwas/pool
pbufio/pbufio.go
Get
func (rp *ReaderPool) Get(r io.Reader, size int) *bufio.Reader { v, n := rp.pool.Get(size) if v != nil { br := v.(*bufio.Reader) br.Reset(r) return br } return bufio.NewReaderSize(r, n) }
go
func (rp *ReaderPool) Get(r io.Reader, size int) *bufio.Reader { v, n := rp.pool.Get(size) if v != nil { br := v.(*bufio.Reader) br.Reset(r) return br } return bufio.NewReaderSize(r, n) }
[ "func", "(", "rp", "*", "ReaderPool", ")", "Get", "(", "r", "io", ".", "Reader", ",", "size", "int", ")", "*", "bufio", ".", "Reader", "{", "v", ",", "n", ":=", "rp", ".", "pool", ".", "Get", "(", "size", ")", "\n", "if", "v", "!=", "nil", ...
// Get returns bufio.Reader whose buffer has at least size bytes.
[ "Get", "returns", "bufio", ".", "Reader", "whose", "buffer", "has", "at", "least", "size", "bytes", "." ]
cd2fb0a117357da7830c32f332c8520db8e2827d
https://github.com/gobwas/pool/blob/cd2fb0a117357da7830c32f332c8520db8e2827d/pbufio/pbufio.go#L90-L98
137,257
gobwas/pool
pbufio/pbufio.go
Put
func (rp *ReaderPool) Put(br *bufio.Reader) { // Should reset even if we do Reset() inside Get(). // This is done to prevent locking underlying io.Reader from GC. br.Reset(nil) rp.pool.Put(br, readerSize(br)) }
go
func (rp *ReaderPool) Put(br *bufio.Reader) { // Should reset even if we do Reset() inside Get(). // This is done to prevent locking underlying io.Reader from GC. br.Reset(nil) rp.pool.Put(br, readerSize(br)) }
[ "func", "(", "rp", "*", "ReaderPool", ")", "Put", "(", "br", "*", "bufio", ".", "Reader", ")", "{", "// Should reset even if we do Reset() inside Get().", "// This is done to prevent locking underlying io.Reader from GC.", "br", ".", "Reset", "(", "nil", ")", "\n", "r...
// Put takes ownership of bufio.Reader for further reuse.
[ "Put", "takes", "ownership", "of", "bufio", ".", "Reader", "for", "further", "reuse", "." ]
cd2fb0a117357da7830c32f332c8520db8e2827d
https://github.com/gobwas/pool/blob/cd2fb0a117357da7830c32f332c8520db8e2827d/pbufio/pbufio.go#L101-L106
137,258
gobwas/pool
internal/pmath/pmath.go
LogarithmicRange
func LogarithmicRange(min, max int, cb func(int)) { if min == 0 { min = 1 } for n := CeilToPowerOfTwo(min); n <= max; n <<= 1 { cb(n) } }
go
func LogarithmicRange(min, max int, cb func(int)) { if min == 0 { min = 1 } for n := CeilToPowerOfTwo(min); n <= max; n <<= 1 { cb(n) } }
[ "func", "LogarithmicRange", "(", "min", ",", "max", "int", ",", "cb", "func", "(", "int", ")", ")", "{", "if", "min", "==", "0", "{", "min", "=", "1", "\n", "}", "\n", "for", "n", ":=", "CeilToPowerOfTwo", "(", "min", ")", ";", "n", "<=", "max"...
// LogarithmicRange iterates from ceiled to power of two min to max, // calling cb on each iteration.
[ "LogarithmicRange", "iterates", "from", "ceiled", "to", "power", "of", "two", "min", "to", "max", "calling", "cb", "on", "each", "iteration", "." ]
cd2fb0a117357da7830c32f332c8520db8e2827d
https://github.com/gobwas/pool/blob/cd2fb0a117357da7830c32f332c8520db8e2827d/internal/pmath/pmath.go#L11-L18
137,259
gobwas/pool
internal/pmath/pmath.go
CeilToPowerOfTwo
func CeilToPowerOfTwo(n int) int { if n&maxintHeadBit != 0 && n > maxintHeadBit { panic("argument is too large") } if n <= 2 { return n } n-- n = fillBits(n) n++ return n }
go
func CeilToPowerOfTwo(n int) int { if n&maxintHeadBit != 0 && n > maxintHeadBit { panic("argument is too large") } if n <= 2 { return n } n-- n = fillBits(n) n++ return n }
[ "func", "CeilToPowerOfTwo", "(", "n", "int", ")", "int", "{", "if", "n", "&", "maxintHeadBit", "!=", "0", "&&", "n", ">", "maxintHeadBit", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "n", "<=", "2", "{", "return", "n", "\n", "}", ...
// CeilToPowerOfTwo returns the least power of two integer value greater than // or equal to n.
[ "CeilToPowerOfTwo", "returns", "the", "least", "power", "of", "two", "integer", "value", "greater", "than", "or", "equal", "to", "n", "." ]
cd2fb0a117357da7830c32f332c8520db8e2827d
https://github.com/gobwas/pool/blob/cd2fb0a117357da7830c32f332c8520db8e2827d/internal/pmath/pmath.go#L32-L43
137,260
gobwas/pool
internal/pmath/pmath.go
FloorToPowerOfTwo
func FloorToPowerOfTwo(n int) int { if n <= 2 { return n } n = fillBits(n) n >>= 1 n++ return n }
go
func FloorToPowerOfTwo(n int) int { if n <= 2 { return n } n = fillBits(n) n >>= 1 n++ return n }
[ "func", "FloorToPowerOfTwo", "(", "n", "int", ")", "int", "{", "if", "n", "<=", "2", "{", "return", "n", "\n", "}", "\n", "n", "=", "fillBits", "(", "n", ")", "\n", "n", ">>=", "1", "\n", "n", "++", "\n", "return", "n", "\n", "}" ]
// FloorToPowerOfTwo returns the greatest power of two integer value less than // or equal to n.
[ "FloorToPowerOfTwo", "returns", "the", "greatest", "power", "of", "two", "integer", "value", "less", "than", "or", "equal", "to", "n", "." ]
cd2fb0a117357da7830c32f332c8520db8e2827d
https://github.com/gobwas/pool/blob/cd2fb0a117357da7830c32f332c8520db8e2827d/internal/pmath/pmath.go#L47-L55
137,261
gobwas/pool
pbytes/pool_sanitize.go
Put
func (p *Pool) Put(bts []byte) { hdr := *(*reflect.SliceHeader)(unsafe.Pointer(&bts)) ptr := hdr.Data - uintptr(guardSize) g := (*guard)(unsafe.Pointer(ptr)) if g.magic != magic { panic("unknown slice returned to the pool") } if n := atomic.AddInt32(&g.owners, -1); n < 0 { panic("multiple Put() detected") }...
go
func (p *Pool) Put(bts []byte) { hdr := *(*reflect.SliceHeader)(unsafe.Pointer(&bts)) ptr := hdr.Data - uintptr(guardSize) g := (*guard)(unsafe.Pointer(ptr)) if g.magic != magic { panic("unknown slice returned to the pool") } if n := atomic.AddInt32(&g.owners, -1); n < 0 { panic("multiple Put() detected") }...
[ "func", "(", "p", "*", "Pool", ")", "Put", "(", "bts", "[", "]", "byte", ")", "{", "hdr", ":=", "*", "(", "*", "reflect", ".", "SliceHeader", ")", "(", "unsafe", ".", "Pointer", "(", "&", "bts", ")", ")", "\n", "ptr", ":=", "hdr", ".", "Data"...
// Put returns given slice to reuse pool.
[ "Put", "returns", "given", "slice", "to", "reuse", "pool", "." ]
cd2fb0a117357da7830c32f332c8520db8e2827d
https://github.com/gobwas/pool/blob/cd2fb0a117357da7830c32f332c8520db8e2827d/pbytes/pool_sanitize.go#L60-L84
137,262
Gurpartap/logrus-stack
logrus-stack-hook.go
Fire
func (hook LogrusStackHook) Fire(entry *logrus.Entry) error { var skipFrames int if len(entry.Data) == 0 { // When WithField(s) is not used, we have 8 logrus frames to skip. skipFrames = 8 } else { // When WithField(s) is used, we have 6 logrus frames to skip. skipFrames = 6 } var frames stack.Stack // ...
go
func (hook LogrusStackHook) Fire(entry *logrus.Entry) error { var skipFrames int if len(entry.Data) == 0 { // When WithField(s) is not used, we have 8 logrus frames to skip. skipFrames = 8 } else { // When WithField(s) is used, we have 6 logrus frames to skip. skipFrames = 6 } var frames stack.Stack // ...
[ "func", "(", "hook", "LogrusStackHook", ")", "Fire", "(", "entry", "*", "logrus", ".", "Entry", ")", "error", "{", "var", "skipFrames", "int", "\n", "if", "len", "(", "entry", ".", "Data", ")", "==", "0", "{", "// When WithField(s) is not used, we have 8 log...
// Fire is called by logrus when something is logged.
[ "Fire", "is", "called", "by", "logrus", "when", "something", "is", "logged", "." ]
89c00d8a28f43c567d92eb81a2945301a6a9fbb9
https://github.com/Gurpartap/logrus-stack/blob/89c00d8a28f43c567d92eb81a2945301a6a9fbb9/logrus-stack-hook.go#L47-L90
137,263
dimchansky/utfbom
utfbom.go
String
func (e Encoding) String() string { switch e { case UTF8: return "UTF8" case UTF16BigEndian: return "UTF16BigEndian" case UTF16LittleEndian: return "UTF16LittleEndian" case UTF32BigEndian: return "UTF32BigEndian" case UTF32LittleEndian: return "UTF32LittleEndian" default: return "Unknown" } }
go
func (e Encoding) String() string { switch e { case UTF8: return "UTF8" case UTF16BigEndian: return "UTF16BigEndian" case UTF16LittleEndian: return "UTF16LittleEndian" case UTF32BigEndian: return "UTF32BigEndian" case UTF32LittleEndian: return "UTF32LittleEndian" default: return "Unknown" } }
[ "func", "(", "e", "Encoding", ")", "String", "(", ")", "string", "{", "switch", "e", "{", "case", "UTF8", ":", "return", "\"", "\"", "\n", "case", "UTF16BigEndian", ":", "return", "\"", "\"", "\n", "case", "UTF16LittleEndian", ":", "return", "\"", "\""...
// String returns a user-friendly string representation of the encoding. Satisfies fmt.Stringer interface.
[ "String", "returns", "a", "user", "-", "friendly", "string", "representation", "of", "the", "encoding", ".", "Satisfies", "fmt", ".", "Stringer", "interface", "." ]
d2133a1ce379ef6fa992b0514a77146c60db9d1c
https://github.com/dimchansky/utfbom/blob/d2133a1ce379ef6fa992b0514a77146c60db9d1c/utfbom.go#L36-L51
137,264
dimchansky/utfbom
utfbom.go
Read
func (r *Reader) Read(p []byte) (n int, err error) { if len(p) == 0 { return 0, nil } if r.buf == nil { if r.err != nil { return 0, r.readErr() } return r.rd.Read(p) } // copy as much as we can n = copy(p, r.buf) r.buf = nilIfEmpty(r.buf[n:]) return n, nil }
go
func (r *Reader) Read(p []byte) (n int, err error) { if len(p) == 0 { return 0, nil } if r.buf == nil { if r.err != nil { return 0, r.readErr() } return r.rd.Read(p) } // copy as much as we can n = copy(p, r.buf) r.buf = nilIfEmpty(r.buf[n:]) return n, nil }
[ "func", "(", "r", "*", "Reader", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "if", "len", "(", "p", ")", "==", "0", "{", "return", "0", ",", "nil", "\n", "}", "\n\n", "if", "r", ".", "buf"...
// Read is an implementation of io.Reader interface. // The bytes are taken from the underlying Reader, but it checks for BOMs, removing them as necessary.
[ "Read", "is", "an", "implementation", "of", "io", ".", "Reader", "interface", ".", "The", "bytes", "are", "taken", "from", "the", "underlying", "Reader", "but", "it", "checks", "for", "BOMs", "removing", "them", "as", "necessary", "." ]
d2133a1ce379ef6fa992b0514a77146c60db9d1c
https://github.com/dimchansky/utfbom/blob/d2133a1ce379ef6fa992b0514a77146c60db9d1c/utfbom.go#L89-L106
137,265
FactomProject/factom
chain.go
ComposeChainCommit
func ComposeChainCommit(c *Chain, ec *ECAddress) (*JSON2Request, error) { buf := new(bytes.Buffer) // 1 byte version buf.Write([]byte{0}) // 6 byte milliTimestamp buf.Write(milliTime()) e := c.FirstEntry // 32 byte ChainID Hash if p, err := hex.DecodeString(c.ChainID); err != nil { return nil, err } else...
go
func ComposeChainCommit(c *Chain, ec *ECAddress) (*JSON2Request, error) { buf := new(bytes.Buffer) // 1 byte version buf.Write([]byte{0}) // 6 byte milliTimestamp buf.Write(milliTime()) e := c.FirstEntry // 32 byte ChainID Hash if p, err := hex.DecodeString(c.ChainID); err != nil { return nil, err } else...
[ "func", "ComposeChainCommit", "(", "c", "*", "Chain", ",", "ec", "*", "ECAddress", ")", "(", "*", "JSON2Request", ",", "error", ")", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n\n", "// 1 byte version", "buf", ".", "Write", "(", "[", ...
// ComposeChainCommit creates a JSON2Request to commit a new Chain via the // factomd web api. The request includes the marshaled MessageRequest with the // Entry Credit Signature.
[ "ComposeChainCommit", "creates", "a", "JSON2Request", "to", "commit", "a", "new", "Chain", "via", "the", "factomd", "web", "api", ".", "The", "request", "includes", "the", "marshaled", "MessageRequest", "with", "the", "Entry", "Credit", "Signature", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/chain.go#L48-L94
137,266
FactomProject/factom
chain.go
ComposeChainReveal
func ComposeChainReveal(c *Chain) (*JSON2Request, error) { p, err := c.FirstEntry.MarshalBinary() if err != nil { return nil, err } params := entryRequest{Entry: hex.EncodeToString(p)} req := NewJSON2Request("reveal-chain", APICounter(), params) return req, nil }
go
func ComposeChainReveal(c *Chain) (*JSON2Request, error) { p, err := c.FirstEntry.MarshalBinary() if err != nil { return nil, err } params := entryRequest{Entry: hex.EncodeToString(p)} req := NewJSON2Request("reveal-chain", APICounter(), params) return req, nil }
[ "func", "ComposeChainReveal", "(", "c", "*", "Chain", ")", "(", "*", "JSON2Request", ",", "error", ")", "{", "p", ",", "err", ":=", "c", ".", "FirstEntry", ".", "MarshalBinary", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "...
// ComposeChainReveal creates a JSON2Request to reveal the Chain via the factomd // web api.
[ "ComposeChainReveal", "creates", "a", "JSON2Request", "to", "reveal", "the", "Chain", "via", "the", "factomd", "web", "api", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/chain.go#L98-L107
137,267
FactomProject/factom
chain.go
CommitChain
func CommitChain(c *Chain, ec *ECAddress) (string, error) { type commitResponse struct { Message string `json:"message"` TxID string `json:"txid"` } req, err := ComposeChainCommit(c, ec) if err != nil { return "", err } resp, err := factomdRequest(req) if err != nil { return "", err } if resp.Erro...
go
func CommitChain(c *Chain, ec *ECAddress) (string, error) { type commitResponse struct { Message string `json:"message"` TxID string `json:"txid"` } req, err := ComposeChainCommit(c, ec) if err != nil { return "", err } resp, err := factomdRequest(req) if err != nil { return "", err } if resp.Erro...
[ "func", "CommitChain", "(", "c", "*", "Chain", ",", "ec", "*", "ECAddress", ")", "(", "string", ",", "error", ")", "{", "type", "commitResponse", "struct", "{", "Message", "string", "`json:\"message\"`", "\n", "TxID", "string", "`json:\"txid\"`", "\n", "}", ...
// CommitChain sends the signed ChainID, the Entry Hash, and the Entry Credit // public key to the factom network. Once the payment is verified and the // network is commited to publishing the Chain it may be published by revealing // the First Entry in the Chain.
[ "CommitChain", "sends", "the", "signed", "ChainID", "the", "Entry", "Hash", "and", "the", "Entry", "Credit", "public", "key", "to", "the", "factom", "network", ".", "Once", "the", "payment", "is", "verified", "and", "the", "network", "is", "commited", "to", ...
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/chain.go#L113-L137
137,268
FactomProject/factom
wallet/transaction.go
SignTransaction
func (w *Wallet) SignTransaction(name string, force bool) error { tx, err := w.GetTransaction(name) if err != nil { return err } if force == false { // check that the address balances are sufficient for the transaction if err := checkCovered(tx); err != nil { return err } // check that the fee is bei...
go
func (w *Wallet) SignTransaction(name string, force bool) error { tx, err := w.GetTransaction(name) if err != nil { return err } if force == false { // check that the address balances are sufficient for the transaction if err := checkCovered(tx); err != nil { return err } // check that the fee is bei...
[ "func", "(", "w", "*", "Wallet", ")", "SignTransaction", "(", "name", "string", ",", "force", "bool", ")", "error", "{", "tx", ",", "err", ":=", "w", ".", "GetTransaction", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n...
// SignTransaction signs a tmp transaction in the wallet with the appropriate // keys from the wallet db // force=true ignores the existing balance and fee overpayment checks.
[ "SignTransaction", "signs", "a", "tmp", "transaction", "in", "the", "wallet", "with", "the", "appropriate", "keys", "from", "the", "wallet", "db", "force", "=", "true", "ignores", "the", "existing", "balance", "and", "fee", "overpayment", "checks", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/wallet/transaction.go#L247-L289
137,269
FactomProject/factom
addresses.go
Sign
func (a *ECAddress) Sign(msg []byte) *[ed.SignatureSize]byte { return ed.Sign(a.SecFixed(), msg) }
go
func (a *ECAddress) Sign(msg []byte) *[ed.SignatureSize]byte { return ed.Sign(a.SecFixed(), msg) }
[ "func", "(", "a", "*", "ECAddress", ")", "Sign", "(", "msg", "[", "]", "byte", ")", "*", "[", "ed", ".", "SignatureSize", "]", "byte", "{", "return", "ed", ".", "Sign", "(", "a", ".", "SecFixed", "(", ")", ",", "msg", ")", "\n", "}" ]
// Sign the message with the ECAddress private key
[ "Sign", "the", "message", "with", "the", "ECAddress", "private", "key" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/addresses.go#L224-L226
137,270
FactomProject/factom
addresses.go
MakeFactoidAddressFromKoinify
func MakeFactoidAddressFromKoinify(mnemonic string) (*FactoidAddress, error) { mnemonic, err := ParseAndValidateMnemonic(mnemonic) if err != nil { return nil, err } seed, err := bip39.NewSeedWithErrorChecking(mnemonic, "") if err != nil { return nil, err } masterKey, err := bip32.NewMasterKey(seed) if err ...
go
func MakeFactoidAddressFromKoinify(mnemonic string) (*FactoidAddress, error) { mnemonic, err := ParseAndValidateMnemonic(mnemonic) if err != nil { return nil, err } seed, err := bip39.NewSeedWithErrorChecking(mnemonic, "") if err != nil { return nil, err } masterKey, err := bip32.NewMasterKey(seed) if err ...
[ "func", "MakeFactoidAddressFromKoinify", "(", "mnemonic", "string", ")", "(", "*", "FactoidAddress", ",", "error", ")", "{", "mnemonic", ",", "err", ":=", "ParseAndValidateMnemonic", "(", "mnemonic", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// MakeFactoidAddressFromKoinify takes the 12 word string used in the Koinify // sale and returns a Factoid Address.
[ "MakeFactoidAddressFromKoinify", "takes", "the", "12", "word", "string", "used", "in", "the", "Koinify", "sale", "and", "returns", "a", "Factoid", "Address", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/addresses.go#L327-L347
137,271
FactomProject/factom
identity.go
GetIdentityChainID
func GetIdentityChainID(name []string) string { hs := sha256.New() for _, part := range name { h := sha256.Sum256([]byte(part)) hs.Write(h[:]) } return hex.EncodeToString(hs.Sum(nil)) }
go
func GetIdentityChainID(name []string) string { hs := sha256.New() for _, part := range name { h := sha256.Sum256([]byte(part)) hs.Write(h[:]) } return hex.EncodeToString(hs.Sum(nil)) }
[ "func", "GetIdentityChainID", "(", "name", "[", "]", "string", ")", "string", "{", "hs", ":=", "sha256", ".", "New", "(", ")", "\n", "for", "_", ",", "part", ":=", "range", "name", "{", "h", ":=", "sha256", ".", "Sum256", "(", "[", "]", "byte", "...
// GetIdentityChainID takes an identity name and returns its corresponding ChainID
[ "GetIdentityChainID", "takes", "an", "identity", "name", "and", "returns", "its", "corresponding", "ChainID" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/identity.go#L28-L35
137,272
FactomProject/factom
identityKeys.go
GetIdentityKey
func GetIdentityKey(s string) (*IdentityKey, error) { if !IsValidIdentityKey(s) { return nil, fmt.Errorf("invalid Identity Private Key") } p := base58.Decode(s) if !bytes.Equal(p[:IDKeyPrefixLength], idSecPrefix) { return nil, fmt.Errorf("invalid Identity Private Key") } return MakeIdentityKey(p[IDKeyPrefix...
go
func GetIdentityKey(s string) (*IdentityKey, error) { if !IsValidIdentityKey(s) { return nil, fmt.Errorf("invalid Identity Private Key") } p := base58.Decode(s) if !bytes.Equal(p[:IDKeyPrefixLength], idSecPrefix) { return nil, fmt.Errorf("invalid Identity Private Key") } return MakeIdentityKey(p[IDKeyPrefix...
[ "func", "GetIdentityKey", "(", "s", "string", ")", "(", "*", "IdentityKey", ",", "error", ")", "{", "if", "!", "IsValidIdentityKey", "(", "s", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "p", ":=", ...
// GetIdentityKey takes a private key string and returns an IdentityKey.
[ "GetIdentityKey", "takes", "a", "private", "key", "string", "and", "returns", "an", "IdentityKey", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/identityKeys.go#L120-L131
137,273
FactomProject/factom
identityKeys.go
Sign
func (k *IdentityKey) Sign(msg []byte) *[ed.SignatureSize]byte { return ed.Sign(k.SecFixed(), msg) }
go
func (k *IdentityKey) Sign(msg []byte) *[ed.SignatureSize]byte { return ed.Sign(k.SecFixed(), msg) }
[ "func", "(", "k", "*", "IdentityKey", ")", "Sign", "(", "msg", "[", "]", "byte", ")", "*", "[", "ed", ".", "SignatureSize", "]", "byte", "{", "return", "ed", ".", "Sign", "(", "k", ".", "SecFixed", "(", ")", ",", "msg", ")", "\n", "}" ]
// Sign the message with the Identity private key
[ "Sign", "the", "message", "with", "the", "Identity", "private", "key" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/identityKeys.go#L207-L209
137,274
FactomProject/factom
wallet/txdatabase.go
GetAllTXs
func (db *TXDatabaseOverlay) GetAllTXs() ([]interfaces.ITransaction, error) { // update the database and get the newest fblock _, err := db.update() if err != nil { return nil, err } fblock, err := db.DBO.FetchFBlockHead() if err != nil { return nil, err } if fblock == nil { return nil, fmt.Errorf("FBlock...
go
func (db *TXDatabaseOverlay) GetAllTXs() ([]interfaces.ITransaction, error) { // update the database and get the newest fblock _, err := db.update() if err != nil { return nil, err } fblock, err := db.DBO.FetchFBlockHead() if err != nil { return nil, err } if fblock == nil { return nil, fmt.Errorf("FBlock...
[ "func", "(", "db", "*", "TXDatabaseOverlay", ")", "GetAllTXs", "(", ")", "(", "[", "]", "interfaces", ".", "ITransaction", ",", "error", ")", "{", "// update the database and get the newest fblock", "_", ",", "err", ":=", "db", ".", "update", "(", ")", "\n",...
// GetAllTXs returns a list of all transactions in the history of Factom. A // local database is used to cache the factoid blocks.
[ "GetAllTXs", "returns", "a", "list", "of", "all", "transactions", "in", "the", "history", "of", "Factom", ".", "A", "local", "database", "is", "used", "to", "cache", "the", "factoid", "blocks", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/wallet/txdatabase.go#L93-L141
137,275
FactomProject/factom
wallet/txdatabase.go
GetTX
func (db *TXDatabaseOverlay) GetTX(txid string) (interfaces.ITransaction, error) { txs, err := db.GetAllTXs() if err != nil { return nil, err } for _, tx := range txs { if tx.GetSigHash().String() == txid { return tx, nil } } return nil, fmt.Errorf("Transaction not found") }
go
func (db *TXDatabaseOverlay) GetTX(txid string) (interfaces.ITransaction, error) { txs, err := db.GetAllTXs() if err != nil { return nil, err } for _, tx := range txs { if tx.GetSigHash().String() == txid { return tx, nil } } return nil, fmt.Errorf("Transaction not found") }
[ "func", "(", "db", "*", "TXDatabaseOverlay", ")", "GetTX", "(", "txid", "string", ")", "(", "interfaces", ".", "ITransaction", ",", "error", ")", "{", "txs", ",", "err", ":=", "db", ".", "GetAllTXs", "(", ")", "\n", "if", "err", "!=", "nil", "{", "...
// GetTX gets a transaction by the transaction id
[ "GetTX", "gets", "a", "transaction", "by", "the", "transaction", "id" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/wallet/txdatabase.go#L144-L157
137,276
FactomProject/factom
wallet/txdatabase.go
GetTXAddress
func (db *TXDatabaseOverlay) GetTXAddress(adr string) ( []interfaces.ITransaction, error) { filtered := make([]interfaces.ITransaction, 0) txs, err := db.GetAllTXs() if err != nil { return nil, err } if factom.AddressStringType(adr) == factom.FactoidPub { for _, tx := range txs { for _, in := range tx.Ge...
go
func (db *TXDatabaseOverlay) GetTXAddress(adr string) ( []interfaces.ITransaction, error) { filtered := make([]interfaces.ITransaction, 0) txs, err := db.GetAllTXs() if err != nil { return nil, err } if factom.AddressStringType(adr) == factom.FactoidPub { for _, tx := range txs { for _, in := range tx.Ge...
[ "func", "(", "db", "*", "TXDatabaseOverlay", ")", "GetTXAddress", "(", "adr", "string", ")", "(", "[", "]", "interfaces", ".", "ITransaction", ",", "error", ")", "{", "filtered", ":=", "make", "(", "[", "]", "interfaces", ".", "ITransaction", ",", "0", ...
// GetTXAddress returns a list of all transactions in the history of Factom that // include a specific address.
[ "GetTXAddress", "returns", "a", "list", "of", "all", "transactions", "in", "the", "history", "of", "Factom", "that", "include", "a", "specific", "address", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/wallet/txdatabase.go#L161-L196
137,277
FactomProject/factom
wallet/txdatabase.go
GetFBlock
func (db *TXDatabaseOverlay) GetFBlock(keymr string) (interfaces.IFBlock, error) { h, err := primitives.NewShaHashFromStr(keymr) if err != nil { return nil, err } fBlock, err := db.DBO.FetchFBlock(h) if err != nil { return nil, err } return fBlock, nil }
go
func (db *TXDatabaseOverlay) GetFBlock(keymr string) (interfaces.IFBlock, error) { h, err := primitives.NewShaHashFromStr(keymr) if err != nil { return nil, err } fBlock, err := db.DBO.FetchFBlock(h) if err != nil { return nil, err } return fBlock, nil }
[ "func", "(", "db", "*", "TXDatabaseOverlay", ")", "GetFBlock", "(", "keymr", "string", ")", "(", "interfaces", ".", "IFBlock", ",", "error", ")", "{", "h", ",", "err", ":=", "primitives", ".", "NewShaHashFromStr", "(", "keymr", ")", "\n", "if", "err", ...
// GetFBlock retrives a Factoid Block from Factom
[ "GetFBlock", "retrives", "a", "Factoid", "Block", "from", "Factom" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/wallet/txdatabase.go#L260-L271
137,278
FactomProject/factom
wallet/txdatabase.go
update
func (db *TXDatabaseOverlay) update() (string, error) { newestFBlock, err := fblockHead() if err != nil { return "", err } start, err := db.FetchNextFBlockHeight() if err != nil { return "", err } // Make sure we didn't switch networks genesis, err := db.DBO.FetchFBlockByHeight(0) if err != nil { retur...
go
func (db *TXDatabaseOverlay) update() (string, error) { newestFBlock, err := fblockHead() if err != nil { return "", err } start, err := db.FetchNextFBlockHeight() if err != nil { return "", err } // Make sure we didn't switch networks genesis, err := db.DBO.FetchFBlockByHeight(0) if err != nil { retur...
[ "func", "(", "db", "*", "TXDatabaseOverlay", ")", "update", "(", ")", "(", "string", ",", "error", ")", "{", "newestFBlock", ",", "err", ":=", "fblockHead", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}",...
// update gets all fblocks written since the database was last updated, and // returns the most recent fblock keymr.
[ "update", "gets", "all", "fblocks", "written", "since", "the", "database", "was", "last", "updated", "and", "returns", "the", "most", "recent", "fblock", "keymr", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/wallet/txdatabase.go#L290-L373
137,279
FactomProject/factom
wallet/txdatabase.go
fblockHead
func fblockHead() (interfaces.IFBlock, error) { fblockID := "000000000000000000000000000000000000000000000000000000000000000f" dbhead, err := factom.GetDBlockHead() if err != nil { return nil, err } dblock, err := factom.GetDBlock(dbhead) if err != nil { return nil, err } var fblockmr string for _, ebloc...
go
func fblockHead() (interfaces.IFBlock, error) { fblockID := "000000000000000000000000000000000000000000000000000000000000000f" dbhead, err := factom.GetDBlockHead() if err != nil { return nil, err } dblock, err := factom.GetDBlock(dbhead) if err != nil { return nil, err } var fblockmr string for _, ebloc...
[ "func", "fblockHead", "(", ")", "(", "interfaces", ".", "IFBlock", ",", "error", ")", "{", "fblockID", ":=", "\"", "\"", "\n\n", "dbhead", ",", "err", ":=", "factom", ".", "GetDBlockHead", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil...
// fblockHead gets the most recent fblock.
[ "fblockHead", "gets", "the", "most", "recent", "fblock", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/wallet/txdatabase.go#L376-L399
137,280
FactomProject/factom
transaction.go
String
func (tx *Transaction) String() (s string) { if tx.Name != "" { s += fmt.Sprintln("Name:", tx.Name) } if tx.IsSigned { s += fmt.Sprintln("TxID:", tx.TxID) } s += fmt.Sprintln("Timestamp:", tx.Timestamp) if tx.BlockHeight != 0 { s += fmt.Sprintln("BlockHeight:", tx.BlockHeight) } s += fmt.Sprintln("TotalIn...
go
func (tx *Transaction) String() (s string) { if tx.Name != "" { s += fmt.Sprintln("Name:", tx.Name) } if tx.IsSigned { s += fmt.Sprintln("TxID:", tx.TxID) } s += fmt.Sprintln("Timestamp:", tx.Timestamp) if tx.BlockHeight != 0 { s += fmt.Sprintln("BlockHeight:", tx.BlockHeight) } s += fmt.Sprintln("TotalIn...
[ "func", "(", "tx", "*", "Transaction", ")", "String", "(", ")", "(", "s", "string", ")", "{", "if", "tx", ".", "Name", "!=", "\"", "\"", "{", "s", "+=", "fmt", ".", "Sprintln", "(", "\"", "\"", ",", "tx", ".", "Name", ")", "\n", "}", "\n", ...
// String prints the formatted data of a transaction.
[ "String", "prints", "the", "formatted", "data", "of", "a", "transaction", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/transaction.go#L37-L79
137,281
FactomProject/factom
transaction.go
MarshalJSON
func (tx *Transaction) MarshalJSON() ([]byte, error) { tmp := &struct { BlockHeight uint32 `json:"blockheight,omitempty"` FeesPaid uint64 `json:"feespaid,omitempty"` FeesRequired uint64 `json:"feesrequired,omitempty"` IsSigned bool `json:"signed"` Name ...
go
func (tx *Transaction) MarshalJSON() ([]byte, error) { tmp := &struct { BlockHeight uint32 `json:"blockheight,omitempty"` FeesPaid uint64 `json:"feespaid,omitempty"` FeesRequired uint64 `json:"feesrequired,omitempty"` IsSigned bool `json:"signed"` Name ...
[ "func", "(", "tx", "*", "Transaction", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "tmp", ":=", "&", "struct", "{", "BlockHeight", "uint32", "`json:\"blockheight,omitempty\"`", "\n", "FeesPaid", "uint64", "`json:\"feespaid,omit...
// MarshalJSON converts the Transaction into a JSON object
[ "MarshalJSON", "converts", "the", "Transaction", "into", "a", "JSON", "object" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/transaction.go#L82-L114
137,282
FactomProject/factom
transaction.go
UnmarshalJSON
func (tx *Transaction) UnmarshalJSON(data []byte) error { type jsontx struct { BlockHeight uint32 `json:"blockheight,omitempty"` FeesPaid uint64 `json:"feespaid,omitempty"` FeesRequired uint64 `json:"feesrequired,omitempty"` IsSigned bool `json:"signed"` ...
go
func (tx *Transaction) UnmarshalJSON(data []byte) error { type jsontx struct { BlockHeight uint32 `json:"blockheight,omitempty"` FeesPaid uint64 `json:"feespaid,omitempty"` FeesRequired uint64 `json:"feesrequired,omitempty"` IsSigned bool `json:"signed"` ...
[ "func", "(", "tx", "*", "Transaction", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "type", "jsontx", "struct", "{", "BlockHeight", "uint32", "`json:\"blockheight,omitempty\"`", "\n", "FeesPaid", "uint64", "`json:\"feespaid,omitempty\"`", ...
// UnmarshalJSON converts the JSON Transaction back into a Transaction
[ "UnmarshalJSON", "converts", "the", "JSON", "Transaction", "back", "into", "a", "Transaction" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/transaction.go#L117-L154
137,283
FactomProject/factom
transaction.go
NewTransaction
func NewTransaction(name string) (*Transaction, error) { params := transactionRequest{Name: name} req := NewJSON2Request("new-transaction", APICounter(), params) resp, err := walletRequest(req) if err != nil { return nil, err } if resp.Error != nil { return nil, resp.Error } tx := new(Transaction) if err...
go
func NewTransaction(name string) (*Transaction, error) { params := transactionRequest{Name: name} req := NewJSON2Request("new-transaction", APICounter(), params) resp, err := walletRequest(req) if err != nil { return nil, err } if resp.Error != nil { return nil, resp.Error } tx := new(Transaction) if err...
[ "func", "NewTransaction", "(", "name", "string", ")", "(", "*", "Transaction", ",", "error", ")", "{", "params", ":=", "transactionRequest", "{", "Name", ":", "name", "}", "\n", "req", ":=", "NewJSON2Request", "(", "\"", "\"", ",", "APICounter", "(", ")"...
// NewTransaction creates a new temporary Transaction in the wallet
[ "NewTransaction", "creates", "a", "new", "temporary", "Transaction", "in", "the", "wallet" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/transaction.go#L157-L174
137,284
FactomProject/factom
transaction.go
GetTmpTransaction
func GetTmpTransaction(name string) (*Transaction, error) { txs, err := ListTransactionsTmp() if err != nil { return nil, err } for _, tx := range txs { if tx.Name == name { return tx, nil } } return nil, fmt.Errorf("Transaction not found") }
go
func GetTmpTransaction(name string) (*Transaction, error) { txs, err := ListTransactionsTmp() if err != nil { return nil, err } for _, tx := range txs { if tx.Name == name { return tx, nil } } return nil, fmt.Errorf("Transaction not found") }
[ "func", "GetTmpTransaction", "(", "name", "string", ")", "(", "*", "Transaction", ",", "error", ")", "{", "txs", ",", "err", ":=", "ListTransactionsTmp", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "...
// GetTmpTransaction gets a temporary transaction from the wallet
[ "GetTmpTransaction", "gets", "a", "temporary", "transaction", "from", "the", "wallet" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/transaction.go#L667-L680
137,285
FactomProject/factom
wallet/importexportldb.go
ImportLDBWalletFromMnemonic
func ImportLDBWalletFromMnemonic(mnemonic, path string) (*Wallet, error) { mnemonic, err := factom.ParseAndValidateMnemonic(mnemonic) if err != nil { return nil, err } // check if the file exists _, err = os.Stat(path) if err == nil { return nil, fmt.Errorf("%s: file already exists", path) } db, err := Ne...
go
func ImportLDBWalletFromMnemonic(mnemonic, path string) (*Wallet, error) { mnemonic, err := factom.ParseAndValidateMnemonic(mnemonic) if err != nil { return nil, err } // check if the file exists _, err = os.Stat(path) if err == nil { return nil, fmt.Errorf("%s: file already exists", path) } db, err := Ne...
[ "func", "ImportLDBWalletFromMnemonic", "(", "mnemonic", ",", "path", "string", ")", "(", "*", "Wallet", ",", "error", ")", "{", "mnemonic", ",", "err", ":=", "factom", ".", "ParseAndValidateMnemonic", "(", "mnemonic", ")", "\n", "if", "err", "!=", "nil", "...
// ImportWalletFromMnemonic creates a new wallet with a provided Mnemonic seed // defined in bip-0039.
[ "ImportWalletFromMnemonic", "creates", "a", "new", "wallet", "with", "a", "provided", "Mnemonic", "seed", "defined", "in", "bip", "-", "0039", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/wallet/importexportldb.go#L17-L45
137,286
FactomProject/factom
wallet/database.go
Close
func (w *Wallet) Close() error { if w.WalletDatabaseOverlay == nil { return nil } return w.DBO.Close() }
go
func (w *Wallet) Close() error { if w.WalletDatabaseOverlay == nil { return nil } return w.DBO.Close() }
[ "func", "(", "w", "*", "Wallet", ")", "Close", "(", ")", "error", "{", "if", "w", ".", "WalletDatabaseOverlay", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "w", ".", "DBO", ".", "Close", "(", ")", "\n", "}" ]
// Close closes a Factom Wallet Database
[ "Close", "closes", "a", "Factom", "Wallet", "Database" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/wallet/database.go#L104-L109
137,287
FactomProject/factom
wallet/database.go
GetAllAddresses
func (w *Wallet) GetAllAddresses() ([]*factom.FactoidAddress, []*factom.ECAddress, error) { fcs, err := w.GetAllFCTAddresses() if err != nil { return nil, nil, err } ecs, err := w.GetAllECAddresses() if err != nil { return nil, nil, err } return fcs, ecs, nil }
go
func (w *Wallet) GetAllAddresses() ([]*factom.FactoidAddress, []*factom.ECAddress, error) { fcs, err := w.GetAllFCTAddresses() if err != nil { return nil, nil, err } ecs, err := w.GetAllECAddresses() if err != nil { return nil, nil, err } return fcs, ecs, nil }
[ "func", "(", "w", "*", "Wallet", ")", "GetAllAddresses", "(", ")", "(", "[", "]", "*", "factom", ".", "FactoidAddress", ",", "[", "]", "*", "factom", ".", "ECAddress", ",", "error", ")", "{", "fcs", ",", "err", ":=", "w", ".", "GetAllFCTAddresses", ...
// GetAllAddresses retrieves all Entry Credit and Factoid Addresses from the // Wallet Database.
[ "GetAllAddresses", "retrieves", "all", "Entry", "Credit", "and", "Factoid", "Addresses", "from", "the", "Wallet", "Database", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/wallet/database.go#L139-L150
137,288
FactomProject/factom
wallet/database.go
GetSeed
func (w *Wallet) GetSeed() (string, error) { seed, err := w.GetDBSeed() if err != nil { return "", err } return seed.MnemonicSeed, nil }
go
func (w *Wallet) GetSeed() (string, error) { seed, err := w.GetDBSeed() if err != nil { return "", err } return seed.MnemonicSeed, nil }
[ "func", "(", "w", "*", "Wallet", ")", "GetSeed", "(", ")", "(", "string", ",", "error", ")", "{", "seed", ",", "err", ":=", "w", ".", "GetDBSeed", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n...
// GetSeed returns the string representaion of the Wallet Seed. The Wallet Seed // can be used to regenerate the Factoid and Entry Credit Addresses previously // generated by the wallet. Note that Addresses that are imported into the // Wallet cannot be regenerated using the Wallet Seed.
[ "GetSeed", "returns", "the", "string", "representaion", "of", "the", "Wallet", "Seed", ".", "The", "Wallet", "Seed", "can", "be", "used", "to", "regenerate", "the", "Factoid", "and", "Entry", "Credit", "Addresses", "previously", "generated", "by", "the", "wall...
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/wallet/database.go#L156-L163
137,289
FactomProject/factom
wallet/util.go
SeedString
func SeedString(seed []byte) string { if len(seed) != SeedLength { return "" } buf := new(bytes.Buffer) // 2 byte Seed Address Prefix buf.Write(seedPrefix) // 64 byte Seed buf.Write(seed) // 4 byte Checksum check := shad(buf.Bytes())[:4] buf.Write(check) return base58.Encode(buf.Bytes()) }
go
func SeedString(seed []byte) string { if len(seed) != SeedLength { return "" } buf := new(bytes.Buffer) // 2 byte Seed Address Prefix buf.Write(seedPrefix) // 64 byte Seed buf.Write(seed) // 4 byte Checksum check := shad(buf.Bytes())[:4] buf.Write(check) return base58.Encode(buf.Bytes()) }
[ "func", "SeedString", "(", "seed", "[", "]", "byte", ")", "string", "{", "if", "len", "(", "seed", ")", "!=", "SeedLength", "{", "return", "\"", "\"", "\n", "}", "\n\n", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n\n", "// 2 byte Seed Ad...
// SeedString returnes the string representation of a raw Wallet Seed or Next // Wallet Seed.
[ "SeedString", "returnes", "the", "string", "representation", "of", "a", "raw", "Wallet", "Seed", "or", "Next", "Wallet", "Seed", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/wallet/util.go#L35-L53
137,290
FactomProject/factom
entry.go
ComposeEntryCommit
func ComposeEntryCommit(e *Entry, ec *ECAddress) (*JSON2Request, error) { buf := new(bytes.Buffer) // 1 byte version buf.Write([]byte{0}) // 6 byte milliTimestamp (truncated unix time) buf.Write(milliTime()) // 32 byte Entry Hash buf.Write(e.Hash()) // 1 byte number of entry credits to pay if c, err := Ent...
go
func ComposeEntryCommit(e *Entry, ec *ECAddress) (*JSON2Request, error) { buf := new(bytes.Buffer) // 1 byte version buf.Write([]byte{0}) // 6 byte milliTimestamp (truncated unix time) buf.Write(milliTime()) // 32 byte Entry Hash buf.Write(e.Hash()) // 1 byte number of entry credits to pay if c, err := Ent...
[ "func", "ComposeEntryCommit", "(", "e", "*", "Entry", ",", "ec", "*", "ECAddress", ")", "(", "*", "JSON2Request", ",", "error", ")", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n\n", "// 1 byte version", "buf", ".", "Write", "(", "[", ...
// ComposeEntryCommit creates a JSON2Request to commit a new Entry via the // factomd web api. The request includes the marshaled MessageRequest with the // Entry Credit Signature.
[ "ComposeEntryCommit", "creates", "a", "JSON2Request", "to", "commit", "a", "new", "Entry", "via", "the", "factomd", "web", "api", ".", "The", "request", "includes", "the", "marshaled", "MessageRequest", "with", "the", "Entry", "Credit", "Signature", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/entry.go#L157-L185
137,291
FactomProject/factom
entry.go
ComposeEntryReveal
func ComposeEntryReveal(e *Entry) (*JSON2Request, error) { p, err := e.MarshalBinary() if err != nil { return nil, err } params := entryRequest{Entry: hex.EncodeToString(p)} req := NewJSON2Request("reveal-entry", APICounter(), params) return req, nil }
go
func ComposeEntryReveal(e *Entry) (*JSON2Request, error) { p, err := e.MarshalBinary() if err != nil { return nil, err } params := entryRequest{Entry: hex.EncodeToString(p)} req := NewJSON2Request("reveal-entry", APICounter(), params) return req, nil }
[ "func", "ComposeEntryReveal", "(", "e", "*", "Entry", ")", "(", "*", "JSON2Request", ",", "error", ")", "{", "p", ",", "err", ":=", "e", ".", "MarshalBinary", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", ...
// ComposeEntryReveal creates a JSON2Request to reveal the Entry via the factomd // web api.
[ "ComposeEntryReveal", "creates", "a", "JSON2Request", "to", "reveal", "the", "Entry", "via", "the", "factomd", "web", "api", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/entry.go#L189-L199
137,292
FactomProject/factom
entry.go
CommitEntry
func CommitEntry(e *Entry, ec *ECAddress) (string, error) { type commitResponse struct { Message string `json:"message"` TxID string `json:"txid"` } req, err := ComposeEntryCommit(e, ec) if err != nil { return "", err } resp, err := factomdRequest(req) if err != nil { return "", err } if resp.Err...
go
func CommitEntry(e *Entry, ec *ECAddress) (string, error) { type commitResponse struct { Message string `json:"message"` TxID string `json:"txid"` } req, err := ComposeEntryCommit(e, ec) if err != nil { return "", err } resp, err := factomdRequest(req) if err != nil { return "", err } if resp.Err...
[ "func", "CommitEntry", "(", "e", "*", "Entry", ",", "ec", "*", "ECAddress", ")", "(", "string", ",", "error", ")", "{", "type", "commitResponse", "struct", "{", "Message", "string", "`json:\"message\"`", "\n", "TxID", "string", "`json:\"txid\"`", "\n", "}", ...
// CommitEntry sends the signed Entry Hash and the Entry Credit public key to // the factom network. Once the payment is verified and the network is commited // to publishing the Entry it may be published with a call to RevealEntry.
[ "CommitEntry", "sends", "the", "signed", "Entry", "Hash", "and", "the", "Entry", "Credit", "public", "key", "to", "the", "factom", "network", ".", "Once", "the", "payment", "is", "verified", "and", "the", "network", "is", "commited", "to", "publishing", "the...
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/entry.go#L204-L229
137,293
FactomProject/factom
util.go
FactoshiToFactoid
func FactoshiToFactoid(i uint64) string { d := i / 1e8 r := i % 1e8 ds := fmt.Sprintf("%d", d) rs := fmt.Sprintf("%08d", r) rs = strings.TrimRight(rs, "0") if len(rs) > 0 { ds = ds + "." } return fmt.Sprintf("%s%s", ds, rs) }
go
func FactoshiToFactoid(i uint64) string { d := i / 1e8 r := i % 1e8 ds := fmt.Sprintf("%d", d) rs := fmt.Sprintf("%08d", r) rs = strings.TrimRight(rs, "0") if len(rs) > 0 { ds = ds + "." } return fmt.Sprintf("%s%s", ds, rs) }
[ "func", "FactoshiToFactoid", "(", "i", "uint64", ")", "string", "{", "d", ":=", "i", "/", "1e8", "\n", "r", ":=", "i", "%", "1e8", "\n", "ds", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "d", ")", "\n", "rs", ":=", "fmt", ".", "Sprintf",...
// FactoshiToFactoid converts a uint64 factoshi ammount into a fixed point // number represented as a string
[ "FactoshiToFactoid", "converts", "a", "uint64", "factoshi", "ammount", "into", "a", "fixed", "point", "number", "represented", "as", "a", "string" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/util.go#L57-L67
137,294
FactomProject/factom
util.go
FactoidToFactoshi
func FactoidToFactoshi(amt string) uint64 { valid := regexp.MustCompile(`^([0-9]+)?(\.[0-9]+)?$`) if !valid.MatchString(amt) { return 0 } var total uint64 = 0 dot := regexp.MustCompile(`\.`) pieces := dot.Split(amt, 2) whole, _ := strconv.Atoi(pieces[0]) total += uint64(whole) * 1e8 if len(pieces) > 1 { ...
go
func FactoidToFactoshi(amt string) uint64 { valid := regexp.MustCompile(`^([0-9]+)?(\.[0-9]+)?$`) if !valid.MatchString(amt) { return 0 } var total uint64 = 0 dot := regexp.MustCompile(`\.`) pieces := dot.Split(amt, 2) whole, _ := strconv.Atoi(pieces[0]) total += uint64(whole) * 1e8 if len(pieces) > 1 { ...
[ "func", "FactoidToFactoshi", "(", "amt", "string", ")", "uint64", "{", "valid", ":=", "regexp", ".", "MustCompile", "(", "`^([0-9]+)?(\\.[0-9]+)?$`", ")", "\n", "if", "!", "valid", ".", "MatchString", "(", "amt", ")", "{", "return", "0", "\n", "}", "\n\n",...
// FactoidToFactoshi takes a Factoid amount as a string and returns the value in // factoids
[ "FactoidToFactoshi", "takes", "a", "Factoid", "amount", "as", "a", "string", "and", "returns", "the", "value", "in", "factoids" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/util.go#L71-L94
137,295
FactomProject/factom
util.go
milliTime
func milliTime() (r []byte) { buf := new(bytes.Buffer) t := time.Now().UnixNano() m := t / 1e6 binary.Write(buf, binary.BigEndian, m) return buf.Bytes()[2:] }
go
func milliTime() (r []byte) { buf := new(bytes.Buffer) t := time.Now().UnixNano() m := t / 1e6 binary.Write(buf, binary.BigEndian, m) return buf.Bytes()[2:] }
[ "func", "milliTime", "(", ")", "(", "r", "[", "]", "byte", ")", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n", "t", ":=", "time", ".", "Now", "(", ")", ".", "UnixNano", "(", ")", "\n", "m", ":=", "t", "/", "1e6", "\n", "bi...
// milliTime returns a 6 byte slice representing the unix time in milliseconds
[ "milliTime", "returns", "a", "6", "byte", "slice", "representing", "the", "unix", "time", "in", "milliseconds" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/util.go#L97-L103
137,296
FactomProject/factom
get.go
GetBalanceTotals
func GetBalanceTotals() (fSaved, fAcknowledged, eSaved, eAcknowledged int64, err error) { type multiBalanceResponse struct { FactoidAccountBalances struct { Ack int64 `json:"ack"` Saved int64 `json:"saved"` } `json:"fctaccountbalances"` EntryCreditAccountBalances struct { Ack int64 `json:"ack"` S...
go
func GetBalanceTotals() (fSaved, fAcknowledged, eSaved, eAcknowledged int64, err error) { type multiBalanceResponse struct { FactoidAccountBalances struct { Ack int64 `json:"ack"` Saved int64 `json:"saved"` } `json:"fctaccountbalances"` EntryCreditAccountBalances struct { Ack int64 `json:"ack"` S...
[ "func", "GetBalanceTotals", "(", ")", "(", "fSaved", ",", "fAcknowledged", ",", "eSaved", ",", "eAcknowledged", "int64", ",", "err", "error", ")", "{", "type", "multiBalanceResponse", "struct", "{", "FactoidAccountBalances", "struct", "{", "Ack", "int64", "`json...
// GetBalanceTotals return the total value of Factoids and Entry Credits in the // wallet according to the the server acknowledgement and the value saved in the // blockchain.
[ "GetBalanceTotals", "return", "the", "total", "value", "of", "Factoids", "and", "Entry", "Credits", "in", "the", "wallet", "according", "to", "the", "the", "server", "acknowledgement", "and", "the", "value", "saved", "in", "the", "blockchain", "." ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/get.go#L66-L99
137,297
FactomProject/factom
get.go
GetRate
func GetRate() (uint64, error) { type rateResponse struct { Rate uint64 `json:"rate"` } req := NewJSON2Request("entry-credit-rate", APICounter(), nil) resp, err := factomdRequest(req) if err != nil { return 0, err } if resp.Error != nil { return 0, resp.Error } rate := new(rateResponse) if err := json...
go
func GetRate() (uint64, error) { type rateResponse struct { Rate uint64 `json:"rate"` } req := NewJSON2Request("entry-credit-rate", APICounter(), nil) resp, err := factomdRequest(req) if err != nil { return 0, err } if resp.Error != nil { return 0, resp.Error } rate := new(rateResponse) if err := json...
[ "func", "GetRate", "(", ")", "(", "uint64", ",", "error", ")", "{", "type", "rateResponse", "struct", "{", "Rate", "uint64", "`json:\"rate\"`", "\n", "}", "\n\n", "req", ":=", "NewJSON2Request", "(", "\"", "\"", ",", "APICounter", "(", ")", ",", "nil", ...
// GetRate returns the number of factoshis per entry credit
[ "GetRate", "returns", "the", "number", "of", "factoshis", "per", "entry", "credit" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/get.go#L102-L122
137,298
FactomProject/factom
get.go
GetDBlock
func GetDBlock(keymr string) (*DBlock, error) { params := keyMRRequest{KeyMR: keymr} req := NewJSON2Request("directory-block", APICounter(), params) resp, err := factomdRequest(req) if err != nil { return nil, err } if resp.Error != nil { return nil, resp.Error } db := new(DBlock) if err := json.Unmarshal...
go
func GetDBlock(keymr string) (*DBlock, error) { params := keyMRRequest{KeyMR: keymr} req := NewJSON2Request("directory-block", APICounter(), params) resp, err := factomdRequest(req) if err != nil { return nil, err } if resp.Error != nil { return nil, resp.Error } db := new(DBlock) if err := json.Unmarshal...
[ "func", "GetDBlock", "(", "keymr", "string", ")", "(", "*", "DBlock", ",", "error", ")", "{", "params", ":=", "keyMRRequest", "{", "KeyMR", ":", "keymr", "}", "\n", "req", ":=", "NewJSON2Request", "(", "\"", "\"", ",", "APICounter", "(", ")", ",", "p...
// GetDBlock requests a Directory Block from factomd by its Key Merkle Root
[ "GetDBlock", "requests", "a", "Directory", "Block", "from", "factomd", "by", "its", "Key", "Merkle", "Root" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/get.go#L125-L142
137,299
FactomProject/factom
get.go
GetEntry
func GetEntry(hash string) (*Entry, error) { params := hashRequest{Hash: hash} req := NewJSON2Request("entry", APICounter(), params) resp, err := factomdRequest(req) if err != nil { return nil, err } if resp.Error != nil { return nil, resp.Error } e := new(Entry) if err := json.Unmarshal(resp.JSONResult()...
go
func GetEntry(hash string) (*Entry, error) { params := hashRequest{Hash: hash} req := NewJSON2Request("entry", APICounter(), params) resp, err := factomdRequest(req) if err != nil { return nil, err } if resp.Error != nil { return nil, resp.Error } e := new(Entry) if err := json.Unmarshal(resp.JSONResult()...
[ "func", "GetEntry", "(", "hash", "string", ")", "(", "*", "Entry", ",", "error", ")", "{", "params", ":=", "hashRequest", "{", "Hash", ":", "hash", "}", "\n", "req", ":=", "NewJSON2Request", "(", "\"", "\"", ",", "APICounter", "(", ")", ",", "params"...
// GetEntry requests an Entry from factomd by its Entry Hash
[ "GetEntry", "requests", "an", "Entry", "from", "factomd", "by", "its", "Entry", "Hash" ]
fc1c06ae7272973dd767b473b384c6221e74c7d7
https://github.com/FactomProject/factom/blob/fc1c06ae7272973dd767b473b384c6221e74c7d7/get.go#L181-L198