repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
giantswarm/certctl
service/role/error.go
IsNoVaultHandlerDefined
func IsNoVaultHandlerDefined(err error) bool { cause := microerror.Cause(err) if cause != nil && strings.Contains(cause.Error(), "no handler for route") { return true } return false }
go
func IsNoVaultHandlerDefined(err error) bool { cause := microerror.Cause(err) if cause != nil && strings.Contains(cause.Error(), "no handler for route") { return true } return false }
[ "func", "IsNoVaultHandlerDefined", "(", "err", "error", ")", "bool", "{", "cause", ":=", "microerror", ".", "Cause", "(", "err", ")", "\n", "if", "cause", "!=", "nil", "&&", "strings", ".", "Contains", "(", "cause", ".", "Error", "(", ")", ",", "\"no handler for route\"", ")", "{", "return", "true", "\n", "}", "\n", "return", "false", "\n", "}" ]
// IsNoVaultHandlerDefined asserts a dirty string matching against the error // message provided by err. This is necessary due to the poor error handling // design of the Vault library we are using.
[ "IsNoVaultHandlerDefined", "asserts", "a", "dirty", "string", "matching", "against", "the", "error", "message", "provided", "by", "err", ".", "This", "is", "necessary", "due", "to", "the", "poor", "error", "handling", "design", "of", "the", "Vault", "library", "we", "are", "using", "." ]
2a6615f61499cd09a8d5ced9a5fade322d2de254
https://github.com/giantswarm/certctl/blob/2a6615f61499cd09a8d5ced9a5fade322d2de254/service/role/error.go#L21-L29
test
giantswarm/certctl
service/role/service.go
New
func New(config Config) (Service, error) { // Dependencies. if config.VaultClient == nil { return nil, microerror.Maskf(invalidConfigError, "Vault client must not be empty") } if config.PKIMountpoint == "" { return nil, microerror.Maskf(invalidConfigError, "PKIMountpoint must not be empty") } service := &service{ vaultClient: config.VaultClient, pkiMountpoint: config.PKIMountpoint, } return service, nil }
go
func New(config Config) (Service, error) { // Dependencies. if config.VaultClient == nil { return nil, microerror.Maskf(invalidConfigError, "Vault client must not be empty") } if config.PKIMountpoint == "" { return nil, microerror.Maskf(invalidConfigError, "PKIMountpoint must not be empty") } service := &service{ vaultClient: config.VaultClient, pkiMountpoint: config.PKIMountpoint, } return service, nil }
[ "func", "New", "(", "config", "Config", ")", "(", "Service", ",", "error", ")", "{", "if", "config", ".", "VaultClient", "==", "nil", "{", "return", "nil", ",", "microerror", ".", "Maskf", "(", "invalidConfigError", ",", "\"Vault client must not be empty\"", ")", "\n", "}", "\n", "if", "config", ".", "PKIMountpoint", "==", "\"\"", "{", "return", "nil", ",", "microerror", ".", "Maskf", "(", "invalidConfigError", ",", "\"PKIMountpoint must not be empty\"", ")", "\n", "}", "\n", "service", ":=", "&", "service", "{", "vaultClient", ":", "config", ".", "VaultClient", ",", "pkiMountpoint", ":", "config", ".", "PKIMountpoint", ",", "}", "\n", "return", "service", ",", "nil", "\n", "}" ]
// New takes a configuration and returns a configured service.
[ "New", "takes", "a", "configuration", "and", "returns", "a", "configured", "service", "." ]
2a6615f61499cd09a8d5ced9a5fade322d2de254
https://github.com/giantswarm/certctl/blob/2a6615f61499cd09a8d5ced9a5fade322d2de254/service/role/service.go#L27-L43
test
giantswarm/certctl
service/role/service.go
Create
func (s *service) Create(params CreateParams) error { logicalStore := s.vaultClient.Logical() data := map[string]interface{}{ "allowed_domains": params.AllowedDomains, "allow_subdomains": params.AllowSubdomains, "ttl": params.TTL, "allow_bare_domains": params.AllowBareDomains, "organization": params.Organizations, } _, err := logicalStore.Write(fmt.Sprintf("%s/roles/%s", s.pkiMountpoint, params.Name), data) if err != nil { return microerror.Mask(err) } return nil }
go
func (s *service) Create(params CreateParams) error { logicalStore := s.vaultClient.Logical() data := map[string]interface{}{ "allowed_domains": params.AllowedDomains, "allow_subdomains": params.AllowSubdomains, "ttl": params.TTL, "allow_bare_domains": params.AllowBareDomains, "organization": params.Organizations, } _, err := logicalStore.Write(fmt.Sprintf("%s/roles/%s", s.pkiMountpoint, params.Name), data) if err != nil { return microerror.Mask(err) } return nil }
[ "func", "(", "s", "*", "service", ")", "Create", "(", "params", "CreateParams", ")", "error", "{", "logicalStore", ":=", "s", ".", "vaultClient", ".", "Logical", "(", ")", "\n", "data", ":=", "map", "[", "string", "]", "interface", "{", "}", "{", "\"allowed_domains\"", ":", "params", ".", "AllowedDomains", ",", "\"allow_subdomains\"", ":", "params", ".", "AllowSubdomains", ",", "\"ttl\"", ":", "params", ".", "TTL", ",", "\"allow_bare_domains\"", ":", "params", ".", "AllowBareDomains", ",", "\"organization\"", ":", "params", ".", "Organizations", ",", "}", "\n", "_", ",", "err", ":=", "logicalStore", ".", "Write", "(", "fmt", ".", "Sprintf", "(", "\"%s/roles/%s\"", ",", "s", ".", "pkiMountpoint", ",", "params", ".", "Name", ")", ",", "data", ")", "\n", "if", "err", "!=", "nil", "{", "return", "microerror", ".", "Mask", "(", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Create creates a role if it doesn't exist yet. Creating roles is idempotent // in the vault api, so no need to check if it already exists.
[ "Create", "creates", "a", "role", "if", "it", "doesn", "t", "exist", "yet", ".", "Creating", "roles", "is", "idempotent", "in", "the", "vault", "api", "so", "no", "need", "to", "check", "if", "it", "already", "exists", "." ]
2a6615f61499cd09a8d5ced9a5fade322d2de254
https://github.com/giantswarm/certctl/blob/2a6615f61499cd09a8d5ced9a5fade322d2de254/service/role/service.go#L55-L71
test
fossapps/captain
captain.go
CreateJob
func CreateJob() Config { return Config{ LockProvider: nil, RuntimeProcessor: nil, ResultProcessor: nil, RuntimeProcessingFrequency: 200 * time.Millisecond, SummaryBuffer: 1, } }
go
func CreateJob() Config { return Config{ LockProvider: nil, RuntimeProcessor: nil, ResultProcessor: nil, RuntimeProcessingFrequency: 200 * time.Millisecond, SummaryBuffer: 1, } }
[ "func", "CreateJob", "(", ")", "Config", "{", "return", "Config", "{", "LockProvider", ":", "nil", ",", "RuntimeProcessor", ":", "nil", ",", "ResultProcessor", ":", "nil", ",", "RuntimeProcessingFrequency", ":", "200", "*", "time", ".", "Millisecond", ",", "SummaryBuffer", ":", "1", ",", "}", "\n", "}" ]
// CreateJob creates a basic empty configuration with some defaults.
[ "CreateJob", "creates", "a", "basic", "empty", "configuration", "with", "some", "defaults", "." ]
0f30dc3a624d523638831aa2bcb08bc962234a95
https://github.com/fossapps/captain/blob/0f30dc3a624d523638831aa2bcb08bc962234a95/captain.go#L44-L52
test
fossapps/captain
captain.go
Run
func (config *Config) Run() { err := config.ensureLock() if err != nil { panic(err) } err = config.runWorker() if err != nil { panic(err) } }
go
func (config *Config) Run() { err := config.ensureLock() if err != nil { panic(err) } err = config.runWorker() if err != nil { panic(err) } }
[ "func", "(", "config", "*", "Config", ")", "Run", "(", ")", "{", "err", ":=", "config", ".", "ensureLock", "(", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "err", "=", "config", ".", "runWorker", "(", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "}" ]
// Run starts the job
[ "Run", "starts", "the", "job" ]
0f30dc3a624d523638831aa2bcb08bc962234a95
https://github.com/fossapps/captain/blob/0f30dc3a624d523638831aa2bcb08bc962234a95/captain.go#L80-L89
test
gokyle/fswatch
watcher.go
newWatcher
func newWatcher(dir_notify bool, initpaths ...string) (w *Watcher) { w = new(Watcher) w.auto_watch = dir_notify w.paths = make(map[string]*watchItem, 0) var paths []string for _, path := range initpaths { matches, err := filepath.Glob(path) if err != nil { continue } paths = append(paths, matches...) } if dir_notify { w.syncAddPaths(paths...) } else { for _, path := range paths { w.paths[path] = watchPath(path) } } return }
go
func newWatcher(dir_notify bool, initpaths ...string) (w *Watcher) { w = new(Watcher) w.auto_watch = dir_notify w.paths = make(map[string]*watchItem, 0) var paths []string for _, path := range initpaths { matches, err := filepath.Glob(path) if err != nil { continue } paths = append(paths, matches...) } if dir_notify { w.syncAddPaths(paths...) } else { for _, path := range paths { w.paths[path] = watchPath(path) } } return }
[ "func", "newWatcher", "(", "dir_notify", "bool", ",", "initpaths", "...", "string", ")", "(", "w", "*", "Watcher", ")", "{", "w", "=", "new", "(", "Watcher", ")", "\n", "w", ".", "auto_watch", "=", "dir_notify", "\n", "w", ".", "paths", "=", "make", "(", "map", "[", "string", "]", "*", "watchItem", ",", "0", ")", "\n", "var", "paths", "[", "]", "string", "\n", "for", "_", ",", "path", ":=", "range", "initpaths", "{", "matches", ",", "err", ":=", "filepath", ".", "Glob", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "continue", "\n", "}", "\n", "paths", "=", "append", "(", "paths", ",", "matches", "...", ")", "\n", "}", "\n", "if", "dir_notify", "{", "w", ".", "syncAddPaths", "(", "paths", "...", ")", "\n", "}", "else", "{", "for", "_", ",", "path", ":=", "range", "paths", "{", "w", ".", "paths", "[", "path", "]", "=", "watchPath", "(", "path", ")", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
// newWatcher is the internal function for properly setting up a new watcher.
[ "newWatcher", "is", "the", "internal", "function", "for", "properly", "setting", "up", "a", "new", "watcher", "." ]
1dbdf8320a690537582afe0f45c947f501adeaad
https://github.com/gokyle/fswatch/blob/1dbdf8320a690537582afe0f45c947f501adeaad/watcher.go#L19-L40
test
gokyle/fswatch
watcher.go
Start
func (w *Watcher) Start() <-chan *Notification { if w.notify_chan != nil { return w.notify_chan } if w.auto_watch { w.add_chan = make(chan *watchItem, NotificationBufLen) go w.watchItemListener() } w.notify_chan = make(chan *Notification, NotificationBufLen) go w.watch(w.notify_chan) return w.notify_chan }
go
func (w *Watcher) Start() <-chan *Notification { if w.notify_chan != nil { return w.notify_chan } if w.auto_watch { w.add_chan = make(chan *watchItem, NotificationBufLen) go w.watchItemListener() } w.notify_chan = make(chan *Notification, NotificationBufLen) go w.watch(w.notify_chan) return w.notify_chan }
[ "func", "(", "w", "*", "Watcher", ")", "Start", "(", ")", "<-", "chan", "*", "Notification", "{", "if", "w", ".", "notify_chan", "!=", "nil", "{", "return", "w", ".", "notify_chan", "\n", "}", "\n", "if", "w", ".", "auto_watch", "{", "w", ".", "add_chan", "=", "make", "(", "chan", "*", "watchItem", ",", "NotificationBufLen", ")", "\n", "go", "w", ".", "watchItemListener", "(", ")", "\n", "}", "\n", "w", ".", "notify_chan", "=", "make", "(", "chan", "*", "Notification", ",", "NotificationBufLen", ")", "\n", "go", "w", ".", "watch", "(", "w", ".", "notify_chan", ")", "\n", "return", "w", ".", "notify_chan", "\n", "}" ]
// Start begins watching the files, sending notifications when files change. // It returns a channel that notifications are sent on.
[ "Start", "begins", "watching", "the", "files", "sending", "notifications", "when", "files", "change", ".", "It", "returns", "a", "channel", "that", "notifications", "are", "sent", "on", "." ]
1dbdf8320a690537582afe0f45c947f501adeaad
https://github.com/gokyle/fswatch/blob/1dbdf8320a690537582afe0f45c947f501adeaad/watcher.go#L59-L70
test
gokyle/fswatch
watcher.go
Stop
func (w *Watcher) Stop() { if w.notify_chan != nil { close(w.notify_chan) } if w.add_chan != nil { close(w.add_chan) } }
go
func (w *Watcher) Stop() { if w.notify_chan != nil { close(w.notify_chan) } if w.add_chan != nil { close(w.add_chan) } }
[ "func", "(", "w", "*", "Watcher", ")", "Stop", "(", ")", "{", "if", "w", ".", "notify_chan", "!=", "nil", "{", "close", "(", "w", ".", "notify_chan", ")", "\n", "}", "\n", "if", "w", ".", "add_chan", "!=", "nil", "{", "close", "(", "w", ".", "add_chan", ")", "\n", "}", "\n", "}" ]
// Stop listening for changes to the files.
[ "Stop", "listening", "for", "changes", "to", "the", "files", "." ]
1dbdf8320a690537582afe0f45c947f501adeaad
https://github.com/gokyle/fswatch/blob/1dbdf8320a690537582afe0f45c947f501adeaad/watcher.go#L73-L81
test
gokyle/fswatch
watcher.go
Active
func (w *Watcher) Active() bool { return w.paths != nil && len(w.paths) > 0 }
go
func (w *Watcher) Active() bool { return w.paths != nil && len(w.paths) > 0 }
[ "func", "(", "w", "*", "Watcher", ")", "Active", "(", ")", "bool", "{", "return", "w", ".", "paths", "!=", "nil", "&&", "len", "(", "w", ".", "paths", ")", ">", "0", "\n", "}" ]
// Returns true if the Watcher is actively looking for changes.
[ "Returns", "true", "if", "the", "Watcher", "is", "actively", "looking", "for", "changes", "." ]
1dbdf8320a690537582afe0f45c947f501adeaad
https://github.com/gokyle/fswatch/blob/1dbdf8320a690537582afe0f45c947f501adeaad/watcher.go#L84-L86
test
gokyle/fswatch
watcher.go
Add
func (w *Watcher) Add(inpaths ...string) { var paths []string for _, path := range inpaths { matches, err := filepath.Glob(path) if err != nil { continue } paths = append(paths, matches...) } if w.auto_watch && w.notify_chan != nil { for _, path := range paths { wi := watchPath(path) w.addPaths(wi) } } else if w.auto_watch { w.syncAddPaths(paths...) } else { for _, path := range paths { w.paths[path] = watchPath(path) } } }
go
func (w *Watcher) Add(inpaths ...string) { var paths []string for _, path := range inpaths { matches, err := filepath.Glob(path) if err != nil { continue } paths = append(paths, matches...) } if w.auto_watch && w.notify_chan != nil { for _, path := range paths { wi := watchPath(path) w.addPaths(wi) } } else if w.auto_watch { w.syncAddPaths(paths...) } else { for _, path := range paths { w.paths[path] = watchPath(path) } } }
[ "func", "(", "w", "*", "Watcher", ")", "Add", "(", "inpaths", "...", "string", ")", "{", "var", "paths", "[", "]", "string", "\n", "for", "_", ",", "path", ":=", "range", "inpaths", "{", "matches", ",", "err", ":=", "filepath", ".", "Glob", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "continue", "\n", "}", "\n", "paths", "=", "append", "(", "paths", ",", "matches", "...", ")", "\n", "}", "\n", "if", "w", ".", "auto_watch", "&&", "w", ".", "notify_chan", "!=", "nil", "{", "for", "_", ",", "path", ":=", "range", "paths", "{", "wi", ":=", "watchPath", "(", "path", ")", "\n", "w", ".", "addPaths", "(", "wi", ")", "\n", "}", "\n", "}", "else", "if", "w", ".", "auto_watch", "{", "w", ".", "syncAddPaths", "(", "paths", "...", ")", "\n", "}", "else", "{", "for", "_", ",", "path", ":=", "range", "paths", "{", "w", ".", "paths", "[", "path", "]", "=", "watchPath", "(", "path", ")", "\n", "}", "\n", "}", "\n", "}" ]
// The Add method takes a variable number of string arguments and adds those // files to the watch list, returning the number of files added.
[ "The", "Add", "method", "takes", "a", "variable", "number", "of", "string", "arguments", "and", "adds", "those", "files", "to", "the", "watch", "list", "returning", "the", "number", "of", "files", "added", "." ]
1dbdf8320a690537582afe0f45c947f501adeaad
https://github.com/gokyle/fswatch/blob/1dbdf8320a690537582afe0f45c947f501adeaad/watcher.go#L90-L111
test
gokyle/fswatch
watcher.go
watch
func (w *Watcher) watch(sndch chan<- *Notification) { defer func() { recover() }() for { <-time.After(WatchDelay) for _, wi := range w.paths { if wi.Update() && w.shouldNotify(wi) { sndch <- wi.Notification() } if wi.LastEvent == NOEXIST && w.auto_watch { delete(w.paths, wi.Path) } if len(w.paths) == 0 { w.Stop() } } } }
go
func (w *Watcher) watch(sndch chan<- *Notification) { defer func() { recover() }() for { <-time.After(WatchDelay) for _, wi := range w.paths { if wi.Update() && w.shouldNotify(wi) { sndch <- wi.Notification() } if wi.LastEvent == NOEXIST && w.auto_watch { delete(w.paths, wi.Path) } if len(w.paths) == 0 { w.Stop() } } } }
[ "func", "(", "w", "*", "Watcher", ")", "watch", "(", "sndch", "chan", "<-", "*", "Notification", ")", "{", "defer", "func", "(", ")", "{", "recover", "(", ")", "\n", "}", "(", ")", "\n", "for", "{", "<-", "time", ".", "After", "(", "WatchDelay", ")", "\n", "for", "_", ",", "wi", ":=", "range", "w", ".", "paths", "{", "if", "wi", ".", "Update", "(", ")", "&&", "w", ".", "shouldNotify", "(", "wi", ")", "{", "sndch", "<-", "wi", ".", "Notification", "(", ")", "\n", "}", "\n", "if", "wi", ".", "LastEvent", "==", "NOEXIST", "&&", "w", ".", "auto_watch", "{", "delete", "(", "w", ".", "paths", ",", "wi", ".", "Path", ")", "\n", "}", "\n", "if", "len", "(", "w", ".", "paths", ")", "==", "0", "{", "w", ".", "Stop", "(", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "}" ]
// goroutine that cycles through the list of paths and checks for updates.
[ "goroutine", "that", "cycles", "through", "the", "list", "of", "paths", "and", "checks", "for", "updates", "." ]
1dbdf8320a690537582afe0f45c947f501adeaad
https://github.com/gokyle/fswatch/blob/1dbdf8320a690537582afe0f45c947f501adeaad/watcher.go#L114-L134
test
gokyle/fswatch
watcher.go
Watching
func (w *Watcher) Watching() (paths []string) { paths = make([]string, 0) for path, _ := range w.paths { paths = append(paths, path) } return }
go
func (w *Watcher) Watching() (paths []string) { paths = make([]string, 0) for path, _ := range w.paths { paths = append(paths, path) } return }
[ "func", "(", "w", "*", "Watcher", ")", "Watching", "(", ")", "(", "paths", "[", "]", "string", ")", "{", "paths", "=", "make", "(", "[", "]", "string", ",", "0", ")", "\n", "for", "path", ",", "_", ":=", "range", "w", ".", "paths", "{", "paths", "=", "append", "(", "paths", ",", "path", ")", "\n", "}", "\n", "return", "\n", "}" ]
// Watching returns a list of the files being watched.
[ "Watching", "returns", "a", "list", "of", "the", "files", "being", "watched", "." ]
1dbdf8320a690537582afe0f45c947f501adeaad
https://github.com/gokyle/fswatch/blob/1dbdf8320a690537582afe0f45c947f501adeaad/watcher.go#L231-L237
test
gokyle/fswatch
watcher.go
State
func (w *Watcher) State() (state []Notification) { state = make([]Notification, 0) if w.paths == nil { return } for _, wi := range w.paths { state = append(state, *wi.Notification()) } return }
go
func (w *Watcher) State() (state []Notification) { state = make([]Notification, 0) if w.paths == nil { return } for _, wi := range w.paths { state = append(state, *wi.Notification()) } return }
[ "func", "(", "w", "*", "Watcher", ")", "State", "(", ")", "(", "state", "[", "]", "Notification", ")", "{", "state", "=", "make", "(", "[", "]", "Notification", ",", "0", ")", "\n", "if", "w", ".", "paths", "==", "nil", "{", "return", "\n", "}", "\n", "for", "_", ",", "wi", ":=", "range", "w", ".", "paths", "{", "state", "=", "append", "(", "state", ",", "*", "wi", ".", "Notification", "(", ")", ")", "\n", "}", "\n", "return", "\n", "}" ]
// State returns a slice of Notifications representing the files being watched // and their last event.
[ "State", "returns", "a", "slice", "of", "Notifications", "representing", "the", "files", "being", "watched", "and", "their", "last", "event", "." ]
1dbdf8320a690537582afe0f45c947f501adeaad
https://github.com/gokyle/fswatch/blob/1dbdf8320a690537582afe0f45c947f501adeaad/watcher.go#L241-L250
test
bluekeyes/hatpear
hatpear.go
Store
func Store(r *http.Request, err error) { errptr, ok := r.Context().Value(errorKey).(*error) if !ok { panic("hatpear: request not configured to store errors") } // check err after checking context to fail fast if unconfigured if err != nil { *errptr = err } }
go
func Store(r *http.Request, err error) { errptr, ok := r.Context().Value(errorKey).(*error) if !ok { panic("hatpear: request not configured to store errors") } // check err after checking context to fail fast if unconfigured if err != nil { *errptr = err } }
[ "func", "Store", "(", "r", "*", "http", ".", "Request", ",", "err", "error", ")", "{", "errptr", ",", "ok", ":=", "r", ".", "Context", "(", ")", ".", "Value", "(", "errorKey", ")", ".", "(", "*", "error", ")", "\n", "if", "!", "ok", "{", "panic", "(", "\"hatpear: request not configured to store errors\"", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "*", "errptr", "=", "err", "\n", "}", "\n", "}" ]
// Store stores an error into the request's context. It panics if the request // was not configured to store errors.
[ "Store", "stores", "an", "error", "into", "the", "request", "s", "context", ".", "It", "panics", "if", "the", "request", "was", "not", "configured", "to", "store", "errors", "." ]
ffb42d5bb417aa8e12b3b7ff73d028b915dafa10
https://github.com/bluekeyes/hatpear/blob/ffb42d5bb417aa8e12b3b7ff73d028b915dafa10/hatpear.go#L26-L35
test
bluekeyes/hatpear
hatpear.go
Get
func Get(r *http.Request) error { errptr, ok := r.Context().Value(errorKey).(*error) if !ok { return nil } return *errptr }
go
func Get(r *http.Request) error { errptr, ok := r.Context().Value(errorKey).(*error) if !ok { return nil } return *errptr }
[ "func", "Get", "(", "r", "*", "http", ".", "Request", ")", "error", "{", "errptr", ",", "ok", ":=", "r", ".", "Context", "(", ")", ".", "Value", "(", "errorKey", ")", ".", "(", "*", "error", ")", "\n", "if", "!", "ok", "{", "return", "nil", "\n", "}", "\n", "return", "*", "errptr", "\n", "}" ]
// Get retrieves an error from the request's context. It returns nil if the // request was not configured to store errors.
[ "Get", "retrieves", "an", "error", "from", "the", "request", "s", "context", ".", "It", "returns", "nil", "if", "the", "request", "was", "not", "configured", "to", "store", "errors", "." ]
ffb42d5bb417aa8e12b3b7ff73d028b915dafa10
https://github.com/bluekeyes/hatpear/blob/ffb42d5bb417aa8e12b3b7ff73d028b915dafa10/hatpear.go#L39-L45
test
bluekeyes/hatpear
hatpear.go
Catch
func Catch(h func(w http.ResponseWriter, r *http.Request, err error)) Middleware { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var err error ctx := context.WithValue(r.Context(), errorKey, &err) next.ServeHTTP(w, r.WithContext(ctx)) if err != nil { h(w, r, err) } }) } }
go
func Catch(h func(w http.ResponseWriter, r *http.Request, err error)) Middleware { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var err error ctx := context.WithValue(r.Context(), errorKey, &err) next.ServeHTTP(w, r.WithContext(ctx)) if err != nil { h(w, r, err) } }) } }
[ "func", "Catch", "(", "h", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "err", "error", ")", ")", "Middleware", "{", "return", "func", "(", "next", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "var", "err", "error", "\n", "ctx", ":=", "context", ".", "WithValue", "(", "r", ".", "Context", "(", ")", ",", "errorKey", ",", "&", "err", ")", "\n", "next", ".", "ServeHTTP", "(", "w", ",", "r", ".", "WithContext", "(", "ctx", ")", ")", "\n", "if", "err", "!=", "nil", "{", "h", "(", "w", ",", "r", ",", "err", ")", "\n", "}", "\n", "}", ")", "\n", "}", "\n", "}" ]
// Catch creates middleware that processes errors stored while serving a // request. Errors are passed to the callback, which should write them to the // response in an appropriate format. This is usually the outermost middleware // in a chain.
[ "Catch", "creates", "middleware", "that", "processes", "errors", "stored", "while", "serving", "a", "request", ".", "Errors", "are", "passed", "to", "the", "callback", "which", "should", "write", "them", "to", "the", "response", "in", "an", "appropriate", "format", ".", "This", "is", "usually", "the", "outermost", "middleware", "in", "a", "chain", "." ]
ffb42d5bb417aa8e12b3b7ff73d028b915dafa10
https://github.com/bluekeyes/hatpear/blob/ffb42d5bb417aa8e12b3b7ff73d028b915dafa10/hatpear.go#L54-L66
test
bluekeyes/hatpear
hatpear.go
Try
func Try(h Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { err := h.ServeHTTP(w, r) Store(r, err) }) }
go
func Try(h Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { err := h.ServeHTTP(w, r) Store(r, err) }) }
[ "func", "Try", "(", "h", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "err", ":=", "h", ".", "ServeHTTP", "(", "w", ",", "r", ")", "\n", "Store", "(", "r", ",", "err", ")", "\n", "}", ")", "\n", "}" ]
// Try converts a handler to a standard http.Handler, storing any error in the // request's context.
[ "Try", "converts", "a", "handler", "to", "a", "standard", "http", ".", "Handler", "storing", "any", "error", "in", "the", "request", "s", "context", "." ]
ffb42d5bb417aa8e12b3b7ff73d028b915dafa10
https://github.com/bluekeyes/hatpear/blob/ffb42d5bb417aa8e12b3b7ff73d028b915dafa10/hatpear.go#L82-L87
test
bluekeyes/hatpear
hatpear.go
Recover
func Recover() Middleware { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer func() { if v := recover(); v != nil { Store(r, PanicError{ value: v, stack: stack(1), }) } }() next.ServeHTTP(w, r) }) } }
go
func Recover() Middleware { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer func() { if v := recover(); v != nil { Store(r, PanicError{ value: v, stack: stack(1), }) } }() next.ServeHTTP(w, r) }) } }
[ "func", "Recover", "(", ")", "Middleware", "{", "return", "func", "(", "next", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "defer", "func", "(", ")", "{", "if", "v", ":=", "recover", "(", ")", ";", "v", "!=", "nil", "{", "Store", "(", "r", ",", "PanicError", "{", "value", ":", "v", ",", "stack", ":", "stack", "(", "1", ")", ",", "}", ")", "\n", "}", "\n", "}", "(", ")", "\n", "next", ".", "ServeHTTP", "(", "w", ",", "r", ")", "\n", "}", ")", "\n", "}", "\n", "}" ]
// Recover creates middleware that can recover from a panic in a handler, // storing a PanicError for future handling.
[ "Recover", "creates", "middleware", "that", "can", "recover", "from", "a", "panic", "in", "a", "handler", "storing", "a", "PanicError", "for", "future", "handling", "." ]
ffb42d5bb417aa8e12b3b7ff73d028b915dafa10
https://github.com/bluekeyes/hatpear/blob/ffb42d5bb417aa8e12b3b7ff73d028b915dafa10/hatpear.go#L96-L110
test
jpillora/velox
example/go/perf/client/client.go
main
func main() { req, _ := http.NewRequest("GET", "http://localhost:7070/sync", nil) req.Header.Set("Accept", "text/event-stream") resp, err := http.DefaultClient.Do(req) if err != nil { log.Fatalf("request: %s", err) } r := resp.Body i := 0 buff := make([]byte, 32*1024) for { n, err := r.Read(buff) if err != nil { break } i++ log.Printf("#%d: %s", i, sizestr.ToString(int64(n))) } r.Close() log.Printf("closed") }
go
func main() { req, _ := http.NewRequest("GET", "http://localhost:7070/sync", nil) req.Header.Set("Accept", "text/event-stream") resp, err := http.DefaultClient.Do(req) if err != nil { log.Fatalf("request: %s", err) } r := resp.Body i := 0 buff := make([]byte, 32*1024) for { n, err := r.Read(buff) if err != nil { break } i++ log.Printf("#%d: %s", i, sizestr.ToString(int64(n))) } r.Close() log.Printf("closed") }
[ "func", "main", "(", ")", "{", "req", ",", "_", ":=", "http", ".", "NewRequest", "(", "\"GET\"", ",", "\"http://localhost:7070/sync\"", ",", "nil", ")", "\n", "req", ".", "Header", ".", "Set", "(", "\"Accept\"", ",", "\"text/event-stream\"", ")", "\n", "resp", ",", "err", ":=", "http", ".", "DefaultClient", ".", "Do", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fatalf", "(", "\"request: %s\"", ",", "err", ")", "\n", "}", "\n", "r", ":=", "resp", ".", "Body", "\n", "i", ":=", "0", "\n", "buff", ":=", "make", "(", "[", "]", "byte", ",", "32", "*", "1024", ")", "\n", "for", "{", "n", ",", "err", ":=", "r", ".", "Read", "(", "buff", ")", "\n", "if", "err", "!=", "nil", "{", "break", "\n", "}", "\n", "i", "++", "\n", "log", ".", "Printf", "(", "\"#%d: %s\"", ",", "i", ",", "sizestr", ".", "ToString", "(", "int64", "(", "n", ")", ")", ")", "\n", "}", "\n", "r", ".", "Close", "(", ")", "\n", "log", ".", "Printf", "(", "\"closed\"", ")", "\n", "}" ]
//go client for performance testing
[ "go", "client", "for", "performance", "testing" ]
42845d32322027cde41ba6b065a083ea4120238f
https://github.com/jpillora/velox/blob/42845d32322027cde41ba6b065a083ea4120238f/example/go/perf/client/client.go#L12-L34
test
jpillora/velox
go/sync.go
SyncHandler
func SyncHandler(gostruct interface{}) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if conn, err := Sync(gostruct, w, r); err != nil { log.Printf("[velox] sync handler error: %s", err) } else { conn.Wait() } }) }
go
func SyncHandler(gostruct interface{}) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if conn, err := Sync(gostruct, w, r); err != nil { log.Printf("[velox] sync handler error: %s", err) } else { conn.Wait() } }) }
[ "func", "SyncHandler", "(", "gostruct", "interface", "{", "}", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "conn", ",", "err", ":=", "Sync", "(", "gostruct", ",", "w", ",", "r", ")", ";", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"[velox] sync handler error: %s\"", ",", "err", ")", "\n", "}", "else", "{", "conn", ".", "Wait", "(", ")", "\n", "}", "\n", "}", ")", "\n", "}" ]
//SyncHandler is a small wrapper around Sync which simply synchronises //all incoming connections. Use Sync if you wish to implement user authentication //or any other request-time checks.
[ "SyncHandler", "is", "a", "small", "wrapper", "around", "Sync", "which", "simply", "synchronises", "all", "incoming", "connections", ".", "Use", "Sync", "if", "you", "wish", "to", "implement", "user", "authentication", "or", "any", "other", "request", "-", "time", "checks", "." ]
42845d32322027cde41ba6b065a083ea4120238f
https://github.com/jpillora/velox/blob/42845d32322027cde41ba6b065a083ea4120238f/go/sync.go#L21-L29
test
jpillora/velox
go/conn.go
connect
func (c *conn) connect(w http.ResponseWriter, r *http.Request) error { //choose transport if r.Header.Get("Accept") == "text/event-stream" { c.transport = &eventSourceTransport{writeTimeout: c.state.WriteTimeout} } else if r.Header.Get("Upgrade") == "websocket" { c.transport = &websocketsTransport{writeTimeout: c.state.WriteTimeout} } else { return fmt.Errorf("Invalid sync request") } //non-blocking connect to client over set transport if err := c.transport.connect(w, r); err != nil { return err } //initial ping if err := c.send(&update{Ping: true}); err != nil { return fmt.Errorf("Failed to send initial event") } //successfully connected c.connected = true c.waiter.Add(1) //while connected, ping loop (every 25s, browser timesout after 30s) go func() { for { select { case <-time.After(c.state.PingInterval): if err := c.send(&update{Ping: true}); err != nil { goto disconnected } case <-c.connectedCh: goto disconnected } } disconnected: c.connected = false c.Close() //unblock waiters c.waiter.Done() }() //non-blocking wait on connection go func() { if err := c.transport.wait(); err != nil { //log error? } close(c.connectedCh) }() //now connected, consumer can connection.Wait() return nil }
go
func (c *conn) connect(w http.ResponseWriter, r *http.Request) error { //choose transport if r.Header.Get("Accept") == "text/event-stream" { c.transport = &eventSourceTransport{writeTimeout: c.state.WriteTimeout} } else if r.Header.Get("Upgrade") == "websocket" { c.transport = &websocketsTransport{writeTimeout: c.state.WriteTimeout} } else { return fmt.Errorf("Invalid sync request") } //non-blocking connect to client over set transport if err := c.transport.connect(w, r); err != nil { return err } //initial ping if err := c.send(&update{Ping: true}); err != nil { return fmt.Errorf("Failed to send initial event") } //successfully connected c.connected = true c.waiter.Add(1) //while connected, ping loop (every 25s, browser timesout after 30s) go func() { for { select { case <-time.After(c.state.PingInterval): if err := c.send(&update{Ping: true}); err != nil { goto disconnected } case <-c.connectedCh: goto disconnected } } disconnected: c.connected = false c.Close() //unblock waiters c.waiter.Done() }() //non-blocking wait on connection go func() { if err := c.transport.wait(); err != nil { //log error? } close(c.connectedCh) }() //now connected, consumer can connection.Wait() return nil }
[ "func", "(", "c", "*", "conn", ")", "connect", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "error", "{", "if", "r", ".", "Header", ".", "Get", "(", "\"Accept\"", ")", "==", "\"text/event-stream\"", "{", "c", ".", "transport", "=", "&", "eventSourceTransport", "{", "writeTimeout", ":", "c", ".", "state", ".", "WriteTimeout", "}", "\n", "}", "else", "if", "r", ".", "Header", ".", "Get", "(", "\"Upgrade\"", ")", "==", "\"websocket\"", "{", "c", ".", "transport", "=", "&", "websocketsTransport", "{", "writeTimeout", ":", "c", ".", "state", ".", "WriteTimeout", "}", "\n", "}", "else", "{", "return", "fmt", ".", "Errorf", "(", "\"Invalid sync request\"", ")", "\n", "}", "\n", "if", "err", ":=", "c", ".", "transport", ".", "connect", "(", "w", ",", "r", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "c", ".", "send", "(", "&", "update", "{", "Ping", ":", "true", "}", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"Failed to send initial event\"", ")", "\n", "}", "\n", "c", ".", "connected", "=", "true", "\n", "c", ".", "waiter", ".", "Add", "(", "1", ")", "\n", "go", "func", "(", ")", "{", "for", "{", "select", "{", "case", "<-", "time", ".", "After", "(", "c", ".", "state", ".", "PingInterval", ")", ":", "if", "err", ":=", "c", ".", "send", "(", "&", "update", "{", "Ping", ":", "true", "}", ")", ";", "err", "!=", "nil", "{", "goto", "disconnected", "\n", "}", "\n", "case", "<-", "c", ".", "connectedCh", ":", "goto", "disconnected", "\n", "}", "\n", "}", "\n", "disconnected", ":", "c", ".", "connected", "=", "false", "\n", "c", ".", "Close", "(", ")", "\n", "c", ".", "waiter", ".", "Done", "(", ")", "\n", "}", "(", ")", "\n", "go", "func", "(", ")", "{", "if", "err", ":=", "c", ".", "transport", ".", "wait", "(", ")", ";", "err", "!=", "nil", "{", "}", "\n", "close", "(", "c", ".", "connectedCh", ")", "\n", "}", "(", ")", "\n", "return", "nil", "\n", "}" ]
//connect using the provided transport //and block until connection is ready
[ "connect", "using", "the", "provided", "transport", "and", "block", "until", "connection", "is", "ready" ]
42845d32322027cde41ba6b065a083ea4120238f
https://github.com/jpillora/velox/blob/42845d32322027cde41ba6b065a083ea4120238f/go/conn.go#L76-L123
test
jpillora/velox
go/conn.go
send
func (c *conn) send(upd *update) error { c.sendingMut.Lock() defer c.sendingMut.Unlock() //send (transports responsiblity to enforce timeouts) return c.transport.send(upd) }
go
func (c *conn) send(upd *update) error { c.sendingMut.Lock() defer c.sendingMut.Unlock() //send (transports responsiblity to enforce timeouts) return c.transport.send(upd) }
[ "func", "(", "c", "*", "conn", ")", "send", "(", "upd", "*", "update", ")", "error", "{", "c", ".", "sendingMut", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "sendingMut", ".", "Unlock", "(", ")", "\n", "return", "c", ".", "transport", ".", "send", "(", "upd", ")", "\n", "}" ]
//send to connection, ensure only 1 concurrent sender
[ "send", "to", "connection", "ensure", "only", "1", "concurrent", "sender" ]
42845d32322027cde41ba6b065a083ea4120238f
https://github.com/jpillora/velox/blob/42845d32322027cde41ba6b065a083ea4120238f/go/conn.go#L177-L182
test
jpillora/velox
go/state.go
NumConnections
func (s *State) NumConnections() int { s.connMut.Lock() n := len(s.conns) s.connMut.Unlock() return n }
go
func (s *State) NumConnections() int { s.connMut.Lock() n := len(s.conns) s.connMut.Unlock() return n }
[ "func", "(", "s", "*", "State", ")", "NumConnections", "(", ")", "int", "{", "s", ".", "connMut", ".", "Lock", "(", ")", "\n", "n", ":=", "len", "(", "s", ".", "conns", ")", "\n", "s", ".", "connMut", ".", "Unlock", "(", ")", "\n", "return", "n", "\n", "}" ]
//NumConnections currently active
[ "NumConnections", "currently", "active" ]
42845d32322027cde41ba6b065a083ea4120238f
https://github.com/jpillora/velox/blob/42845d32322027cde41ba6b065a083ea4120238f/go/state.go#L135-L140
test
jpillora/velox
go/state.go
Push
func (s *State) Push() bool { //attempt to mark state as 'pushing' if atomic.CompareAndSwapUint32(&s.push.ing, 0, 1) { go s.gopush() return true } //if already pushing, mark queued atomic.StoreUint32(&s.push.queued, 1) return false }
go
func (s *State) Push() bool { //attempt to mark state as 'pushing' if atomic.CompareAndSwapUint32(&s.push.ing, 0, 1) { go s.gopush() return true } //if already pushing, mark queued atomic.StoreUint32(&s.push.queued, 1) return false }
[ "func", "(", "s", "*", "State", ")", "Push", "(", ")", "bool", "{", "if", "atomic", ".", "CompareAndSwapUint32", "(", "&", "s", ".", "push", ".", "ing", ",", "0", ",", "1", ")", "{", "go", "s", ".", "gopush", "(", ")", "\n", "return", "true", "\n", "}", "\n", "atomic", ".", "StoreUint32", "(", "&", "s", ".", "push", ".", "queued", ",", "1", ")", "\n", "return", "false", "\n", "}" ]
//Push the changes from this object to all connected clients. //Push is thread-safe and is throttled so it can be called //with abandon. Returns false if a Push is already in progress.
[ "Push", "the", "changes", "from", "this", "object", "to", "all", "connected", "clients", ".", "Push", "is", "thread", "-", "safe", "and", "is", "throttled", "so", "it", "can", "be", "called", "with", "abandon", ".", "Returns", "false", "if", "a", "Push", "is", "already", "in", "progress", "." ]
42845d32322027cde41ba6b065a083ea4120238f
https://github.com/jpillora/velox/blob/42845d32322027cde41ba6b065a083ea4120238f/go/state.go#L145-L154
test
jpillora/velox
go/state.go
gopush
func (s *State) gopush() { s.push.mut.Lock() t0 := time.Now() //queue cleanup defer func() { //measure time passed, ensure we wait at least Throttle time tdelta := time.Now().Sub(t0) if t := s.Throttle - tdelta; t > 0 { time.Sleep(t) } //push complete s.push.mut.Unlock() atomic.StoreUint32(&s.push.ing, 0) //if queued, auto-push again if atomic.CompareAndSwapUint32(&s.push.queued, 1, 0) { s.Push() } }() //calculate new json state l, hasLock := s.gostruct.(sync.Locker) if hasLock { l.Lock() } newBytes, err := json.Marshal(s.gostruct) if hasLock { l.Unlock() } if err != nil { log.Printf("velox: marshal failed: %s", err) return } //if changed, then calculate change set if !bytes.Equal(s.data.bytes, newBytes) { //calculate change set from last version ops, _ := jsonpatch.CreatePatch(s.data.bytes, newBytes) if len(s.data.bytes) > 0 && len(ops) > 0 { //changes! bump version s.data.mut.Lock() s.data.delta, _ = json.Marshal(ops) s.data.bytes = newBytes s.data.version++ s.data.mut.Unlock() } } //send this new change to each subscriber s.connMut.Lock() for _, c := range s.conns { if c.version != s.data.version { go c.push() } } s.connMut.Unlock() //defered cleanup() }
go
func (s *State) gopush() { s.push.mut.Lock() t0 := time.Now() //queue cleanup defer func() { //measure time passed, ensure we wait at least Throttle time tdelta := time.Now().Sub(t0) if t := s.Throttle - tdelta; t > 0 { time.Sleep(t) } //push complete s.push.mut.Unlock() atomic.StoreUint32(&s.push.ing, 0) //if queued, auto-push again if atomic.CompareAndSwapUint32(&s.push.queued, 1, 0) { s.Push() } }() //calculate new json state l, hasLock := s.gostruct.(sync.Locker) if hasLock { l.Lock() } newBytes, err := json.Marshal(s.gostruct) if hasLock { l.Unlock() } if err != nil { log.Printf("velox: marshal failed: %s", err) return } //if changed, then calculate change set if !bytes.Equal(s.data.bytes, newBytes) { //calculate change set from last version ops, _ := jsonpatch.CreatePatch(s.data.bytes, newBytes) if len(s.data.bytes) > 0 && len(ops) > 0 { //changes! bump version s.data.mut.Lock() s.data.delta, _ = json.Marshal(ops) s.data.bytes = newBytes s.data.version++ s.data.mut.Unlock() } } //send this new change to each subscriber s.connMut.Lock() for _, c := range s.conns { if c.version != s.data.version { go c.push() } } s.connMut.Unlock() //defered cleanup() }
[ "func", "(", "s", "*", "State", ")", "gopush", "(", ")", "{", "s", ".", "push", ".", "mut", ".", "Lock", "(", ")", "\n", "t0", ":=", "time", ".", "Now", "(", ")", "\n", "defer", "func", "(", ")", "{", "tdelta", ":=", "time", ".", "Now", "(", ")", ".", "Sub", "(", "t0", ")", "\n", "if", "t", ":=", "s", ".", "Throttle", "-", "tdelta", ";", "t", ">", "0", "{", "time", ".", "Sleep", "(", "t", ")", "\n", "}", "\n", "s", ".", "push", ".", "mut", ".", "Unlock", "(", ")", "\n", "atomic", ".", "StoreUint32", "(", "&", "s", ".", "push", ".", "ing", ",", "0", ")", "\n", "if", "atomic", ".", "CompareAndSwapUint32", "(", "&", "s", ".", "push", ".", "queued", ",", "1", ",", "0", ")", "{", "s", ".", "Push", "(", ")", "\n", "}", "\n", "}", "(", ")", "\n", "l", ",", "hasLock", ":=", "s", ".", "gostruct", ".", "(", "sync", ".", "Locker", ")", "\n", "if", "hasLock", "{", "l", ".", "Lock", "(", ")", "\n", "}", "\n", "newBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "s", ".", "gostruct", ")", "\n", "if", "hasLock", "{", "l", ".", "Unlock", "(", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"velox: marshal failed: %s\"", ",", "err", ")", "\n", "return", "\n", "}", "\n", "if", "!", "bytes", ".", "Equal", "(", "s", ".", "data", ".", "bytes", ",", "newBytes", ")", "{", "ops", ",", "_", ":=", "jsonpatch", ".", "CreatePatch", "(", "s", ".", "data", ".", "bytes", ",", "newBytes", ")", "\n", "if", "len", "(", "s", ".", "data", ".", "bytes", ")", ">", "0", "&&", "len", "(", "ops", ")", ">", "0", "{", "s", ".", "data", ".", "mut", ".", "Lock", "(", ")", "\n", "s", ".", "data", ".", "delta", ",", "_", "=", "json", ".", "Marshal", "(", "ops", ")", "\n", "s", ".", "data", ".", "bytes", "=", "newBytes", "\n", "s", ".", "data", ".", "version", "++", "\n", "s", ".", "data", ".", "mut", ".", "Unlock", "(", ")", "\n", "}", "\n", "}", "\n", "s", ".", "connMut", ".", "Lock", "(", ")", "\n", "for", "_", ",", "c", ":=", "range", "s", ".", "conns", "{", "if", "c", ".", "version", "!=", "s", ".", "data", ".", "version", "{", "go", "c", ".", "push", "(", ")", "\n", "}", "\n", "}", "\n", "s", ".", "connMut", ".", "Unlock", "(", ")", "\n", "}" ]
//non-blocking push
[ "non", "-", "blocking", "push" ]
42845d32322027cde41ba6b065a083ea4120238f
https://github.com/jpillora/velox/blob/42845d32322027cde41ba6b065a083ea4120238f/go/state.go#L157-L210
test
fujiwara/fluent-agent-hydra
hydra/out_forward.go
NewOutForward
func NewOutForward(configServers []*ConfigServer) (*OutForward, error) { loggers := make([]*fluent.Fluent, len(configServers)) for i, server := range configServers { logger, err := fluent.New(fluent.Config{Server: server.Address()}) if err != nil { log.Println("[warning]", err) } else { log.Println("[info] Server", server.Address(), "connected") } loggers[i] = logger logger.Send([]byte{}) } return &OutForward{ loggers: loggers, sent: 0, }, nil }
go
func NewOutForward(configServers []*ConfigServer) (*OutForward, error) { loggers := make([]*fluent.Fluent, len(configServers)) for i, server := range configServers { logger, err := fluent.New(fluent.Config{Server: server.Address()}) if err != nil { log.Println("[warning]", err) } else { log.Println("[info] Server", server.Address(), "connected") } loggers[i] = logger logger.Send([]byte{}) } return &OutForward{ loggers: loggers, sent: 0, }, nil }
[ "func", "NewOutForward", "(", "configServers", "[", "]", "*", "ConfigServer", ")", "(", "*", "OutForward", ",", "error", ")", "{", "loggers", ":=", "make", "(", "[", "]", "*", "fluent", ".", "Fluent", ",", "len", "(", "configServers", ")", ")", "\n", "for", "i", ",", "server", ":=", "range", "configServers", "{", "logger", ",", "err", ":=", "fluent", ".", "New", "(", "fluent", ".", "Config", "{", "Server", ":", "server", ".", "Address", "(", ")", "}", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Println", "(", "\"[warning]\"", ",", "err", ")", "\n", "}", "else", "{", "log", ".", "Println", "(", "\"[info] Server\"", ",", "server", ".", "Address", "(", ")", ",", "\"connected\"", ")", "\n", "}", "\n", "loggers", "[", "i", "]", "=", "logger", "\n", "logger", ".", "Send", "(", "[", "]", "byte", "{", "}", ")", "\n", "}", "\n", "return", "&", "OutForward", "{", "loggers", ":", "loggers", ",", "sent", ":", "0", ",", "}", ",", "nil", "\n", "}" ]
// OutForward ... recieve FluentRecordSet from channel, and send it to passed loggers until success.
[ "OutForward", "...", "recieve", "FluentRecordSet", "from", "channel", "and", "send", "it", "to", "passed", "loggers", "until", "success", "." ]
f5c1c02a0b892cf5c08918ec2ff7bbca71cc7e4f
https://github.com/fujiwara/fluent-agent-hydra/blob/f5c1c02a0b892cf5c08918ec2ff7bbca71cc7e4f/hydra/out_forward.go#L24-L40
test
fujiwara/fluent-agent-hydra
hydra/in_tail.go
Run
func (t *InTail) Run(c *Context) { c.InputProcess.Add(1) defer c.InputProcess.Done() t.messageCh = c.MessageCh t.monitorCh = c.MonitorCh c.StartProcess.Done() if t.eventCh == nil { err := t.TailStdin(c) if err != nil { if _, ok := err.(Signal); ok { log.Println("[info]", err) } else { log.Println("[error]", err) } return } } log.Println("[info] Trying trail file", t.filename) f, err := t.newTrailFile(SEEK_TAIL, c) if err != nil { if _, ok := err.(Signal); ok { log.Println("[info]", err) } else { log.Println("[error]", err) } return } for { for { err := t.watchFileEvent(f, c) if err != nil { if _, ok := err.(Signal); ok { log.Println("[info]", err) return } else { log.Println("[warning]", err) break } } } // re open file var err error f, err = t.newTrailFile(SEEK_HEAD, c) if err != nil { if _, ok := err.(Signal); ok { log.Println("[info]", err) } else { log.Println("[error]", err) } return } } }
go
func (t *InTail) Run(c *Context) { c.InputProcess.Add(1) defer c.InputProcess.Done() t.messageCh = c.MessageCh t.monitorCh = c.MonitorCh c.StartProcess.Done() if t.eventCh == nil { err := t.TailStdin(c) if err != nil { if _, ok := err.(Signal); ok { log.Println("[info]", err) } else { log.Println("[error]", err) } return } } log.Println("[info] Trying trail file", t.filename) f, err := t.newTrailFile(SEEK_TAIL, c) if err != nil { if _, ok := err.(Signal); ok { log.Println("[info]", err) } else { log.Println("[error]", err) } return } for { for { err := t.watchFileEvent(f, c) if err != nil { if _, ok := err.(Signal); ok { log.Println("[info]", err) return } else { log.Println("[warning]", err) break } } } // re open file var err error f, err = t.newTrailFile(SEEK_HEAD, c) if err != nil { if _, ok := err.(Signal); ok { log.Println("[info]", err) } else { log.Println("[error]", err) } return } } }
[ "func", "(", "t", "*", "InTail", ")", "Run", "(", "c", "*", "Context", ")", "{", "c", ".", "InputProcess", ".", "Add", "(", "1", ")", "\n", "defer", "c", ".", "InputProcess", ".", "Done", "(", ")", "\n", "t", ".", "messageCh", "=", "c", ".", "MessageCh", "\n", "t", ".", "monitorCh", "=", "c", ".", "MonitorCh", "\n", "c", ".", "StartProcess", ".", "Done", "(", ")", "\n", "if", "t", ".", "eventCh", "==", "nil", "{", "err", ":=", "t", ".", "TailStdin", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "err", ".", "(", "Signal", ")", ";", "ok", "{", "log", ".", "Println", "(", "\"[info]\"", ",", "err", ")", "\n", "}", "else", "{", "log", ".", "Println", "(", "\"[error]\"", ",", "err", ")", "\n", "}", "\n", "return", "\n", "}", "\n", "}", "\n", "log", ".", "Println", "(", "\"[info] Trying trail file\"", ",", "t", ".", "filename", ")", "\n", "f", ",", "err", ":=", "t", ".", "newTrailFile", "(", "SEEK_TAIL", ",", "c", ")", "\n", "if", "err", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "err", ".", "(", "Signal", ")", ";", "ok", "{", "log", ".", "Println", "(", "\"[info]\"", ",", "err", ")", "\n", "}", "else", "{", "log", ".", "Println", "(", "\"[error]\"", ",", "err", ")", "\n", "}", "\n", "return", "\n", "}", "\n", "for", "{", "for", "{", "err", ":=", "t", ".", "watchFileEvent", "(", "f", ",", "c", ")", "\n", "if", "err", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "err", ".", "(", "Signal", ")", ";", "ok", "{", "log", ".", "Println", "(", "\"[info]\"", ",", "err", ")", "\n", "return", "\n", "}", "else", "{", "log", ".", "Println", "(", "\"[warning]\"", ",", "err", ")", "\n", "break", "\n", "}", "\n", "}", "\n", "}", "\n", "var", "err", "error", "\n", "f", ",", "err", "=", "t", ".", "newTrailFile", "(", "SEEK_HEAD", ",", "c", ")", "\n", "if", "err", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "err", ".", "(", "Signal", ")", ";", "ok", "{", "log", ".", "Println", "(", "\"[info]\"", ",", "err", ")", "\n", "}", "else", "{", "log", ".", "Println", "(", "\"[error]\"", ",", "err", ")", "\n", "}", "\n", "return", "\n", "}", "\n", "}", "\n", "}" ]
// InTail follow the tail of file and post BulkMessage to channel.
[ "InTail", "follow", "the", "tail", "of", "file", "and", "post", "BulkMessage", "to", "channel", "." ]
f5c1c02a0b892cf5c08918ec2ff7bbca71cc7e4f
https://github.com/fujiwara/fluent-agent-hydra/blob/f5c1c02a0b892cf5c08918ec2ff7bbca71cc7e4f/hydra/in_tail.go#L148-L204
test
fujiwara/fluent-agent-hydra
fluent/fluent.go
New
func New(config Config) (f *Fluent, err error) { if config.Server == "" { config.Server = defaultServer } if config.Timeout == 0 { config.Timeout = defaultTimeout } if config.RetryWait == 0 { config.RetryWait = defaultRetryWait } if config.MaxRetry == 0 { config.MaxRetry = defaultMaxRetry } f = &Fluent{ Config: config, reconnecting: false, cancelReconnect: make(chan bool), } err = f.connect() return }
go
func New(config Config) (f *Fluent, err error) { if config.Server == "" { config.Server = defaultServer } if config.Timeout == 0 { config.Timeout = defaultTimeout } if config.RetryWait == 0 { config.RetryWait = defaultRetryWait } if config.MaxRetry == 0 { config.MaxRetry = defaultMaxRetry } f = &Fluent{ Config: config, reconnecting: false, cancelReconnect: make(chan bool), } err = f.connect() return }
[ "func", "New", "(", "config", "Config", ")", "(", "f", "*", "Fluent", ",", "err", "error", ")", "{", "if", "config", ".", "Server", "==", "\"\"", "{", "config", ".", "Server", "=", "defaultServer", "\n", "}", "\n", "if", "config", ".", "Timeout", "==", "0", "{", "config", ".", "Timeout", "=", "defaultTimeout", "\n", "}", "\n", "if", "config", ".", "RetryWait", "==", "0", "{", "config", ".", "RetryWait", "=", "defaultRetryWait", "\n", "}", "\n", "if", "config", ".", "MaxRetry", "==", "0", "{", "config", ".", "MaxRetry", "=", "defaultMaxRetry", "\n", "}", "\n", "f", "=", "&", "Fluent", "{", "Config", ":", "config", ",", "reconnecting", ":", "false", ",", "cancelReconnect", ":", "make", "(", "chan", "bool", ")", ",", "}", "\n", "err", "=", "f", ".", "connect", "(", ")", "\n", "return", "\n", "}" ]
// New creates a new Logger.
[ "New", "creates", "a", "new", "Logger", "." ]
f5c1c02a0b892cf5c08918ec2ff7bbca71cc7e4f
https://github.com/fujiwara/fluent-agent-hydra/blob/f5c1c02a0b892cf5c08918ec2ff7bbca71cc7e4f/fluent/fluent.go#L66-L86
test
fujiwara/fluent-agent-hydra
fluent/fluent.go
Close
func (f *Fluent) Close() (err error) { if f.conn != nil { f.mu.Lock() defer f.mu.Unlock() } else { return } if f.conn != nil { f.conn.Close() f.conn = nil } return }
go
func (f *Fluent) Close() (err error) { if f.conn != nil { f.mu.Lock() defer f.mu.Unlock() } else { return } if f.conn != nil { f.conn.Close() f.conn = nil } return }
[ "func", "(", "f", "*", "Fluent", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "if", "f", ".", "conn", "!=", "nil", "{", "f", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "mu", ".", "Unlock", "(", ")", "\n", "}", "else", "{", "return", "\n", "}", "\n", "if", "f", ".", "conn", "!=", "nil", "{", "f", ".", "conn", ".", "Close", "(", ")", "\n", "f", ".", "conn", "=", "nil", "\n", "}", "\n", "return", "\n", "}" ]
// Close closes the connection.
[ "Close", "closes", "the", "connection", "." ]
f5c1c02a0b892cf5c08918ec2ff7bbca71cc7e4f
https://github.com/fujiwara/fluent-agent-hydra/blob/f5c1c02a0b892cf5c08918ec2ff7bbca71cc7e4f/fluent/fluent.go#L89-L101
test
fujiwara/fluent-agent-hydra
fluent/fluent.go
IsReconnecting
func (f *Fluent) IsReconnecting() bool { f.mu.Lock() defer f.mu.Unlock() return f.reconnecting }
go
func (f *Fluent) IsReconnecting() bool { f.mu.Lock() defer f.mu.Unlock() return f.reconnecting }
[ "func", "(", "f", "*", "Fluent", ")", "IsReconnecting", "(", ")", "bool", "{", "f", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "f", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "f", ".", "reconnecting", "\n", "}" ]
// IsReconnecting return true if a reconnecting process in progress.
[ "IsReconnecting", "return", "true", "if", "a", "reconnecting", "process", "in", "progress", "." ]
f5c1c02a0b892cf5c08918ec2ff7bbca71cc7e4f
https://github.com/fujiwara/fluent-agent-hydra/blob/f5c1c02a0b892cf5c08918ec2ff7bbca71cc7e4f/fluent/fluent.go#L121-L125
test
fujiwara/fluent-agent-hydra
fluent/fluent.go
connect
func (f *Fluent) connect() (err error) { host, port, err := net.SplitHostPort(f.Server) if err != nil { return err } addrs, err := net.LookupHost(host) if err != nil || len(addrs) == 0 { return err } // for DNS round robin n := Rand.Intn(len(addrs)) addr := addrs[n] var format string if strings.Contains(addr, ":") { // v6 format = "[%s]:%s" } else { // v4 format = "%s:%s" } resolved := fmt.Sprintf(format, addr, port) log.Printf("[info] Connect to %s (%s)", f.Server, resolved) f.conn, err = net.DialTimeout("tcp", resolved, f.Config.Timeout) f.recordError(err) return }
go
func (f *Fluent) connect() (err error) { host, port, err := net.SplitHostPort(f.Server) if err != nil { return err } addrs, err := net.LookupHost(host) if err != nil || len(addrs) == 0 { return err } // for DNS round robin n := Rand.Intn(len(addrs)) addr := addrs[n] var format string if strings.Contains(addr, ":") { // v6 format = "[%s]:%s" } else { // v4 format = "%s:%s" } resolved := fmt.Sprintf(format, addr, port) log.Printf("[info] Connect to %s (%s)", f.Server, resolved) f.conn, err = net.DialTimeout("tcp", resolved, f.Config.Timeout) f.recordError(err) return }
[ "func", "(", "f", "*", "Fluent", ")", "connect", "(", ")", "(", "err", "error", ")", "{", "host", ",", "port", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "f", ".", "Server", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "addrs", ",", "err", ":=", "net", ".", "LookupHost", "(", "host", ")", "\n", "if", "err", "!=", "nil", "||", "len", "(", "addrs", ")", "==", "0", "{", "return", "err", "\n", "}", "\n", "n", ":=", "Rand", ".", "Intn", "(", "len", "(", "addrs", ")", ")", "\n", "addr", ":=", "addrs", "[", "n", "]", "\n", "var", "format", "string", "\n", "if", "strings", ".", "Contains", "(", "addr", ",", "\":\"", ")", "{", "format", "=", "\"[%s]:%s\"", "\n", "}", "else", "{", "format", "=", "\"%s:%s\"", "\n", "}", "\n", "resolved", ":=", "fmt", ".", "Sprintf", "(", "format", ",", "addr", ",", "port", ")", "\n", "log", ".", "Printf", "(", "\"[info] Connect to %s (%s)\"", ",", "f", ".", "Server", ",", "resolved", ")", "\n", "f", ".", "conn", ",", "err", "=", "net", ".", "DialTimeout", "(", "\"tcp\"", ",", "resolved", ",", "f", ".", "Config", ".", "Timeout", ")", "\n", "f", ".", "recordError", "(", "err", ")", "\n", "return", "\n", "}" ]
// connect establishes a new connection using the specified transport.
[ "connect", "establishes", "a", "new", "connection", "using", "the", "specified", "transport", "." ]
f5c1c02a0b892cf5c08918ec2ff7bbca71cc7e4f
https://github.com/fujiwara/fluent-agent-hydra/blob/f5c1c02a0b892cf5c08918ec2ff7bbca71cc7e4f/fluent/fluent.go#L132-L157
test
haklop/gnotifier
gnotifier.go
Notification
func Notification(title, message string) GNotifier { config := &Config{title, message, 5000, ""} n := &notifier{Config: config} return n }
go
func Notification(title, message string) GNotifier { config := &Config{title, message, 5000, ""} n := &notifier{Config: config} return n }
[ "func", "Notification", "(", "title", ",", "message", "string", ")", "GNotifier", "{", "config", ":=", "&", "Config", "{", "title", ",", "message", ",", "5000", ",", "\"\"", "}", "\n", "n", ":=", "&", "notifier", "{", "Config", ":", "config", "}", "\n", "return", "n", "\n", "}" ]
// Notification is the builder
[ "Notification", "is", "the", "builder" ]
0de36badf60155d5953373ed432982b20c62fb91
https://github.com/haklop/gnotifier/blob/0de36badf60155d5953373ed432982b20c62fb91/gnotifier.go#L48-L52
test
haklop/gnotifier
gnotifier.go
NullNotification
func NullNotification(title, message string) GNotifier { config := &Config{title, message, 5000, ""} n := &nullNotifier{Config: config} return n }
go
func NullNotification(title, message string) GNotifier { config := &Config{title, message, 5000, ""} n := &nullNotifier{Config: config} return n }
[ "func", "NullNotification", "(", "title", ",", "message", "string", ")", "GNotifier", "{", "config", ":=", "&", "Config", "{", "title", ",", "message", ",", "5000", ",", "\"\"", "}", "\n", "n", ":=", "&", "nullNotifier", "{", "Config", ":", "config", "}", "\n", "return", "n", "\n", "}" ]
// NullNotification is the builder for tests where no side effects are desired
[ "NullNotification", "is", "the", "builder", "for", "tests", "where", "no", "side", "effects", "are", "desired" ]
0de36badf60155d5953373ed432982b20c62fb91
https://github.com/haklop/gnotifier/blob/0de36badf60155d5953373ed432982b20c62fb91/gnotifier.go#L71-L75
test
mastahyeti/fakeca
identity.go
New
func New(opts ...Option) *Identity { c := &configuration{} for _, opt := range opts { option(opt)(c) } return c.generate() }
go
func New(opts ...Option) *Identity { c := &configuration{} for _, opt := range opts { option(opt)(c) } return c.generate() }
[ "func", "New", "(", "opts", "...", "Option", ")", "*", "Identity", "{", "c", ":=", "&", "configuration", "{", "}", "\n", "for", "_", ",", "opt", ":=", "range", "opts", "{", "option", "(", "opt", ")", "(", "c", ")", "\n", "}", "\n", "return", "c", ".", "generate", "(", ")", "\n", "}" ]
// New creates a new CA.
[ "New", "creates", "a", "new", "CA", "." ]
c1d84b1b473e99212130da7b311dd0605de5ed0a
https://github.com/mastahyeti/fakeca/blob/c1d84b1b473e99212130da7b311dd0605de5ed0a/identity.go#L24-L32
test
mastahyeti/fakeca
identity.go
Issue
func (id *Identity) Issue(opts ...Option) *Identity { opts = append(opts, Issuer(id)) return New(opts...) }
go
func (id *Identity) Issue(opts ...Option) *Identity { opts = append(opts, Issuer(id)) return New(opts...) }
[ "func", "(", "id", "*", "Identity", ")", "Issue", "(", "opts", "...", "Option", ")", "*", "Identity", "{", "opts", "=", "append", "(", "opts", ",", "Issuer", "(", "id", ")", ")", "\n", "return", "New", "(", "opts", "...", ")", "\n", "}" ]
// Issue issues a new Identity with this one as its parent.
[ "Issue", "issues", "a", "new", "Identity", "with", "this", "one", "as", "its", "parent", "." ]
c1d84b1b473e99212130da7b311dd0605de5ed0a
https://github.com/mastahyeti/fakeca/blob/c1d84b1b473e99212130da7b311dd0605de5ed0a/identity.go#L35-L38
test
mastahyeti/fakeca
configuration.go
Subject
func Subject(value pkix.Name) Option { return func(c *configuration) { c.subject = &value } }
go
func Subject(value pkix.Name) Option { return func(c *configuration) { c.subject = &value } }
[ "func", "Subject", "(", "value", "pkix", ".", "Name", ")", "Option", "{", "return", "func", "(", "c", "*", "configuration", ")", "{", "c", ".", "subject", "=", "&", "value", "\n", "}", "\n", "}" ]
// Subject is an Option that sets a identity's subject field.
[ "Subject", "is", "an", "Option", "that", "sets", "a", "identity", "s", "subject", "field", "." ]
c1d84b1b473e99212130da7b311dd0605de5ed0a
https://github.com/mastahyeti/fakeca/blob/c1d84b1b473e99212130da7b311dd0605de5ed0a/configuration.go#L171-L175
test
mastahyeti/fakeca
configuration.go
PrivateKey
func PrivateKey(value crypto.Signer) Option { return func(c *configuration) { c.priv = &value } }
go
func PrivateKey(value crypto.Signer) Option { return func(c *configuration) { c.priv = &value } }
[ "func", "PrivateKey", "(", "value", "crypto", ".", "Signer", ")", "Option", "{", "return", "func", "(", "c", "*", "configuration", ")", "{", "c", ".", "priv", "=", "&", "value", "\n", "}", "\n", "}" ]
// PrivateKey is an Option for setting the identity's private key.
[ "PrivateKey", "is", "an", "Option", "for", "setting", "the", "identity", "s", "private", "key", "." ]
c1d84b1b473e99212130da7b311dd0605de5ed0a
https://github.com/mastahyeti/fakeca/blob/c1d84b1b473e99212130da7b311dd0605de5ed0a/configuration.go#L186-L190
test
mastahyeti/fakeca
configuration.go
NotBefore
func NotBefore(value time.Time) Option { return func(c *configuration) { c.notBefore = &value } }
go
func NotBefore(value time.Time) Option { return func(c *configuration) { c.notBefore = &value } }
[ "func", "NotBefore", "(", "value", "time", ".", "Time", ")", "Option", "{", "return", "func", "(", "c", "*", "configuration", ")", "{", "c", ".", "notBefore", "=", "&", "value", "\n", "}", "\n", "}" ]
// NotBefore is an Option for setting the identity's certificate's NotBefore.
[ "NotBefore", "is", "an", "Option", "for", "setting", "the", "identity", "s", "certificate", "s", "NotBefore", "." ]
c1d84b1b473e99212130da7b311dd0605de5ed0a
https://github.com/mastahyeti/fakeca/blob/c1d84b1b473e99212130da7b311dd0605de5ed0a/configuration.go#L200-L204
test
mastahyeti/fakeca
configuration.go
NotAfter
func NotAfter(value time.Time) Option { return func(c *configuration) { c.notAfter = &value } }
go
func NotAfter(value time.Time) Option { return func(c *configuration) { c.notAfter = &value } }
[ "func", "NotAfter", "(", "value", "time", ".", "Time", ")", "Option", "{", "return", "func", "(", "c", "*", "configuration", ")", "{", "c", ".", "notAfter", "=", "&", "value", "\n", "}", "\n", "}" ]
// NotAfter is an Option for setting the identity's certificate's NotAfter.
[ "NotAfter", "is", "an", "Option", "for", "setting", "the", "identity", "s", "certificate", "s", "NotAfter", "." ]
c1d84b1b473e99212130da7b311dd0605de5ed0a
https://github.com/mastahyeti/fakeca/blob/c1d84b1b473e99212130da7b311dd0605de5ed0a/configuration.go#L207-L211
test
mastahyeti/fakeca
configuration.go
IssuingCertificateURL
func IssuingCertificateURL(value ...string) Option { return func(c *configuration) { c.issuingCertificateURL = append(c.issuingCertificateURL, value...) } }
go
func IssuingCertificateURL(value ...string) Option { return func(c *configuration) { c.issuingCertificateURL = append(c.issuingCertificateURL, value...) } }
[ "func", "IssuingCertificateURL", "(", "value", "...", "string", ")", "Option", "{", "return", "func", "(", "c", "*", "configuration", ")", "{", "c", ".", "issuingCertificateURL", "=", "append", "(", "c", ".", "issuingCertificateURL", ",", "value", "...", ")", "\n", "}", "\n", "}" ]
// IssuingCertificateURL is an Option for setting the identity's certificate's // IssuingCertificateURL.
[ "IssuingCertificateURL", "is", "an", "Option", "for", "setting", "the", "identity", "s", "certificate", "s", "IssuingCertificateURL", "." ]
c1d84b1b473e99212130da7b311dd0605de5ed0a
https://github.com/mastahyeti/fakeca/blob/c1d84b1b473e99212130da7b311dd0605de5ed0a/configuration.go#L215-L219
test
mastahyeti/fakeca
configuration.go
OCSPServer
func OCSPServer(value ...string) Option { return func(c *configuration) { c.ocspServer = append(c.ocspServer, value...) } }
go
func OCSPServer(value ...string) Option { return func(c *configuration) { c.ocspServer = append(c.ocspServer, value...) } }
[ "func", "OCSPServer", "(", "value", "...", "string", ")", "Option", "{", "return", "func", "(", "c", "*", "configuration", ")", "{", "c", ".", "ocspServer", "=", "append", "(", "c", ".", "ocspServer", ",", "value", "...", ")", "\n", "}", "\n", "}" ]
// OCSPServer is an Option for setting the identity's certificate's OCSPServer.
[ "OCSPServer", "is", "an", "Option", "for", "setting", "the", "identity", "s", "certificate", "s", "OCSPServer", "." ]
c1d84b1b473e99212130da7b311dd0605de5ed0a
https://github.com/mastahyeti/fakeca/blob/c1d84b1b473e99212130da7b311dd0605de5ed0a/configuration.go#L222-L226
test
mrd0ll4r/tbotapi
api.go
New
func New(apiKey string) (*TelegramBotAPI, error) { toReturn := TelegramBotAPI{ Updates: make(chan BotUpdate), baseURIs: createEndpoints(fmt.Sprintf(apiBaseURI, apiKey)), closed: make(chan struct{}), c: newClient(fmt.Sprintf(apiBaseURI, apiKey)), updateC: newClient(fmt.Sprintf(apiBaseURI, apiKey)), } user, err := toReturn.GetMe() if err != nil { return nil, err } toReturn.ID = user.User.ID toReturn.Name = user.User.FirstName toReturn.Username = *user.User.Username err = toReturn.removeWebhook() if err != nil { return nil, err } toReturn.wg.Add(1) go toReturn.updateLoop() return &toReturn, nil }
go
func New(apiKey string) (*TelegramBotAPI, error) { toReturn := TelegramBotAPI{ Updates: make(chan BotUpdate), baseURIs: createEndpoints(fmt.Sprintf(apiBaseURI, apiKey)), closed: make(chan struct{}), c: newClient(fmt.Sprintf(apiBaseURI, apiKey)), updateC: newClient(fmt.Sprintf(apiBaseURI, apiKey)), } user, err := toReturn.GetMe() if err != nil { return nil, err } toReturn.ID = user.User.ID toReturn.Name = user.User.FirstName toReturn.Username = *user.User.Username err = toReturn.removeWebhook() if err != nil { return nil, err } toReturn.wg.Add(1) go toReturn.updateLoop() return &toReturn, nil }
[ "func", "New", "(", "apiKey", "string", ")", "(", "*", "TelegramBotAPI", ",", "error", ")", "{", "toReturn", ":=", "TelegramBotAPI", "{", "Updates", ":", "make", "(", "chan", "BotUpdate", ")", ",", "baseURIs", ":", "createEndpoints", "(", "fmt", ".", "Sprintf", "(", "apiBaseURI", ",", "apiKey", ")", ")", ",", "closed", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "c", ":", "newClient", "(", "fmt", ".", "Sprintf", "(", "apiBaseURI", ",", "apiKey", ")", ")", ",", "updateC", ":", "newClient", "(", "fmt", ".", "Sprintf", "(", "apiBaseURI", ",", "apiKey", ")", ")", ",", "}", "\n", "user", ",", "err", ":=", "toReturn", ".", "GetMe", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "toReturn", ".", "ID", "=", "user", ".", "User", ".", "ID", "\n", "toReturn", ".", "Name", "=", "user", ".", "User", ".", "FirstName", "\n", "toReturn", ".", "Username", "=", "*", "user", ".", "User", ".", "Username", "\n", "err", "=", "toReturn", ".", "removeWebhook", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "toReturn", ".", "wg", ".", "Add", "(", "1", ")", "\n", "go", "toReturn", ".", "updateLoop", "(", ")", "\n", "return", "&", "toReturn", ",", "nil", "\n", "}" ]
// New creates a new API Client for a Telegram bot using the apiKey // provided. // It will call the GetMe method to retrieve the bots id, name and // username. // // This bot uses long polling to retrieve its updates. If a webhook was set // for the given apiKey, this will remove it.
[ "New", "creates", "a", "new", "API", "Client", "for", "a", "Telegram", "bot", "using", "the", "apiKey", "provided", ".", "It", "will", "call", "the", "GetMe", "method", "to", "retrieve", "the", "bots", "id", "name", "and", "username", ".", "This", "bot", "uses", "long", "polling", "to", "retrieve", "its", "updates", ".", "If", "a", "webhook", "was", "set", "for", "the", "given", "apiKey", "this", "will", "remove", "it", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/api.go#L60-L85
test
mrd0ll4r/tbotapi
api.go
NewWithWebhook
func NewWithWebhook(apiKey, webhookURL, certificate string) (*TelegramBotAPI, http.HandlerFunc, error) { toReturn := TelegramBotAPI{ Updates: make(chan BotUpdate), baseURIs: createEndpoints(fmt.Sprintf(apiBaseURI, apiKey)), closed: make(chan struct{}), c: newClient(fmt.Sprintf(apiBaseURI, apiKey)), updateC: newClient(fmt.Sprintf(apiBaseURI, apiKey)), } user, err := toReturn.GetMe() if err != nil { return nil, nil, err } toReturn.ID = user.User.ID toReturn.Name = user.User.FirstName toReturn.Username = *user.User.Username file, err := os.Open(certificate) if err != nil { return nil, nil, err } err = toReturn.setWebhook(webhookURL, certificate, file) if err != nil { return nil, nil, err } updateFunc := func(w http.ResponseWriter, r *http.Request) { bytes, err := ioutil.ReadAll(r.Body) if err != nil { toReturn.Updates <- BotUpdate{err: err} return } update := &Update{} err = json.Unmarshal(bytes, update) if err != nil { toReturn.Updates <- BotUpdate{err: err} return } toReturn.Updates <- BotUpdate{update: *update} } return &toReturn, updateFunc, nil }
go
func NewWithWebhook(apiKey, webhookURL, certificate string) (*TelegramBotAPI, http.HandlerFunc, error) { toReturn := TelegramBotAPI{ Updates: make(chan BotUpdate), baseURIs: createEndpoints(fmt.Sprintf(apiBaseURI, apiKey)), closed: make(chan struct{}), c: newClient(fmt.Sprintf(apiBaseURI, apiKey)), updateC: newClient(fmt.Sprintf(apiBaseURI, apiKey)), } user, err := toReturn.GetMe() if err != nil { return nil, nil, err } toReturn.ID = user.User.ID toReturn.Name = user.User.FirstName toReturn.Username = *user.User.Username file, err := os.Open(certificate) if err != nil { return nil, nil, err } err = toReturn.setWebhook(webhookURL, certificate, file) if err != nil { return nil, nil, err } updateFunc := func(w http.ResponseWriter, r *http.Request) { bytes, err := ioutil.ReadAll(r.Body) if err != nil { toReturn.Updates <- BotUpdate{err: err} return } update := &Update{} err = json.Unmarshal(bytes, update) if err != nil { toReturn.Updates <- BotUpdate{err: err} return } toReturn.Updates <- BotUpdate{update: *update} } return &toReturn, updateFunc, nil }
[ "func", "NewWithWebhook", "(", "apiKey", ",", "webhookURL", ",", "certificate", "string", ")", "(", "*", "TelegramBotAPI", ",", "http", ".", "HandlerFunc", ",", "error", ")", "{", "toReturn", ":=", "TelegramBotAPI", "{", "Updates", ":", "make", "(", "chan", "BotUpdate", ")", ",", "baseURIs", ":", "createEndpoints", "(", "fmt", ".", "Sprintf", "(", "apiBaseURI", ",", "apiKey", ")", ")", ",", "closed", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "c", ":", "newClient", "(", "fmt", ".", "Sprintf", "(", "apiBaseURI", ",", "apiKey", ")", ")", ",", "updateC", ":", "newClient", "(", "fmt", ".", "Sprintf", "(", "apiBaseURI", ",", "apiKey", ")", ")", ",", "}", "\n", "user", ",", "err", ":=", "toReturn", ".", "GetMe", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "toReturn", ".", "ID", "=", "user", ".", "User", ".", "ID", "\n", "toReturn", ".", "Name", "=", "user", ".", "User", ".", "FirstName", "\n", "toReturn", ".", "Username", "=", "*", "user", ".", "User", ".", "Username", "\n", "file", ",", "err", ":=", "os", ".", "Open", "(", "certificate", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "err", "=", "toReturn", ".", "setWebhook", "(", "webhookURL", ",", "certificate", ",", "file", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "updateFunc", ":=", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "bytes", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ".", "Body", ")", "\n", "if", "err", "!=", "nil", "{", "toReturn", ".", "Updates", "<-", "BotUpdate", "{", "err", ":", "err", "}", "\n", "return", "\n", "}", "\n", "update", ":=", "&", "Update", "{", "}", "\n", "err", "=", "json", ".", "Unmarshal", "(", "bytes", ",", "update", ")", "\n", "if", "err", "!=", "nil", "{", "toReturn", ".", "Updates", "<-", "BotUpdate", "{", "err", ":", "err", "}", "\n", "return", "\n", "}", "\n", "toReturn", ".", "Updates", "<-", "BotUpdate", "{", "update", ":", "*", "update", "}", "\n", "}", "\n", "return", "&", "toReturn", ",", "updateFunc", ",", "nil", "\n", "}" ]
// NewWithWebhook creates a new API client for a Telegram bot using the apiKey // provided. It will call the GetMe method to retrieve the bots id, name and // username. // In addition to the API client, a http.HandlerFunc will be returned. This // handler func reacts to webhook requests and will put updates into the // Updates channel.
[ "NewWithWebhook", "creates", "a", "new", "API", "client", "for", "a", "Telegram", "bot", "using", "the", "apiKey", "provided", ".", "It", "will", "call", "the", "GetMe", "method", "to", "retrieve", "the", "bots", "id", "name", "and", "username", ".", "In", "addition", "to", "the", "API", "client", "a", "http", ".", "HandlerFunc", "will", "be", "returned", ".", "This", "handler", "func", "reacts", "to", "webhook", "requests", "and", "will", "put", "updates", "into", "the", "Updates", "channel", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/api.go#L93-L137
test
mrd0ll4r/tbotapi
api.go
Close
func (api *TelegramBotAPI) Close() { select { case <-api.closed: return default: } close(api.closed) api.wg.Wait() }
go
func (api *TelegramBotAPI) Close() { select { case <-api.closed: return default: } close(api.closed) api.wg.Wait() }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "Close", "(", ")", "{", "select", "{", "case", "<-", "api", ".", "closed", ":", "return", "\n", "default", ":", "}", "\n", "close", "(", "api", ".", "closed", ")", "\n", "api", ".", "wg", ".", "Wait", "(", ")", "\n", "}" ]
// Close shuts down this client. // Until Close returns, new updates and errors will be put into the // respective channels. // Note that, if no updates are received, this function may block for up to // one minute, which is the time interval // for long polling.
[ "Close", "shuts", "down", "this", "client", ".", "Until", "Close", "returns", "new", "updates", "and", "errors", "will", "be", "put", "into", "the", "respective", "channels", ".", "Note", "that", "if", "no", "updates", "are", "received", "this", "function", "may", "block", "for", "up", "to", "one", "minute", "which", "is", "the", "time", "interval", "for", "long", "polling", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/api.go#L145-L153
test
mrd0ll4r/tbotapi
api.go
GetMe
func (api *TelegramBotAPI) GetMe() (*UserResponse, error) { resp := &UserResponse{} _, err := api.c.get(getMe, resp) if err != nil { return nil, err } err = check(&resp.baseResponse) if err != nil { return nil, err } return resp, nil }
go
func (api *TelegramBotAPI) GetMe() (*UserResponse, error) { resp := &UserResponse{} _, err := api.c.get(getMe, resp) if err != nil { return nil, err } err = check(&resp.baseResponse) if err != nil { return nil, err } return resp, nil }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "GetMe", "(", ")", "(", "*", "UserResponse", ",", "error", ")", "{", "resp", ":=", "&", "UserResponse", "{", "}", "\n", "_", ",", "err", ":=", "api", ".", "c", ".", "get", "(", "getMe", ",", "resp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "err", "=", "check", "(", "&", "resp", ".", "baseResponse", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "resp", ",", "nil", "\n", "}" ]
// GetMe returns basic information about the bot in form of a UserResponse.
[ "GetMe", "returns", "basic", "information", "about", "the", "bot", "in", "form", "of", "a", "UserResponse", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/api.go#L265-L277
test
mrd0ll4r/tbotapi
examples/boilerplate/boilerplate.go
RunBot
func RunBot(apiKey string, bot BotFunc, name, description string) { closing := make(chan struct{}) fmt.Printf("%s: %s\n", name, description) fmt.Println("Starting...") api, err := tbotapi.New(apiKey) if err != nil { log.Fatal(err) } // Just to show its working. fmt.Printf("User ID: %d\n", api.ID) fmt.Printf("Bot Name: %s\n", api.Name) fmt.Printf("Bot Username: %s\n", api.Username) closed := make(chan struct{}) wg := &sync.WaitGroup{} wg.Add(1) go func() { defer wg.Done() for { select { case <-closed: return case update := <-api.Updates: if update.Error() != nil { // TODO handle this properly fmt.Printf("Update error: %s\n", update.Error()) continue } bot(update.Update(), api) } } }() // Ensure a clean shutdown. shutdown := make(chan os.Signal) signal.Notify(shutdown, syscall.SIGINT, syscall.SIGTERM) go func() { <-shutdown close(closing) }() fmt.Println("Bot started. Press CTRL-C to close...") // Wait for the signal. <-closing fmt.Println("Closing...") // Always close the API first, let it clean up the update loop. // This might take a while. api.Close() close(closed) wg.Wait() }
go
func RunBot(apiKey string, bot BotFunc, name, description string) { closing := make(chan struct{}) fmt.Printf("%s: %s\n", name, description) fmt.Println("Starting...") api, err := tbotapi.New(apiKey) if err != nil { log.Fatal(err) } // Just to show its working. fmt.Printf("User ID: %d\n", api.ID) fmt.Printf("Bot Name: %s\n", api.Name) fmt.Printf("Bot Username: %s\n", api.Username) closed := make(chan struct{}) wg := &sync.WaitGroup{} wg.Add(1) go func() { defer wg.Done() for { select { case <-closed: return case update := <-api.Updates: if update.Error() != nil { // TODO handle this properly fmt.Printf("Update error: %s\n", update.Error()) continue } bot(update.Update(), api) } } }() // Ensure a clean shutdown. shutdown := make(chan os.Signal) signal.Notify(shutdown, syscall.SIGINT, syscall.SIGTERM) go func() { <-shutdown close(closing) }() fmt.Println("Bot started. Press CTRL-C to close...") // Wait for the signal. <-closing fmt.Println("Closing...") // Always close the API first, let it clean up the update loop. // This might take a while. api.Close() close(closed) wg.Wait() }
[ "func", "RunBot", "(", "apiKey", "string", ",", "bot", "BotFunc", ",", "name", ",", "description", "string", ")", "{", "closing", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "fmt", ".", "Printf", "(", "\"%s: %s\\n\"", ",", "\\n", ",", "name", ")", "\n", "description", "\n", "fmt", ".", "Println", "(", "\"Starting...\"", ")", "\n", "api", ",", "err", ":=", "tbotapi", ".", "New", "(", "apiKey", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fatal", "(", "err", ")", "\n", "}", "\n", "fmt", ".", "Printf", "(", "\"User ID: %d\\n\"", ",", "\\n", ")", "\n", "api", ".", "ID", "\n", "fmt", ".", "Printf", "(", "\"Bot Name: %s\\n\"", ",", "\\n", ")", "\n", "api", ".", "Name", "\n", "fmt", ".", "Printf", "(", "\"Bot Username: %s\\n\"", ",", "\\n", ")", "\n", "api", ".", "Username", "\n", "closed", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "wg", ":=", "&", "sync", ".", "WaitGroup", "{", "}", "\n", "wg", ".", "Add", "(", "1", ")", "\n", "go", "func", "(", ")", "{", "defer", "wg", ".", "Done", "(", ")", "\n", "for", "{", "select", "{", "case", "<-", "closed", ":", "return", "\n", "case", "update", ":=", "<-", "api", ".", "Updates", ":", "if", "update", ".", "Error", "(", ")", "!=", "nil", "{", "fmt", ".", "Printf", "(", "\"Update error: %s\\n\"", ",", "\\n", ")", "\n", "update", ".", "Error", "(", ")", "\n", "}", "\n", "continue", "\n", "}", "\n", "}", "\n", "}", "bot", "(", "update", ".", "Update", "(", ")", ",", "api", ")", "\n", "(", ")", "\n", "shutdown", ":=", "make", "(", "chan", "os", ".", "Signal", ")", "\n", "signal", ".", "Notify", "(", "shutdown", ",", "syscall", ".", "SIGINT", ",", "syscall", ".", "SIGTERM", ")", "\n", "go", "func", "(", ")", "{", "<-", "shutdown", "\n", "close", "(", "closing", ")", "\n", "}", "(", ")", "\n", "fmt", ".", "Println", "(", "\"Bot started. Press CTRL-C to close...\"", ")", "\n", "}" ]
// RunBot runs a bot. // It will block until either something very bad happens or closing is closed.
[ "RunBot", "runs", "a", "bot", ".", "It", "will", "block", "until", "either", "something", "very", "bad", "happens", "or", "closing", "is", "closed", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/examples/boilerplate/boilerplate.go#L25-L83
test
mrd0ll4r/tbotapi
examples/boilerplate/boilerplate.go
RunBotOnWebhook
func RunBotOnWebhook(apiKey string, bot BotFunc, name, description, webhookHost string, webhookPort uint16, pubkey, privkey string) { closing := make(chan struct{}) fmt.Printf("%s: %s\n", name, description) fmt.Println("Starting...") u := url.URL{ Host: webhookHost + ":" + fmt.Sprint(webhookPort), Scheme: "https", Path: apiKey, } api, handler, err := tbotapi.NewWithWebhook(apiKey, u.String(), pubkey) if err != nil { log.Fatal(err) } // Just to show its working. fmt.Printf("User ID: %d\n", api.ID) fmt.Printf("Bot Name: %s\n", api.Name) fmt.Printf("Bot Username: %s\n", api.Username) closed := make(chan struct{}) wg := &sync.WaitGroup{} wg.Add(1) go func() { defer wg.Done() for { select { case <-closed: return case update := <-api.Updates: if update.Error() != nil { // TODO handle this properly fmt.Printf("Update error: %s\n", update.Error()) continue } bot(update.Update(), api) } } }() http.HandleFunc("/"+apiKey, handler) fmt.Println("Starting webhook...") go func() { log.Fatal(http.ListenAndServeTLS("0.0.0.0:"+fmt.Sprint(webhookPort), pubkey, privkey, nil)) }() // Ensure a clean shutdown. shutdown := make(chan os.Signal) signal.Notify(shutdown, syscall.SIGINT, syscall.SIGTERM) go func() { <-shutdown close(closing) }() fmt.Println("Bot started. Press CTRL-C to close...") // Wait for the signal. <-closing fmt.Println("Closing...") // Always close the API first. api.Close() close(closed) wg.Wait() }
go
func RunBotOnWebhook(apiKey string, bot BotFunc, name, description, webhookHost string, webhookPort uint16, pubkey, privkey string) { closing := make(chan struct{}) fmt.Printf("%s: %s\n", name, description) fmt.Println("Starting...") u := url.URL{ Host: webhookHost + ":" + fmt.Sprint(webhookPort), Scheme: "https", Path: apiKey, } api, handler, err := tbotapi.NewWithWebhook(apiKey, u.String(), pubkey) if err != nil { log.Fatal(err) } // Just to show its working. fmt.Printf("User ID: %d\n", api.ID) fmt.Printf("Bot Name: %s\n", api.Name) fmt.Printf("Bot Username: %s\n", api.Username) closed := make(chan struct{}) wg := &sync.WaitGroup{} wg.Add(1) go func() { defer wg.Done() for { select { case <-closed: return case update := <-api.Updates: if update.Error() != nil { // TODO handle this properly fmt.Printf("Update error: %s\n", update.Error()) continue } bot(update.Update(), api) } } }() http.HandleFunc("/"+apiKey, handler) fmt.Println("Starting webhook...") go func() { log.Fatal(http.ListenAndServeTLS("0.0.0.0:"+fmt.Sprint(webhookPort), pubkey, privkey, nil)) }() // Ensure a clean shutdown. shutdown := make(chan os.Signal) signal.Notify(shutdown, syscall.SIGINT, syscall.SIGTERM) go func() { <-shutdown close(closing) }() fmt.Println("Bot started. Press CTRL-C to close...") // Wait for the signal. <-closing fmt.Println("Closing...") // Always close the API first. api.Close() close(closed) wg.Wait() }
[ "func", "RunBotOnWebhook", "(", "apiKey", "string", ",", "bot", "BotFunc", ",", "name", ",", "description", ",", "webhookHost", "string", ",", "webhookPort", "uint16", ",", "pubkey", ",", "privkey", "string", ")", "{", "closing", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "fmt", ".", "Printf", "(", "\"%s: %s\\n\"", ",", "\\n", ",", "name", ")", "\n", "description", "\n", "fmt", ".", "Println", "(", "\"Starting...\"", ")", "\n", "u", ":=", "url", ".", "URL", "{", "Host", ":", "webhookHost", "+", "\":\"", "+", "fmt", ".", "Sprint", "(", "webhookPort", ")", ",", "Scheme", ":", "\"https\"", ",", "Path", ":", "apiKey", ",", "}", "\n", "api", ",", "handler", ",", "err", ":=", "tbotapi", ".", "NewWithWebhook", "(", "apiKey", ",", "u", ".", "String", "(", ")", ",", "pubkey", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fatal", "(", "err", ")", "\n", "}", "\n", "fmt", ".", "Printf", "(", "\"User ID: %d\\n\"", ",", "\\n", ")", "\n", "api", ".", "ID", "\n", "fmt", ".", "Printf", "(", "\"Bot Name: %s\\n\"", ",", "\\n", ")", "\n", "api", ".", "Name", "\n", "fmt", ".", "Printf", "(", "\"Bot Username: %s\\n\"", ",", "\\n", ")", "\n", "api", ".", "Username", "\n", "closed", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "wg", ":=", "&", "sync", ".", "WaitGroup", "{", "}", "\n", "wg", ".", "Add", "(", "1", ")", "\n", "go", "func", "(", ")", "{", "defer", "wg", ".", "Done", "(", ")", "\n", "for", "{", "select", "{", "case", "<-", "closed", ":", "return", "\n", "case", "update", ":=", "<-", "api", ".", "Updates", ":", "if", "update", ".", "Error", "(", ")", "!=", "nil", "{", "fmt", ".", "Printf", "(", "\"Update error: %s\\n\"", ",", "\\n", ")", "\n", "update", ".", "Error", "(", ")", "\n", "}", "\n", "continue", "\n", "}", "\n", "}", "\n", "}", "bot", "(", "update", ".", "Update", "(", ")", ",", "api", ")", "\n", "(", ")", "\n", "http", ".", "HandleFunc", "(", "\"/\"", "+", "apiKey", ",", "handler", ")", "\n", "fmt", ".", "Println", "(", "\"Starting webhook...\"", ")", "\n", "go", "func", "(", ")", "{", "log", ".", "Fatal", "(", "http", ".", "ListenAndServeTLS", "(", "\"0.0.0.0:\"", "+", "fmt", ".", "Sprint", "(", "webhookPort", ")", ",", "pubkey", ",", "privkey", ",", "nil", ")", ")", "\n", "}", "(", ")", "\n", "shutdown", ":=", "make", "(", "chan", "os", ".", "Signal", ")", "\n", "signal", ".", "Notify", "(", "shutdown", ",", "syscall", ".", "SIGINT", ",", "syscall", ".", "SIGTERM", ")", "\n", "go", "func", "(", ")", "{", "<-", "shutdown", "\n", "close", "(", "closing", ")", "\n", "}", "(", ")", "\n", "fmt", ".", "Println", "(", "\"Bot started. Press CTRL-C to close...\"", ")", "\n", "}" ]
// RunBotOnWebhook runs the given BotFunc with a webhook.
[ "RunBotOnWebhook", "runs", "the", "given", "BotFunc", "with", "a", "webhook", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/examples/boilerplate/boilerplate.go#L86-L155
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingMessage
func (api *TelegramBotAPI) NewOutgoingMessage(recipient Recipient, text string) *OutgoingMessage { return &OutgoingMessage{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, Text: text, ParseMode: ModeDefault, } }
go
func (api *TelegramBotAPI) NewOutgoingMessage(recipient Recipient, text string) *OutgoingMessage { return &OutgoingMessage{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, Text: text, ParseMode: ModeDefault, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingMessage", "(", "recipient", "Recipient", ",", "text", "string", ")", "*", "OutgoingMessage", "{", "return", "&", "OutgoingMessage", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "Text", ":", "text", ",", "ParseMode", ":", "ModeDefault", ",", "}", "\n", "}" ]
// NewOutgoingMessage creates a new outgoing message.
[ "NewOutgoingMessage", "creates", "a", "new", "outgoing", "message", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L10-L21
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingLocation
func (api *TelegramBotAPI) NewOutgoingLocation(recipient Recipient, latitude, longitude float32) *OutgoingLocation { return &OutgoingLocation{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, Latitude: latitude, Longitude: longitude, } }
go
func (api *TelegramBotAPI) NewOutgoingLocation(recipient Recipient, latitude, longitude float32) *OutgoingLocation { return &OutgoingLocation{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, Latitude: latitude, Longitude: longitude, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingLocation", "(", "recipient", "Recipient", ",", "latitude", ",", "longitude", "float32", ")", "*", "OutgoingLocation", "{", "return", "&", "OutgoingLocation", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "Latitude", ":", "latitude", ",", "Longitude", ":", "longitude", ",", "}", "\n", "}" ]
// NewOutgoingLocation creates a new outgoing location.
[ "NewOutgoingLocation", "creates", "a", "new", "outgoing", "location", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L24-L35
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingVenue
func (api *TelegramBotAPI) NewOutgoingVenue(recipient Recipient, latitude, longitude float32, title, address string) *OutgoingVenue { return &OutgoingVenue{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, Latitude: latitude, Longitude: longitude, Title: title, Address: address, } }
go
func (api *TelegramBotAPI) NewOutgoingVenue(recipient Recipient, latitude, longitude float32, title, address string) *OutgoingVenue { return &OutgoingVenue{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, Latitude: latitude, Longitude: longitude, Title: title, Address: address, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingVenue", "(", "recipient", "Recipient", ",", "latitude", ",", "longitude", "float32", ",", "title", ",", "address", "string", ")", "*", "OutgoingVenue", "{", "return", "&", "OutgoingVenue", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "Latitude", ":", "latitude", ",", "Longitude", ":", "longitude", ",", "Title", ":", "title", ",", "Address", ":", "address", ",", "}", "\n", "}" ]
// NewOutgoingVenue creates a new outgoing location.
[ "NewOutgoingVenue", "creates", "a", "new", "outgoing", "location", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L38-L51
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingVideo
func (api *TelegramBotAPI) NewOutgoingVideo(recipient Recipient, fileName string, reader io.Reader) *OutgoingVideo { return &OutgoingVideo{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileName: fileName, r: reader, }, } }
go
func (api *TelegramBotAPI) NewOutgoingVideo(recipient Recipient, fileName string, reader io.Reader) *OutgoingVideo { return &OutgoingVideo{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileName: fileName, r: reader, }, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingVideo", "(", "recipient", "Recipient", ",", "fileName", "string", ",", "reader", "io", ".", "Reader", ")", "*", "OutgoingVideo", "{", "return", "&", "OutgoingVideo", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "outgoingFileBase", ":", "outgoingFileBase", "{", "fileName", ":", "fileName", ",", "r", ":", "reader", ",", "}", ",", "}", "\n", "}" ]
// NewOutgoingVideo creates a new outgoing video file.
[ "NewOutgoingVideo", "creates", "a", "new", "outgoing", "video", "file", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L54-L67
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingVideoResend
func (api *TelegramBotAPI) NewOutgoingVideoResend(recipient Recipient, fileID string) *OutgoingVideo { return &OutgoingVideo{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileID: fileID, }, } }
go
func (api *TelegramBotAPI) NewOutgoingVideoResend(recipient Recipient, fileID string) *OutgoingVideo { return &OutgoingVideo{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileID: fileID, }, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingVideoResend", "(", "recipient", "Recipient", ",", "fileID", "string", ")", "*", "OutgoingVideo", "{", "return", "&", "OutgoingVideo", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "outgoingFileBase", ":", "outgoingFileBase", "{", "fileID", ":", "fileID", ",", "}", ",", "}", "\n", "}" ]
// NewOutgoingVideoResend creates a new outgoing video file for re-sending.
[ "NewOutgoingVideoResend", "creates", "a", "new", "outgoing", "video", "file", "for", "re", "-", "sending", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L70-L82
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingPhoto
func (api *TelegramBotAPI) NewOutgoingPhoto(recipient Recipient, fileName string, reader io.Reader) *OutgoingPhoto { return &OutgoingPhoto{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileName: fileName, r: reader, }, } }
go
func (api *TelegramBotAPI) NewOutgoingPhoto(recipient Recipient, fileName string, reader io.Reader) *OutgoingPhoto { return &OutgoingPhoto{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileName: fileName, r: reader, }, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingPhoto", "(", "recipient", "Recipient", ",", "fileName", "string", ",", "reader", "io", ".", "Reader", ")", "*", "OutgoingPhoto", "{", "return", "&", "OutgoingPhoto", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "outgoingFileBase", ":", "outgoingFileBase", "{", "fileName", ":", "fileName", ",", "r", ":", "reader", ",", "}", ",", "}", "\n", "}" ]
// NewOutgoingPhoto creates a new outgoing photo.
[ "NewOutgoingPhoto", "creates", "a", "new", "outgoing", "photo", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L85-L98
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingPhotoResend
func (api *TelegramBotAPI) NewOutgoingPhotoResend(recipient Recipient, fileID string) *OutgoingPhoto { return &OutgoingPhoto{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileID: fileID, }, } }
go
func (api *TelegramBotAPI) NewOutgoingPhotoResend(recipient Recipient, fileID string) *OutgoingPhoto { return &OutgoingPhoto{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileID: fileID, }, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingPhotoResend", "(", "recipient", "Recipient", ",", "fileID", "string", ")", "*", "OutgoingPhoto", "{", "return", "&", "OutgoingPhoto", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "outgoingFileBase", ":", "outgoingFileBase", "{", "fileID", ":", "fileID", ",", "}", ",", "}", "\n", "}" ]
// NewOutgoingPhotoResend creates a new outgoing photo for re-sending.
[ "NewOutgoingPhotoResend", "creates", "a", "new", "outgoing", "photo", "for", "re", "-", "sending", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L101-L113
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingSticker
func (api *TelegramBotAPI) NewOutgoingSticker(recipient Recipient, fileName string, reader io.Reader) *OutgoingSticker { return &OutgoingSticker{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileName: fileName, r: reader, }, } }
go
func (api *TelegramBotAPI) NewOutgoingSticker(recipient Recipient, fileName string, reader io.Reader) *OutgoingSticker { return &OutgoingSticker{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileName: fileName, r: reader, }, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingSticker", "(", "recipient", "Recipient", ",", "fileName", "string", ",", "reader", "io", ".", "Reader", ")", "*", "OutgoingSticker", "{", "return", "&", "OutgoingSticker", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "outgoingFileBase", ":", "outgoingFileBase", "{", "fileName", ":", "fileName", ",", "r", ":", "reader", ",", "}", ",", "}", "\n", "}" ]
// NewOutgoingSticker creates a new outgoing sticker message.
[ "NewOutgoingSticker", "creates", "a", "new", "outgoing", "sticker", "message", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L116-L129
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingStickerResend
func (api *TelegramBotAPI) NewOutgoingStickerResend(recipient Recipient, fileID string) *OutgoingSticker { return &OutgoingSticker{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileID: fileID, }, } }
go
func (api *TelegramBotAPI) NewOutgoingStickerResend(recipient Recipient, fileID string) *OutgoingSticker { return &OutgoingSticker{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileID: fileID, }, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingStickerResend", "(", "recipient", "Recipient", ",", "fileID", "string", ")", "*", "OutgoingSticker", "{", "return", "&", "OutgoingSticker", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "outgoingFileBase", ":", "outgoingFileBase", "{", "fileID", ":", "fileID", ",", "}", ",", "}", "\n", "}" ]
// NewOutgoingStickerResend creates a new outgoing sticker message for // re-sending.
[ "NewOutgoingStickerResend", "creates", "a", "new", "outgoing", "sticker", "message", "for", "re", "-", "sending", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L133-L145
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingVoice
func (api *TelegramBotAPI) NewOutgoingVoice(recipient Recipient, fileName string, reader io.Reader) *OutgoingVoice { return &OutgoingVoice{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileName: fileName, r: reader, }, } }
go
func (api *TelegramBotAPI) NewOutgoingVoice(recipient Recipient, fileName string, reader io.Reader) *OutgoingVoice { return &OutgoingVoice{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileName: fileName, r: reader, }, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingVoice", "(", "recipient", "Recipient", ",", "fileName", "string", ",", "reader", "io", ".", "Reader", ")", "*", "OutgoingVoice", "{", "return", "&", "OutgoingVoice", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "outgoingFileBase", ":", "outgoingFileBase", "{", "fileName", ":", "fileName", ",", "r", ":", "reader", ",", "}", ",", "}", "\n", "}" ]
// NewOutgoingVoice creates a new outgoing voice note.
[ "NewOutgoingVoice", "creates", "a", "new", "outgoing", "voice", "note", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L148-L161
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingVoiceResend
func (api *TelegramBotAPI) NewOutgoingVoiceResend(recipient Recipient, fileID string) *OutgoingVoice { return &OutgoingVoice{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileID: fileID, }, } }
go
func (api *TelegramBotAPI) NewOutgoingVoiceResend(recipient Recipient, fileID string) *OutgoingVoice { return &OutgoingVoice{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileID: fileID, }, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingVoiceResend", "(", "recipient", "Recipient", ",", "fileID", "string", ")", "*", "OutgoingVoice", "{", "return", "&", "OutgoingVoice", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "outgoingFileBase", ":", "outgoingFileBase", "{", "fileID", ":", "fileID", ",", "}", ",", "}", "\n", "}" ]
// NewOutgoingVoiceResend creates a new outgoing voice note for re-sending.
[ "NewOutgoingVoiceResend", "creates", "a", "new", "outgoing", "voice", "note", "for", "re", "-", "sending", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L164-L176
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingAudio
func (api *TelegramBotAPI) NewOutgoingAudio(recipient Recipient, fileName string, reader io.Reader) *OutgoingAudio { return &OutgoingAudio{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileName: fileName, r: reader, }, } }
go
func (api *TelegramBotAPI) NewOutgoingAudio(recipient Recipient, fileName string, reader io.Reader) *OutgoingAudio { return &OutgoingAudio{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileName: fileName, r: reader, }, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingAudio", "(", "recipient", "Recipient", ",", "fileName", "string", ",", "reader", "io", ".", "Reader", ")", "*", "OutgoingAudio", "{", "return", "&", "OutgoingAudio", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "outgoingFileBase", ":", "outgoingFileBase", "{", "fileName", ":", "fileName", ",", "r", ":", "reader", ",", "}", ",", "}", "\n", "}" ]
// NewOutgoingAudio creates a new outgoing audio file.
[ "NewOutgoingAudio", "creates", "a", "new", "outgoing", "audio", "file", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L179-L192
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingAudioResend
func (api *TelegramBotAPI) NewOutgoingAudioResend(recipient Recipient, fileID string) *OutgoingAudio { return &OutgoingAudio{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileID: fileID, }, } }
go
func (api *TelegramBotAPI) NewOutgoingAudioResend(recipient Recipient, fileID string) *OutgoingAudio { return &OutgoingAudio{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileID: fileID, }, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingAudioResend", "(", "recipient", "Recipient", ",", "fileID", "string", ")", "*", "OutgoingAudio", "{", "return", "&", "OutgoingAudio", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "outgoingFileBase", ":", "outgoingFileBase", "{", "fileID", ":", "fileID", ",", "}", ",", "}", "\n", "}" ]
// NewOutgoingAudioResend creates a new outgoing audio file for re-sending.
[ "NewOutgoingAudioResend", "creates", "a", "new", "outgoing", "audio", "file", "for", "re", "-", "sending", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L195-L207
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingDocument
func (api *TelegramBotAPI) NewOutgoingDocument(recipient Recipient, fileName string, reader io.Reader) *OutgoingDocument { return &OutgoingDocument{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileName: fileName, r: reader, }, } }
go
func (api *TelegramBotAPI) NewOutgoingDocument(recipient Recipient, fileName string, reader io.Reader) *OutgoingDocument { return &OutgoingDocument{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileName: fileName, r: reader, }, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingDocument", "(", "recipient", "Recipient", ",", "fileName", "string", ",", "reader", "io", ".", "Reader", ")", "*", "OutgoingDocument", "{", "return", "&", "OutgoingDocument", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "outgoingFileBase", ":", "outgoingFileBase", "{", "fileName", ":", "fileName", ",", "r", ":", "reader", ",", "}", ",", "}", "\n", "}" ]
// NewOutgoingDocument creates a new outgoing file.
[ "NewOutgoingDocument", "creates", "a", "new", "outgoing", "file", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L210-L223
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingDocumentResend
func (api *TelegramBotAPI) NewOutgoingDocumentResend(recipient Recipient, fileID string) *OutgoingDocument { return &OutgoingDocument{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileID: fileID, }, } }
go
func (api *TelegramBotAPI) NewOutgoingDocumentResend(recipient Recipient, fileID string) *OutgoingDocument { return &OutgoingDocument{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, outgoingFileBase: outgoingFileBase{ fileID: fileID, }, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingDocumentResend", "(", "recipient", "Recipient", ",", "fileID", "string", ")", "*", "OutgoingDocument", "{", "return", "&", "OutgoingDocument", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "outgoingFileBase", ":", "outgoingFileBase", "{", "fileID", ":", "fileID", ",", "}", ",", "}", "\n", "}" ]
// NewOutgoingDocumentResend creates a new outgoing file for re-sending.
[ "NewOutgoingDocumentResend", "creates", "a", "new", "outgoing", "file", "for", "re", "-", "sending", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L226-L238
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingForward
func (api *TelegramBotAPI) NewOutgoingForward(recipient Recipient, origin Chat, messageID int) *OutgoingForward { return &OutgoingForward{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, FromChatID: NewRecipientFromChat(origin), MessageID: messageID, } }
go
func (api *TelegramBotAPI) NewOutgoingForward(recipient Recipient, origin Chat, messageID int) *OutgoingForward { return &OutgoingForward{ outgoingMessageBase: outgoingMessageBase{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, }, FromChatID: NewRecipientFromChat(origin), MessageID: messageID, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingForward", "(", "recipient", "Recipient", ",", "origin", "Chat", ",", "messageID", "int", ")", "*", "OutgoingForward", "{", "return", "&", "OutgoingForward", "{", "outgoingMessageBase", ":", "outgoingMessageBase", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "}", ",", "FromChatID", ":", "NewRecipientFromChat", "(", "origin", ")", ",", "MessageID", ":", "messageID", ",", "}", "\n", "}" ]
// NewOutgoingForward creates a new outgoing, forwarded message.
[ "NewOutgoingForward", "creates", "a", "new", "outgoing", "forwarded", "message", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L241-L252
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingChatAction
func (api *TelegramBotAPI) NewOutgoingChatAction(recipient Recipient, action ChatAction) *OutgoingChatAction { return &OutgoingChatAction{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, Action: action, } }
go
func (api *TelegramBotAPI) NewOutgoingChatAction(recipient Recipient, action ChatAction) *OutgoingChatAction { return &OutgoingChatAction{ outgoingBase: outgoingBase{ api: api, Recipient: recipient, }, Action: action, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingChatAction", "(", "recipient", "Recipient", ",", "action", "ChatAction", ")", "*", "OutgoingChatAction", "{", "return", "&", "OutgoingChatAction", "{", "outgoingBase", ":", "outgoingBase", "{", "api", ":", "api", ",", "Recipient", ":", "recipient", ",", "}", ",", "Action", ":", "action", ",", "}", "\n", "}" ]
// NewOutgoingChatAction creates a new outgoing chat action.
[ "NewOutgoingChatAction", "creates", "a", "new", "outgoing", "chat", "action", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L255-L263
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingUserProfilePhotosRequest
func (api *TelegramBotAPI) NewOutgoingUserProfilePhotosRequest(userID int) *OutgoingUserProfilePhotosRequest { return &OutgoingUserProfilePhotosRequest{ api: api, UserID: userID, } }
go
func (api *TelegramBotAPI) NewOutgoingUserProfilePhotosRequest(userID int) *OutgoingUserProfilePhotosRequest { return &OutgoingUserProfilePhotosRequest{ api: api, UserID: userID, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingUserProfilePhotosRequest", "(", "userID", "int", ")", "*", "OutgoingUserProfilePhotosRequest", "{", "return", "&", "OutgoingUserProfilePhotosRequest", "{", "api", ":", "api", ",", "UserID", ":", "userID", ",", "}", "\n", "}" ]
// NewOutgoingUserProfilePhotosRequest creates a new request for a users // profile photos.
[ "NewOutgoingUserProfilePhotosRequest", "creates", "a", "new", "request", "for", "a", "users", "profile", "photos", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L267-L272
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingKickChatMember
func (api *TelegramBotAPI) NewOutgoingKickChatMember(chat Recipient, userID int) *OutgoingKickChatMember { return &OutgoingKickChatMember{ api: api, Recipient: chat, UserID: userID, } }
go
func (api *TelegramBotAPI) NewOutgoingKickChatMember(chat Recipient, userID int) *OutgoingKickChatMember { return &OutgoingKickChatMember{ api: api, Recipient: chat, UserID: userID, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingKickChatMember", "(", "chat", "Recipient", ",", "userID", "int", ")", "*", "OutgoingKickChatMember", "{", "return", "&", "OutgoingKickChatMember", "{", "api", ":", "api", ",", "Recipient", ":", "chat", ",", "UserID", ":", "userID", ",", "}", "\n", "}" ]
// NewOutgoingKickChatMember creates a request to kick a member from a // group chat or channel.
[ "NewOutgoingKickChatMember", "creates", "a", "request", "to", "kick", "a", "member", "from", "a", "group", "chat", "or", "channel", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L276-L282
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingUnbanChatMember
func (api *TelegramBotAPI) NewOutgoingUnbanChatMember(chat Recipient, userID int) *OutgoingUnbanChatMember { return &OutgoingUnbanChatMember{ api: api, Recipient: chat, UserID: userID, } }
go
func (api *TelegramBotAPI) NewOutgoingUnbanChatMember(chat Recipient, userID int) *OutgoingUnbanChatMember { return &OutgoingUnbanChatMember{ api: api, Recipient: chat, UserID: userID, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingUnbanChatMember", "(", "chat", "Recipient", ",", "userID", "int", ")", "*", "OutgoingUnbanChatMember", "{", "return", "&", "OutgoingUnbanChatMember", "{", "api", ":", "api", ",", "Recipient", ":", "chat", ",", "UserID", ":", "userID", ",", "}", "\n", "}" ]
// NewOutgoingUnbanChatMember creates a request to unban a member of a // group chat or channel.
[ "NewOutgoingUnbanChatMember", "creates", "a", "request", "to", "unban", "a", "member", "of", "a", "group", "chat", "or", "channel", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L286-L292
test
mrd0ll4r/tbotapi
ctors.go
NewOutgoingCallbackQueryResponse
func (api *TelegramBotAPI) NewOutgoingCallbackQueryResponse(queryID string) *OutgoingCallbackQueryResponse { return &OutgoingCallbackQueryResponse{ api: api, CallbackQueryID: queryID, } }
go
func (api *TelegramBotAPI) NewOutgoingCallbackQueryResponse(queryID string) *OutgoingCallbackQueryResponse { return &OutgoingCallbackQueryResponse{ api: api, CallbackQueryID: queryID, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewOutgoingCallbackQueryResponse", "(", "queryID", "string", ")", "*", "OutgoingCallbackQueryResponse", "{", "return", "&", "OutgoingCallbackQueryResponse", "{", "api", ":", "api", ",", "CallbackQueryID", ":", "queryID", ",", "}", "\n", "}" ]
// NewOutgoingCallbackQueryResponse creates a response to a callback query.
[ "NewOutgoingCallbackQueryResponse", "creates", "a", "response", "to", "a", "callback", "query", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L295-L300
test
mrd0ll4r/tbotapi
ctors.go
NewInlineQueryAnswer
func (api *TelegramBotAPI) NewInlineQueryAnswer(queryID string, results []InlineQueryResult) *InlineQueryAnswer { return &InlineQueryAnswer{ api: api, QueryID: queryID, Results: results, } }
go
func (api *TelegramBotAPI) NewInlineQueryAnswer(queryID string, results []InlineQueryResult) *InlineQueryAnswer { return &InlineQueryAnswer{ api: api, QueryID: queryID, Results: results, } }
[ "func", "(", "api", "*", "TelegramBotAPI", ")", "NewInlineQueryAnswer", "(", "queryID", "string", ",", "results", "[", "]", "InlineQueryResult", ")", "*", "InlineQueryAnswer", "{", "return", "&", "InlineQueryAnswer", "{", "api", ":", "api", ",", "QueryID", ":", "queryID", ",", "Results", ":", "results", ",", "}", "\n", "}" ]
// NewInlineQueryAnswer creates a new inline query answer.
[ "NewInlineQueryAnswer", "creates", "a", "new", "inline", "query", "answer", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/ctors.go#L303-L309
test
mrd0ll4r/tbotapi
incoming.go
Type
func (m *Message) Type() MessageType { if m.Text != nil { return TextMessage } else if m.Audio != nil { return AudioMessage } else if m.Document != nil { return DocumentMessage } else if m.Photo != nil { return PhotoMessage } else if m.Sticker != nil { return StickerMessage } else if m.Video != nil { return VideoMessage } else if m.Voice != nil { return VoiceMessage } else if m.Contact != nil { return ContactMessage } else if m.Location != nil { return LocationMessage } else if m.NewChatMember != nil { return NewChatMember } else if m.LeftChatMember != nil { return LeftChatMember } else if m.NewChatTitle != nil { return NewChatTitle } else if m.NewChatPhoto != nil { return NewChatPhoto } else if m.DeleteChatPhoto { return DeletedChatPhoto } else if m.GroupChatCreated { return GroupChatCreated } else if m.SupergroupChatCreated { return SupergroupChatCreated } else if m.ChannelChatCreated { return ChannelChatCreated } else if m.MigrateToChatID != nil { return MigrationToSupergroup } else if m.MigrateFromChatID != nil { return MigrationFromGroup } else if m.Venue != nil { return VenueMessage } else if m.PinnedMessage != nil { return PinnedMessage } return UnknownMessage }
go
func (m *Message) Type() MessageType { if m.Text != nil { return TextMessage } else if m.Audio != nil { return AudioMessage } else if m.Document != nil { return DocumentMessage } else if m.Photo != nil { return PhotoMessage } else if m.Sticker != nil { return StickerMessage } else if m.Video != nil { return VideoMessage } else if m.Voice != nil { return VoiceMessage } else if m.Contact != nil { return ContactMessage } else if m.Location != nil { return LocationMessage } else if m.NewChatMember != nil { return NewChatMember } else if m.LeftChatMember != nil { return LeftChatMember } else if m.NewChatTitle != nil { return NewChatTitle } else if m.NewChatPhoto != nil { return NewChatPhoto } else if m.DeleteChatPhoto { return DeletedChatPhoto } else if m.GroupChatCreated { return GroupChatCreated } else if m.SupergroupChatCreated { return SupergroupChatCreated } else if m.ChannelChatCreated { return ChannelChatCreated } else if m.MigrateToChatID != nil { return MigrationToSupergroup } else if m.MigrateFromChatID != nil { return MigrationFromGroup } else if m.Venue != nil { return VenueMessage } else if m.PinnedMessage != nil { return PinnedMessage } return UnknownMessage }
[ "func", "(", "m", "*", "Message", ")", "Type", "(", ")", "MessageType", "{", "if", "m", ".", "Text", "!=", "nil", "{", "return", "TextMessage", "\n", "}", "else", "if", "m", ".", "Audio", "!=", "nil", "{", "return", "AudioMessage", "\n", "}", "else", "if", "m", ".", "Document", "!=", "nil", "{", "return", "DocumentMessage", "\n", "}", "else", "if", "m", ".", "Photo", "!=", "nil", "{", "return", "PhotoMessage", "\n", "}", "else", "if", "m", ".", "Sticker", "!=", "nil", "{", "return", "StickerMessage", "\n", "}", "else", "if", "m", ".", "Video", "!=", "nil", "{", "return", "VideoMessage", "\n", "}", "else", "if", "m", ".", "Voice", "!=", "nil", "{", "return", "VoiceMessage", "\n", "}", "else", "if", "m", ".", "Contact", "!=", "nil", "{", "return", "ContactMessage", "\n", "}", "else", "if", "m", ".", "Location", "!=", "nil", "{", "return", "LocationMessage", "\n", "}", "else", "if", "m", ".", "NewChatMember", "!=", "nil", "{", "return", "NewChatMember", "\n", "}", "else", "if", "m", ".", "LeftChatMember", "!=", "nil", "{", "return", "LeftChatMember", "\n", "}", "else", "if", "m", ".", "NewChatTitle", "!=", "nil", "{", "return", "NewChatTitle", "\n", "}", "else", "if", "m", ".", "NewChatPhoto", "!=", "nil", "{", "return", "NewChatPhoto", "\n", "}", "else", "if", "m", ".", "DeleteChatPhoto", "{", "return", "DeletedChatPhoto", "\n", "}", "else", "if", "m", ".", "GroupChatCreated", "{", "return", "GroupChatCreated", "\n", "}", "else", "if", "m", ".", "SupergroupChatCreated", "{", "return", "SupergroupChatCreated", "\n", "}", "else", "if", "m", ".", "ChannelChatCreated", "{", "return", "ChannelChatCreated", "\n", "}", "else", "if", "m", ".", "MigrateToChatID", "!=", "nil", "{", "return", "MigrationToSupergroup", "\n", "}", "else", "if", "m", ".", "MigrateFromChatID", "!=", "nil", "{", "return", "MigrationFromGroup", "\n", "}", "else", "if", "m", ".", "Venue", "!=", "nil", "{", "return", "VenueMessage", "\n", "}", "else", "if", "m", ".", "PinnedMessage", "!=", "nil", "{", "return", "PinnedMessage", "\n", "}", "\n", "return", "UnknownMessage", "\n", "}" ]
// Type determines the type of the message. // Note that, for all these types, messages can still be replies or // forwarded.
[ "Type", "determines", "the", "type", "of", "the", "message", ".", "Note", "that", "for", "all", "these", "types", "messages", "can", "still", "be", "replies", "or", "forwarded", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/incoming.go#L150-L196
test
mrd0ll4r/tbotapi
incoming.go
Type
func (u *Update) Type() UpdateType { if u.Message != nil { return MessageUpdate } else if u.InlineQuery != nil { return InlineQueryUpdate } else if u.ChosenInlineResult != nil { return ChosenInlineResultUpdate } return UnknownUpdate }
go
func (u *Update) Type() UpdateType { if u.Message != nil { return MessageUpdate } else if u.InlineQuery != nil { return InlineQueryUpdate } else if u.ChosenInlineResult != nil { return ChosenInlineResultUpdate } return UnknownUpdate }
[ "func", "(", "u", "*", "Update", ")", "Type", "(", ")", "UpdateType", "{", "if", "u", ".", "Message", "!=", "nil", "{", "return", "MessageUpdate", "\n", "}", "else", "if", "u", ".", "InlineQuery", "!=", "nil", "{", "return", "InlineQueryUpdate", "\n", "}", "else", "if", "u", ".", "ChosenInlineResult", "!=", "nil", "{", "return", "ChosenInlineResultUpdate", "\n", "}", "\n", "return", "UnknownUpdate", "\n", "}" ]
// Type returns the type of the update.
[ "Type", "returns", "the", "type", "of", "the", "update", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/incoming.go#L376-L385
test
mrd0ll4r/tbotapi
shared.go
MarshalJSON
func (r Recipient) MarshalJSON() ([]byte, error) { toReturn := "" if r.isChannel() { toReturn = fmt.Sprintf("\"%s\"", *r.ChannelID) } else { toReturn = fmt.Sprintf("%d", *r.ChatID) } return []byte(toReturn), nil }
go
func (r Recipient) MarshalJSON() ([]byte, error) { toReturn := "" if r.isChannel() { toReturn = fmt.Sprintf("\"%s\"", *r.ChannelID) } else { toReturn = fmt.Sprintf("%d", *r.ChatID) } return []byte(toReturn), nil }
[ "func", "(", "r", "Recipient", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "toReturn", ":=", "\"\"", "\n", "if", "r", ".", "isChannel", "(", ")", "{", "toReturn", "=", "fmt", ".", "Sprintf", "(", "\"\\\"%s\\\"\"", ",", "\\\"", ")", "\n", "}", "else", "\\\"", "\n", "*", "r", ".", "ChannelID", "\n", "}" ]
// MarshalJSON marshals the recipient to JSON.
[ "MarshalJSON", "marshals", "the", "recipient", "to", "JSON", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/shared.go#L43-L53
test
mrd0ll4r/tbotapi
outgoing.go
querystring
func (ow *outgoingSetWebhook) querystring() querystring { toReturn := make(map[string]string) if ow.URL != "" { toReturn["url"] = ow.URL } return querystring(toReturn) }
go
func (ow *outgoingSetWebhook) querystring() querystring { toReturn := make(map[string]string) if ow.URL != "" { toReturn["url"] = ow.URL } return querystring(toReturn) }
[ "func", "(", "ow", "*", "outgoingSetWebhook", ")", "querystring", "(", ")", "querystring", "{", "toReturn", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "if", "ow", ".", "URL", "!=", "\"\"", "{", "toReturn", "[", "\"url\"", "]", "=", "ow", ".", "URL", "\n", "}", "\n", "return", "querystring", "(", "toReturn", ")", "\n", "}" ]
// querystring implements querystringer to represent the outgoing certificate // file.
[ "querystring", "implements", "querystringer", "to", "represent", "the", "outgoing", "certificate", "file", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/outgoing.go#L20-L28
test
mrd0ll4r/tbotapi
outgoing.go
getBaseQueryString
func (op *outgoingBase) getBaseQueryString() querystring { toReturn := map[string]string{} if op.Recipient.isChannel() { //Channel toReturn["chat_id"] = fmt.Sprint(*op.Recipient.ChannelID) } else { toReturn["chat_id"] = fmt.Sprint(*op.Recipient.ChatID) } return querystring(toReturn) }
go
func (op *outgoingBase) getBaseQueryString() querystring { toReturn := map[string]string{} if op.Recipient.isChannel() { //Channel toReturn["chat_id"] = fmt.Sprint(*op.Recipient.ChannelID) } else { toReturn["chat_id"] = fmt.Sprint(*op.Recipient.ChatID) } return querystring(toReturn) }
[ "func", "(", "op", "*", "outgoingBase", ")", "getBaseQueryString", "(", ")", "querystring", "{", "toReturn", ":=", "map", "[", "string", "]", "string", "{", "}", "\n", "if", "op", ".", "Recipient", ".", "isChannel", "(", ")", "{", "toReturn", "[", "\"chat_id\"", "]", "=", "fmt", ".", "Sprint", "(", "*", "op", ".", "Recipient", ".", "ChannelID", ")", "\n", "}", "else", "{", "toReturn", "[", "\"chat_id\"", "]", "=", "fmt", ".", "Sprint", "(", "*", "op", ".", "Recipient", ".", "ChatID", ")", "\n", "}", "\n", "return", "querystring", "(", "toReturn", ")", "\n", "}" ]
// getBaseQueryString gets a Querystring representing this message.
[ "getBaseQueryString", "gets", "a", "Querystring", "representing", "this", "message", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/outgoing.go#L107-L117
test
mrd0ll4r/tbotapi
outgoing.go
getBaseQueryString
func (op *outgoingMessageBase) getBaseQueryString() querystring { toReturn := map[string]string{} if op.Recipient.isChannel() { //Channel. toReturn["chat_id"] = fmt.Sprint(*op.Recipient.ChannelID) } else { toReturn["chat_id"] = fmt.Sprint(*op.Recipient.ChatID) } if op.replyToMessageIDSet { toReturn["reply_to_message_id"] = fmt.Sprint(op.ReplyToMessageID) } if op.replyMarkupSet { b, err := json.Marshal(op.ReplyMarkup) if err != nil { panic(err) } toReturn["reply_markup"] = string(b) } if op.DisableNotification { toReturn["disable_notification"] = fmt.Sprint(op.DisableNotification) } return querystring(toReturn) }
go
func (op *outgoingMessageBase) getBaseQueryString() querystring { toReturn := map[string]string{} if op.Recipient.isChannel() { //Channel. toReturn["chat_id"] = fmt.Sprint(*op.Recipient.ChannelID) } else { toReturn["chat_id"] = fmt.Sprint(*op.Recipient.ChatID) } if op.replyToMessageIDSet { toReturn["reply_to_message_id"] = fmt.Sprint(op.ReplyToMessageID) } if op.replyMarkupSet { b, err := json.Marshal(op.ReplyMarkup) if err != nil { panic(err) } toReturn["reply_markup"] = string(b) } if op.DisableNotification { toReturn["disable_notification"] = fmt.Sprint(op.DisableNotification) } return querystring(toReturn) }
[ "func", "(", "op", "*", "outgoingMessageBase", ")", "getBaseQueryString", "(", ")", "querystring", "{", "toReturn", ":=", "map", "[", "string", "]", "string", "{", "}", "\n", "if", "op", ".", "Recipient", ".", "isChannel", "(", ")", "{", "toReturn", "[", "\"chat_id\"", "]", "=", "fmt", ".", "Sprint", "(", "*", "op", ".", "Recipient", ".", "ChannelID", ")", "\n", "}", "else", "{", "toReturn", "[", "\"chat_id\"", "]", "=", "fmt", ".", "Sprint", "(", "*", "op", ".", "Recipient", ".", "ChatID", ")", "\n", "}", "\n", "if", "op", ".", "replyToMessageIDSet", "{", "toReturn", "[", "\"reply_to_message_id\"", "]", "=", "fmt", ".", "Sprint", "(", "op", ".", "ReplyToMessageID", ")", "\n", "}", "\n", "if", "op", ".", "replyMarkupSet", "{", "b", ",", "err", ":=", "json", ".", "Marshal", "(", "op", ".", "ReplyMarkup", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "toReturn", "[", "\"reply_markup\"", "]", "=", "string", "(", "b", ")", "\n", "}", "\n", "if", "op", ".", "DisableNotification", "{", "toReturn", "[", "\"disable_notification\"", "]", "=", "fmt", ".", "Sprint", "(", "op", ".", "DisableNotification", ")", "\n", "}", "\n", "return", "querystring", "(", "toReturn", ")", "\n", "}" ]
// getMessageBaseQueryString gets a Querystring representing this message.
[ "getMessageBaseQueryString", "gets", "a", "Querystring", "representing", "this", "message", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/outgoing.go#L120-L146
test
mrd0ll4r/tbotapi
outgoing.go
querystring
func (oa *OutgoingAudio) querystring() querystring { toReturn := map[string]string(oa.getBaseQueryString()) if oa.Duration != 0 { toReturn["duration"] = fmt.Sprint(oa.Duration) } if oa.Performer != "" { toReturn["performer"] = oa.Performer } if oa.Title != "" { toReturn["title"] = oa.Title } return querystring(toReturn) }
go
func (oa *OutgoingAudio) querystring() querystring { toReturn := map[string]string(oa.getBaseQueryString()) if oa.Duration != 0 { toReturn["duration"] = fmt.Sprint(oa.Duration) } if oa.Performer != "" { toReturn["performer"] = oa.Performer } if oa.Title != "" { toReturn["title"] = oa.Title } return querystring(toReturn) }
[ "func", "(", "oa", "*", "OutgoingAudio", ")", "querystring", "(", ")", "querystring", "{", "toReturn", ":=", "map", "[", "string", "]", "string", "(", "oa", ".", "getBaseQueryString", "(", ")", ")", "\n", "if", "oa", ".", "Duration", "!=", "0", "{", "toReturn", "[", "\"duration\"", "]", "=", "fmt", ".", "Sprint", "(", "oa", ".", "Duration", ")", "\n", "}", "\n", "if", "oa", ".", "Performer", "!=", "\"\"", "{", "toReturn", "[", "\"performer\"", "]", "=", "oa", ".", "Performer", "\n", "}", "\n", "if", "oa", ".", "Title", "!=", "\"\"", "{", "toReturn", "[", "\"title\"", "]", "=", "oa", ".", "Title", "\n", "}", "\n", "return", "querystring", "(", "toReturn", ")", "\n", "}" ]
// querystring implements querystringer to represent the audio file.
[ "querystring", "implements", "querystringer", "to", "represent", "the", "audio", "file", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/outgoing.go#L194-L210
test
mrd0ll4r/tbotapi
outgoing.go
querystring
func (op *OutgoingPhoto) querystring() querystring { toReturn := map[string]string(op.getBaseQueryString()) if op.Caption != "" { toReturn["caption"] = op.Caption } return querystring(toReturn) }
go
func (op *OutgoingPhoto) querystring() querystring { toReturn := map[string]string(op.getBaseQueryString()) if op.Caption != "" { toReturn["caption"] = op.Caption } return querystring(toReturn) }
[ "func", "(", "op", "*", "OutgoingPhoto", ")", "querystring", "(", ")", "querystring", "{", "toReturn", ":=", "map", "[", "string", "]", "string", "(", "op", ".", "getBaseQueryString", "(", ")", ")", "\n", "if", "op", ".", "Caption", "!=", "\"\"", "{", "toReturn", "[", "\"caption\"", "]", "=", "op", ".", "Caption", "\n", "}", "\n", "return", "querystring", "(", "toReturn", ")", "\n", "}" ]
// querystring implements querystringer to represent the photo.
[ "querystring", "implements", "querystringer", "to", "represent", "the", "photo", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/outgoing.go#L304-L312
test
mrd0ll4r/tbotapi
outgoing.go
querystring
func (op *OutgoingUserProfilePhotosRequest) querystring() querystring { toReturn := map[string]string{} toReturn["user_id"] = fmt.Sprint(op.UserID) if op.Offset != 0 { toReturn["offset"] = fmt.Sprint(op.Offset) } if op.Limit != 0 { toReturn["limit"] = fmt.Sprint(op.Limit) } return querystring(toReturn) }
go
func (op *OutgoingUserProfilePhotosRequest) querystring() querystring { toReturn := map[string]string{} toReturn["user_id"] = fmt.Sprint(op.UserID) if op.Offset != 0 { toReturn["offset"] = fmt.Sprint(op.Offset) } if op.Limit != 0 { toReturn["limit"] = fmt.Sprint(op.Limit) } return querystring(toReturn) }
[ "func", "(", "op", "*", "OutgoingUserProfilePhotosRequest", ")", "querystring", "(", ")", "querystring", "{", "toReturn", ":=", "map", "[", "string", "]", "string", "{", "}", "\n", "toReturn", "[", "\"user_id\"", "]", "=", "fmt", ".", "Sprint", "(", "op", ".", "UserID", ")", "\n", "if", "op", ".", "Offset", "!=", "0", "{", "toReturn", "[", "\"offset\"", "]", "=", "fmt", ".", "Sprint", "(", "op", ".", "Offset", ")", "\n", "}", "\n", "if", "op", ".", "Limit", "!=", "0", "{", "toReturn", "[", "\"limit\"", "]", "=", "fmt", ".", "Sprint", "(", "op", ".", "Limit", ")", "\n", "}", "\n", "return", "querystring", "(", "toReturn", ")", "\n", "}" ]
// querystring implements querystringer to represent the request.
[ "querystring", "implements", "querystringer", "to", "represent", "the", "request", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/outgoing.go#L369-L382
test
mrd0ll4r/tbotapi
outgoing.go
querystring
func (ov *OutgoingVideo) querystring() querystring { toReturn := map[string]string(ov.getBaseQueryString()) if ov.Caption != "" { toReturn["caption"] = ov.Caption } if ov.Duration != 0 { toReturn["duration"] = fmt.Sprint(ov.Duration) } return querystring(toReturn) }
go
func (ov *OutgoingVideo) querystring() querystring { toReturn := map[string]string(ov.getBaseQueryString()) if ov.Caption != "" { toReturn["caption"] = ov.Caption } if ov.Duration != 0 { toReturn["duration"] = fmt.Sprint(ov.Duration) } return querystring(toReturn) }
[ "func", "(", "ov", "*", "OutgoingVideo", ")", "querystring", "(", ")", "querystring", "{", "toReturn", ":=", "map", "[", "string", "]", "string", "(", "ov", ".", "getBaseQueryString", "(", ")", ")", "\n", "if", "ov", ".", "Caption", "!=", "\"\"", "{", "toReturn", "[", "\"caption\"", "]", "=", "ov", ".", "Caption", "\n", "}", "\n", "if", "ov", ".", "Duration", "!=", "0", "{", "toReturn", "[", "\"duration\"", "]", "=", "fmt", ".", "Sprint", "(", "ov", ".", "Duration", ")", "\n", "}", "\n", "return", "querystring", "(", "toReturn", ")", "\n", "}" ]
// querystring implements querystringer to represent the outgoing video // file.
[ "querystring", "implements", "querystringer", "to", "represent", "the", "outgoing", "video", "file", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/outgoing.go#L406-L418
test
mrd0ll4r/tbotapi
outgoing.go
querystring
func (ov *OutgoingVoice) querystring() querystring { toReturn := map[string]string(ov.getBaseQueryString()) if ov.Duration != 0 { toReturn["duration"] = fmt.Sprint(ov.Duration) } return querystring(toReturn) }
go
func (ov *OutgoingVoice) querystring() querystring { toReturn := map[string]string(ov.getBaseQueryString()) if ov.Duration != 0 { toReturn["duration"] = fmt.Sprint(ov.Duration) } return querystring(toReturn) }
[ "func", "(", "ov", "*", "OutgoingVoice", ")", "querystring", "(", ")", "querystring", "{", "toReturn", ":=", "map", "[", "string", "]", "string", "(", "ov", ".", "getBaseQueryString", "(", ")", ")", "\n", "if", "ov", ".", "Duration", "!=", "0", "{", "toReturn", "[", "\"duration\"", "]", "=", "fmt", ".", "Sprint", "(", "ov", ".", "Duration", ")", "\n", "}", "\n", "return", "querystring", "(", "toReturn", ")", "\n", "}" ]
// querystring implements querystringer to represent the outgoing voice // note.
[ "querystring", "implements", "querystringer", "to", "represent", "the", "outgoing", "voice", "note", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/outgoing.go#L435-L443
test
mrd0ll4r/tbotapi
outgoing.go
NewInlineQueryResultArticle
func NewInlineQueryResultArticle(id, title, text string) *InlineQueryResultArticle { return &InlineQueryResultArticle{ InlineQueryResultBase: InlineQueryResultBase{ Type: ArticleResult, ID: id, }, Title: title, Text: text, } }
go
func NewInlineQueryResultArticle(id, title, text string) *InlineQueryResultArticle { return &InlineQueryResultArticle{ InlineQueryResultBase: InlineQueryResultBase{ Type: ArticleResult, ID: id, }, Title: title, Text: text, } }
[ "func", "NewInlineQueryResultArticle", "(", "id", ",", "title", ",", "text", "string", ")", "*", "InlineQueryResultArticle", "{", "return", "&", "InlineQueryResultArticle", "{", "InlineQueryResultBase", ":", "InlineQueryResultBase", "{", "Type", ":", "ArticleResult", ",", "ID", ":", "id", ",", "}", ",", "Title", ":", "title", ",", "Text", ":", "text", ",", "}", "\n", "}" ]
// NewInlineQueryResultArticle returns a new InlineQueryResultArticle with // all mandatory fields set.
[ "NewInlineQueryResultArticle", "returns", "a", "new", "InlineQueryResultArticle", "with", "all", "mandatory", "fields", "set", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/outgoing.go#L592-L601
test
mrd0ll4r/tbotapi
outgoing.go
NewInlineQueryResultPhoto
func NewInlineQueryResultPhoto(id, photoURL, thumbURL string) *InlineQueryResultPhoto { return &InlineQueryResultPhoto{ InlineQueryResultBase: InlineQueryResultBase{ Type: PhotoResult, ID: id, }, PhotoURL: photoURL, ThumbURL: thumbURL, } }
go
func NewInlineQueryResultPhoto(id, photoURL, thumbURL string) *InlineQueryResultPhoto { return &InlineQueryResultPhoto{ InlineQueryResultBase: InlineQueryResultBase{ Type: PhotoResult, ID: id, }, PhotoURL: photoURL, ThumbURL: thumbURL, } }
[ "func", "NewInlineQueryResultPhoto", "(", "id", ",", "photoURL", ",", "thumbURL", "string", ")", "*", "InlineQueryResultPhoto", "{", "return", "&", "InlineQueryResultPhoto", "{", "InlineQueryResultBase", ":", "InlineQueryResultBase", "{", "Type", ":", "PhotoResult", ",", "ID", ":", "id", ",", "}", ",", "PhotoURL", ":", "photoURL", ",", "ThumbURL", ":", "thumbURL", ",", "}", "\n", "}" ]
// NewInlineQueryResultPhoto returns a new InlineQueryResultPhoto with all // mandatory fields set.
[ "NewInlineQueryResultPhoto", "returns", "a", "new", "InlineQueryResultPhoto", "with", "all", "mandatory", "fields", "set", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/outgoing.go#L624-L633
test
mrd0ll4r/tbotapi
outgoing.go
NewInlineQueryResultGif
func NewInlineQueryResultGif(id, gifURL, thumbURL string) *InlineQueryResultGif { return &InlineQueryResultGif{ InlineQueryResultBase: InlineQueryResultBase{ Type: GifResult, ID: id, }, GifURL: gifURL, ThumbURL: thumbURL, } }
go
func NewInlineQueryResultGif(id, gifURL, thumbURL string) *InlineQueryResultGif { return &InlineQueryResultGif{ InlineQueryResultBase: InlineQueryResultBase{ Type: GifResult, ID: id, }, GifURL: gifURL, ThumbURL: thumbURL, } }
[ "func", "NewInlineQueryResultGif", "(", "id", ",", "gifURL", ",", "thumbURL", "string", ")", "*", "InlineQueryResultGif", "{", "return", "&", "InlineQueryResultGif", "{", "InlineQueryResultBase", ":", "InlineQueryResultBase", "{", "Type", ":", "GifResult", ",", "ID", ":", "id", ",", "}", ",", "GifURL", ":", "gifURL", ",", "ThumbURL", ":", "thumbURL", ",", "}", "\n", "}" ]
// NewInlineQueryResultGif returns a new InlineQueryResultGif with all // mandatory fields set.
[ "NewInlineQueryResultGif", "returns", "a", "new", "InlineQueryResultGif", "with", "all", "mandatory", "fields", "set", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/outgoing.go#L648-L657
test
mrd0ll4r/tbotapi
outgoing.go
NewInlineQueryResultMpeg4Gif
func NewInlineQueryResultMpeg4Gif(id, mpeg4URL, thumbURL string) *InlineQueryResultMpeg4Gif { return &InlineQueryResultMpeg4Gif{ InlineQueryResultBase: InlineQueryResultBase{ Type: PhotoResult, ID: id, }, Mpeg4URL: mpeg4URL, ThumbURL: thumbURL, } }
go
func NewInlineQueryResultMpeg4Gif(id, mpeg4URL, thumbURL string) *InlineQueryResultMpeg4Gif { return &InlineQueryResultMpeg4Gif{ InlineQueryResultBase: InlineQueryResultBase{ Type: PhotoResult, ID: id, }, Mpeg4URL: mpeg4URL, ThumbURL: thumbURL, } }
[ "func", "NewInlineQueryResultMpeg4Gif", "(", "id", ",", "mpeg4URL", ",", "thumbURL", "string", ")", "*", "InlineQueryResultMpeg4Gif", "{", "return", "&", "InlineQueryResultMpeg4Gif", "{", "InlineQueryResultBase", ":", "InlineQueryResultBase", "{", "Type", ":", "PhotoResult", ",", "ID", ":", "id", ",", "}", ",", "Mpeg4URL", ":", "mpeg4URL", ",", "ThumbURL", ":", "thumbURL", ",", "}", "\n", "}" ]
// NewInlineQueryResultMpeg4Gif returns a new InlineQueryResultMpeg4Gif // with all mandatory fields set.
[ "NewInlineQueryResultMpeg4Gif", "returns", "a", "new", "InlineQueryResultMpeg4Gif", "with", "all", "mandatory", "fields", "set", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/outgoing.go#L673-L682
test
mrd0ll4r/tbotapi
outgoing.go
NewInlineQueryResultVideo
func NewInlineQueryResultVideo(id, videoURL, thumbURL, title, text string, mimeType MIMEType) *InlineQueryResultVideo { return &InlineQueryResultVideo{ InlineQueryResultBase: InlineQueryResultBase{ Type: PhotoResult, ID: id, }, VideoURL: videoURL, MIMEType: mimeType, ThumbURL: thumbURL, Title: title, Text: text, } }
go
func NewInlineQueryResultVideo(id, videoURL, thumbURL, title, text string, mimeType MIMEType) *InlineQueryResultVideo { return &InlineQueryResultVideo{ InlineQueryResultBase: InlineQueryResultBase{ Type: PhotoResult, ID: id, }, VideoURL: videoURL, MIMEType: mimeType, ThumbURL: thumbURL, Title: title, Text: text, } }
[ "func", "NewInlineQueryResultVideo", "(", "id", ",", "videoURL", ",", "thumbURL", ",", "title", ",", "text", "string", ",", "mimeType", "MIMEType", ")", "*", "InlineQueryResultVideo", "{", "return", "&", "InlineQueryResultVideo", "{", "InlineQueryResultBase", ":", "InlineQueryResultBase", "{", "Type", ":", "PhotoResult", ",", "ID", ":", "id", ",", "}", ",", "VideoURL", ":", "videoURL", ",", "MIMEType", ":", "mimeType", ",", "ThumbURL", ":", "thumbURL", ",", "Title", ":", "title", ",", "Text", ":", "text", ",", "}", "\n", "}" ]
// NewInlineQueryResultVideo returns a new InlineQueryResultVideo with all // mandatory fields set.
[ "NewInlineQueryResultVideo", "returns", "a", "new", "InlineQueryResultVideo", "with", "all", "mandatory", "fields", "set", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/outgoing.go#L710-L722
test
mrd0ll4r/tbotapi
sendable.go
Send
func (op *OutgoingUserProfilePhotosRequest) Send() (*UserProfilePhotosResponse, error) { resp := &UserProfilePhotosResponse{} _, err := op.api.c.postJSON(getUserProfilePhotos, resp, op) if err != nil { return nil, err } err = check(&resp.baseResponse) if err != nil { return nil, err } return resp, nil }
go
func (op *OutgoingUserProfilePhotosRequest) Send() (*UserProfilePhotosResponse, error) { resp := &UserProfilePhotosResponse{} _, err := op.api.c.postJSON(getUserProfilePhotos, resp, op) if err != nil { return nil, err } err = check(&resp.baseResponse) if err != nil { return nil, err } return resp, nil }
[ "func", "(", "op", "*", "OutgoingUserProfilePhotosRequest", ")", "Send", "(", ")", "(", "*", "UserProfilePhotosResponse", ",", "error", ")", "{", "resp", ":=", "&", "UserProfilePhotosResponse", "{", "}", "\n", "_", ",", "err", ":=", "op", ".", "api", ".", "c", ".", "postJSON", "(", "getUserProfilePhotos", ",", "resp", ",", "op", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "err", "=", "check", "(", "&", "resp", ".", "baseResponse", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "resp", ",", "nil", "\n", "}" ]
// Send sends the request. // On success, the photos are returned as a UserProfilePhotosResponse.
[ "Send", "sends", "the", "request", ".", "On", "success", "the", "photos", "are", "returned", "as", "a", "UserProfilePhotosResponse", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/sendable.go#L91-L104
test
mrd0ll4r/tbotapi
sendable.go
Send
func (oc *OutgoingChatAction) Send() error { resp := &baseResponse{} _, err := oc.api.c.postJSON(sendChatAction, resp, oc) if err != nil { return err } return check(resp) }
go
func (oc *OutgoingChatAction) Send() error { resp := &baseResponse{} _, err := oc.api.c.postJSON(sendChatAction, resp, oc) if err != nil { return err } return check(resp) }
[ "func", "(", "oc", "*", "OutgoingChatAction", ")", "Send", "(", ")", "error", "{", "resp", ":=", "&", "baseResponse", "{", "}", "\n", "_", ",", "err", ":=", "oc", ".", "api", ".", "c", ".", "postJSON", "(", "sendChatAction", ",", "resp", ",", "oc", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "check", "(", "resp", ")", "\n", "}" ]
// Send sends the chat action. // On success, nil is returned.
[ "Send", "sends", "the", "chat", "action", ".", "On", "success", "nil", "is", "returned", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/sendable.go#L108-L117
test
mrd0ll4r/tbotapi
sendable.go
Send
func (ia *InlineQueryAnswer) Send() error { resp := &baseResponse{} _, err := ia.api.c.postJSON(answerInlineQuery, resp, ia) if err != nil { return err } return check(resp) }
go
func (ia *InlineQueryAnswer) Send() error { resp := &baseResponse{} _, err := ia.api.c.postJSON(answerInlineQuery, resp, ia) if err != nil { return err } return check(resp) }
[ "func", "(", "ia", "*", "InlineQueryAnswer", ")", "Send", "(", ")", "error", "{", "resp", ":=", "&", "baseResponse", "{", "}", "\n", "_", ",", "err", ":=", "ia", ".", "api", ".", "c", ".", "postJSON", "(", "answerInlineQuery", ",", "resp", ",", "ia", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "check", "(", "resp", ")", "\n", "}" ]
// Send sends the inline query answer. // On success, nil is returned.
[ "Send", "sends", "the", "inline", "query", "answer", ".", "On", "success", "nil", "is", "returned", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/sendable.go#L121-L130
test
mrd0ll4r/tbotapi
sendable.go
Send
func (kr *OutgoingKickChatMember) Send() error { resp := &baseResponse{} _, err := kr.api.c.postJSON(kickChatMember, resp, kr) if err != nil { return err } return check(resp) }
go
func (kr *OutgoingKickChatMember) Send() error { resp := &baseResponse{} _, err := kr.api.c.postJSON(kickChatMember, resp, kr) if err != nil { return err } return check(resp) }
[ "func", "(", "kr", "*", "OutgoingKickChatMember", ")", "Send", "(", ")", "error", "{", "resp", ":=", "&", "baseResponse", "{", "}", "\n", "_", ",", "err", ":=", "kr", ".", "api", ".", "c", ".", "postJSON", "(", "kickChatMember", ",", "resp", ",", "kr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "check", "(", "resp", ")", "\n", "}" ]
// Send sends the kick request.
[ "Send", "sends", "the", "kick", "request", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/sendable.go#L133-L142
test
mrd0ll4r/tbotapi
sendable.go
Send
func (ub *OutgoingUnbanChatMember) Send() error { resp := &baseResponse{} _, err := ub.api.c.postJSON(unbanChatMember, resp, ub) if err != nil { return err } return check(resp) }
go
func (ub *OutgoingUnbanChatMember) Send() error { resp := &baseResponse{} _, err := ub.api.c.postJSON(unbanChatMember, resp, ub) if err != nil { return err } return check(resp) }
[ "func", "(", "ub", "*", "OutgoingUnbanChatMember", ")", "Send", "(", ")", "error", "{", "resp", ":=", "&", "baseResponse", "{", "}", "\n", "_", ",", "err", ":=", "ub", ".", "api", ".", "c", ".", "postJSON", "(", "unbanChatMember", ",", "resp", ",", "ub", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "check", "(", "resp", ")", "\n", "}" ]
// Send sends the unban request.
[ "Send", "sends", "the", "unban", "request", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/sendable.go#L145-L154
test
mrd0ll4r/tbotapi
sendable.go
Send
func (cbr *OutgoingCallbackQueryResponse) Send() error { resp := &baseResponse{} _, err := cbr.api.c.postJSON(answerCallbackQuery, resp, cbr) if err != nil { return err } return check(resp) }
go
func (cbr *OutgoingCallbackQueryResponse) Send() error { resp := &baseResponse{} _, err := cbr.api.c.postJSON(answerCallbackQuery, resp, cbr) if err != nil { return err } return check(resp) }
[ "func", "(", "cbr", "*", "OutgoingCallbackQueryResponse", ")", "Send", "(", ")", "error", "{", "resp", ":=", "&", "baseResponse", "{", "}", "\n", "_", ",", "err", ":=", "cbr", ".", "api", ".", "c", ".", "postJSON", "(", "answerCallbackQuery", ",", "resp", ",", "cbr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "check", "(", "resp", ")", "\n", "}" ]
// Send sends the callback response.
[ "Send", "sends", "the", "callback", "response", "." ]
edc257282178bb5cebbfcc41260ec04c1ec7ac19
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/sendable.go#L157-L166
test
grokify/go-scim-client
api_client.go
NewAPIClient
func NewAPIClient(cfg *Configuration) *APIClient { if cfg.HTTPClient == nil { cfg.HTTPClient = http.DefaultClient } c := &APIClient{} c.cfg = cfg c.common.client = c // API Services c.ServiceProviderConfigApi = (*ServiceProviderConfigApiService)(&c.common) c.UserApi = (*UserApiService)(&c.common) return c }
go
func NewAPIClient(cfg *Configuration) *APIClient { if cfg.HTTPClient == nil { cfg.HTTPClient = http.DefaultClient } c := &APIClient{} c.cfg = cfg c.common.client = c // API Services c.ServiceProviderConfigApi = (*ServiceProviderConfigApiService)(&c.common) c.UserApi = (*UserApiService)(&c.common) return c }
[ "func", "NewAPIClient", "(", "cfg", "*", "Configuration", ")", "*", "APIClient", "{", "if", "cfg", ".", "HTTPClient", "==", "nil", "{", "cfg", ".", "HTTPClient", "=", "http", ".", "DefaultClient", "\n", "}", "\n", "c", ":=", "&", "APIClient", "{", "}", "\n", "c", ".", "cfg", "=", "cfg", "\n", "c", ".", "common", ".", "client", "=", "c", "\n", "c", ".", "ServiceProviderConfigApi", "=", "(", "*", "ServiceProviderConfigApiService", ")", "(", "&", "c", ".", "common", ")", "\n", "c", ".", "UserApi", "=", "(", "*", "UserApiService", ")", "(", "&", "c", ".", "common", ")", "\n", "return", "c", "\n", "}" ]
// NewAPIClient creates a new API client. Requires a userAgent string describing your application. // optionally a custom http.Client to allow for advanced features such as caching.
[ "NewAPIClient", "creates", "a", "new", "API", "client", ".", "Requires", "a", "userAgent", "string", "describing", "your", "application", ".", "optionally", "a", "custom", "http", ".", "Client", "to", "allow", "for", "advanced", "features", "such", "as", "caching", "." ]
800878015236174e45b05db1ec125aae20a093e4
https://github.com/grokify/go-scim-client/blob/800878015236174e45b05db1ec125aae20a093e4/api_client.go#L56-L70
test
naoina/genmai
field.go
BeforeInsert
func (ts *TimeStamp) BeforeInsert() error { n := now() ts.CreatedAt = n ts.UpdatedAt = n return nil }
go
func (ts *TimeStamp) BeforeInsert() error { n := now() ts.CreatedAt = n ts.UpdatedAt = n return nil }
[ "func", "(", "ts", "*", "TimeStamp", ")", "BeforeInsert", "(", ")", "error", "{", "n", ":=", "now", "(", ")", "\n", "ts", ".", "CreatedAt", "=", "n", "\n", "ts", ".", "UpdatedAt", "=", "n", "\n", "return", "nil", "\n", "}" ]
// BeforeInsert sets current time to CreatedAt and UpdatedAt field. // It always returns nil.
[ "BeforeInsert", "sets", "current", "time", "to", "CreatedAt", "and", "UpdatedAt", "field", ".", "It", "always", "returns", "nil", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/field.go#L16-L21
test
naoina/genmai
util.go
ColumnName
func ColumnName(d Dialect, tname, cname string) string { if cname != "*" { cname = d.Quote(cname) } if tname == "" { return cname } return fmt.Sprintf("%s.%s", d.Quote(tname), cname) }
go
func ColumnName(d Dialect, tname, cname string) string { if cname != "*" { cname = d.Quote(cname) } if tname == "" { return cname } return fmt.Sprintf("%s.%s", d.Quote(tname), cname) }
[ "func", "ColumnName", "(", "d", "Dialect", ",", "tname", ",", "cname", "string", ")", "string", "{", "if", "cname", "!=", "\"*\"", "{", "cname", "=", "d", ".", "Quote", "(", "cname", ")", "\n", "}", "\n", "if", "tname", "==", "\"\"", "{", "return", "cname", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"%s.%s\"", ",", "d", ".", "Quote", "(", "tname", ")", ",", "cname", ")", "\n", "}" ]
// columnName returns the column name that added the table name with quoted if needed.
[ "columnName", "returns", "the", "column", "name", "that", "added", "the", "table", "name", "with", "quoted", "if", "needed", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/util.go#L22-L30
test
naoina/genmai
genmai.go
New
func New(dialect Dialect, dsn string) (*DB, error) { db, err := sql.Open(dialect.Name(), dsn) if err != nil { return nil, err } return &DB{db: db, dialect: dialect, logger: defaultLogger}, nil }
go
func New(dialect Dialect, dsn string) (*DB, error) { db, err := sql.Open(dialect.Name(), dsn) if err != nil { return nil, err } return &DB{db: db, dialect: dialect, logger: defaultLogger}, nil }
[ "func", "New", "(", "dialect", "Dialect", ",", "dsn", "string", ")", "(", "*", "DB", ",", "error", ")", "{", "db", ",", "err", ":=", "sql", ".", "Open", "(", "dialect", ".", "Name", "(", ")", ",", "dsn", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "DB", "{", "db", ":", "db", ",", "dialect", ":", "dialect", ",", "logger", ":", "defaultLogger", "}", ",", "nil", "\n", "}" ]
// New returns a new DB. // If any error occurs, it returns nil and error.
[ "New", "returns", "a", "new", "DB", ".", "If", "any", "error", "occurs", "it", "returns", "nil", "and", "error", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L36-L42
test
naoina/genmai
genmai.go
From
func (db *DB) From(arg interface{}) *From { t := reflect.Indirect(reflect.ValueOf(arg)).Type() if t.Kind() != reflect.Struct { panic(fmt.Errorf("From: argument must be struct (or that pointer) type, got %v", t)) } return &From{TableName: db.tableName(t)} }
go
func (db *DB) From(arg interface{}) *From { t := reflect.Indirect(reflect.ValueOf(arg)).Type() if t.Kind() != reflect.Struct { panic(fmt.Errorf("From: argument must be struct (or that pointer) type, got %v", t)) } return &From{TableName: db.tableName(t)} }
[ "func", "(", "db", "*", "DB", ")", "From", "(", "arg", "interface", "{", "}", ")", "*", "From", "{", "t", ":=", "reflect", ".", "Indirect", "(", "reflect", ".", "ValueOf", "(", "arg", ")", ")", ".", "Type", "(", ")", "\n", "if", "t", ".", "Kind", "(", ")", "!=", "reflect", ".", "Struct", "{", "panic", "(", "fmt", ".", "Errorf", "(", "\"From: argument must be struct (or that pointer) type, got %v\"", ",", "t", ")", ")", "\n", "}", "\n", "return", "&", "From", "{", "TableName", ":", "db", ".", "tableName", "(", "t", ")", "}", "\n", "}" ]
// From returns a "FROM" statement. // A table name will be determined from name of struct of arg. // If arg argument is not struct type, it panics.
[ "From", "returns", "a", "FROM", "statement", ".", "A", "table", "name", "will", "be", "determined", "from", "name", "of", "struct", "of", "arg", ".", "If", "arg", "argument", "is", "not", "struct", "type", "it", "panics", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L128-L134
test
naoina/genmai
genmai.go
Where
func (db *DB) Where(cond interface{}, args ...interface{}) *Condition { return newCondition(db).Where(cond, args...) }
go
func (db *DB) Where(cond interface{}, args ...interface{}) *Condition { return newCondition(db).Where(cond, args...) }
[ "func", "(", "db", "*", "DB", ")", "Where", "(", "cond", "interface", "{", "}", ",", "args", "...", "interface", "{", "}", ")", "*", "Condition", "{", "return", "newCondition", "(", "db", ")", ".", "Where", "(", "cond", ",", "args", "...", ")", "\n", "}" ]
// Where returns a new Condition of "WHERE" clause.
[ "Where", "returns", "a", "new", "Condition", "of", "WHERE", "clause", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L137-L139
test
naoina/genmai
genmai.go
OrderBy
func (db *DB) OrderBy(table interface{}, column interface{}, order ...interface{}) *Condition { return newCondition(db).OrderBy(table, column, order...) }
go
func (db *DB) OrderBy(table interface{}, column interface{}, order ...interface{}) *Condition { return newCondition(db).OrderBy(table, column, order...) }
[ "func", "(", "db", "*", "DB", ")", "OrderBy", "(", "table", "interface", "{", "}", ",", "column", "interface", "{", "}", ",", "order", "...", "interface", "{", "}", ")", "*", "Condition", "{", "return", "newCondition", "(", "db", ")", ".", "OrderBy", "(", "table", ",", "column", ",", "order", "...", ")", "\n", "}" ]
// OrderBy returns a new Condition of "ORDER BY" clause.
[ "OrderBy", "returns", "a", "new", "Condition", "of", "ORDER", "BY", "clause", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L142-L144
test
naoina/genmai
genmai.go
Limit
func (db *DB) Limit(lim int) *Condition { return newCondition(db).Limit(lim) }
go
func (db *DB) Limit(lim int) *Condition { return newCondition(db).Limit(lim) }
[ "func", "(", "db", "*", "DB", ")", "Limit", "(", "lim", "int", ")", "*", "Condition", "{", "return", "newCondition", "(", "db", ")", ".", "Limit", "(", "lim", ")", "\n", "}" ]
// Limit returns a new Condition of "LIMIT" clause.
[ "Limit", "returns", "a", "new", "Condition", "of", "LIMIT", "clause", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L147-L149
test
naoina/genmai
genmai.go
Offset
func (db *DB) Offset(offset int) *Condition { return newCondition(db).Offset(offset) }
go
func (db *DB) Offset(offset int) *Condition { return newCondition(db).Offset(offset) }
[ "func", "(", "db", "*", "DB", ")", "Offset", "(", "offset", "int", ")", "*", "Condition", "{", "return", "newCondition", "(", "db", ")", ".", "Offset", "(", "offset", ")", "\n", "}" ]
// Offset returns a new Condition of "OFFSET" clause.
[ "Offset", "returns", "a", "new", "Condition", "of", "OFFSET", "clause", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L152-L154
test