id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
143,500
shkh/lastfm-go
lastfm/user.go
GetTopAlbums
func (api userApi) GetTopAlbums(args map[string]interface{}) (result UserGetTopAlbums, err error) { defer func() { appendCaller(err, "lastfm.User.GetTopAlbums") }() err = callGet("user.gettopalbums", api.params, args, &result, P{ "plain": []string{"user", "period", "limit", "page"}, }) return }
go
func (api userApi) GetTopAlbums(args map[string]interface{}) (result UserGetTopAlbums, err error) { defer func() { appendCaller(err, "lastfm.User.GetTopAlbums") }() err = callGet("user.gettopalbums", api.params, args, &result, P{ "plain": []string{"user", "period", "limit", "page"}, }) return }
[ "func", "(", "api", "userApi", ")", "GetTopAlbums", "(", "args", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "result", "UserGetTopAlbums", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "appendCaller", "(", "err", ",", ...
//user.getTopAlbums
[ "user", ".", "getTopAlbums" ]
29483feae85788de18215fcfdf60ff6deeff19e4
https://github.com/shkh/lastfm-go/blob/29483feae85788de18215fcfdf60ff6deeff19e4/lastfm/user.go#L66-L72
143,501
shkh/lastfm-go
lastfm/user.go
GetTopArtists
func (api userApi) GetTopArtists(args map[string]interface{}) (result UserGetTopArtists, err error) { defer func() { appendCaller(err, "lastfm.User.GetTopArtists") }() err = callGet("user.gettopartists", api.params, args, &result, P{ "plain": []string{"user", "period", "limit", "page"}, }) return }
go
func (api userApi) GetTopArtists(args map[string]interface{}) (result UserGetTopArtists, err error) { defer func() { appendCaller(err, "lastfm.User.GetTopArtists") }() err = callGet("user.gettopartists", api.params, args, &result, P{ "plain": []string{"user", "period", "limit", "page"}, }) return }
[ "func", "(", "api", "userApi", ")", "GetTopArtists", "(", "args", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "result", "UserGetTopArtists", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "appendCaller", "(", "err", ",",...
//user.getTopArtists
[ "user", ".", "getTopArtists" ]
29483feae85788de18215fcfdf60ff6deeff19e4
https://github.com/shkh/lastfm-go/blob/29483feae85788de18215fcfdf60ff6deeff19e4/lastfm/user.go#L75-L81
143,502
shkh/lastfm-go
lastfm/user.go
GetTopTags
func (api userApi) GetTopTags(args map[string]interface{}) (result UserGetTopTags, err error) { defer func() { appendCaller(err, "lastfm.User.GetTopTags") }() err = callGet("user.gettoptags", api.params, args, &result, P{ "plain": []string{"user", "limit"}, }) return }
go
func (api userApi) GetTopTags(args map[string]interface{}) (result UserGetTopTags, err error) { defer func() { appendCaller(err, "lastfm.User.GetTopTags") }() err = callGet("user.gettoptags", api.params, args, &result, P{ "plain": []string{"user", "limit"}, }) return }
[ "func", "(", "api", "userApi", ")", "GetTopTags", "(", "args", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "result", "UserGetTopTags", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "appendCaller", "(", "err", ",", "\"...
//user.getTopTags
[ "user", ".", "getTopTags" ]
29483feae85788de18215fcfdf60ff6deeff19e4
https://github.com/shkh/lastfm-go/blob/29483feae85788de18215fcfdf60ff6deeff19e4/lastfm/user.go#L84-L90
143,503
shkh/lastfm-go
lastfm/user.go
GetTopTracks
func (api userApi) GetTopTracks(args map[string]interface{}) (result UserGetTopTracks, err error) { defer func() { appendCaller(err, "lastfm.User.GetTopTracks") }() err = callGet("user.gettoptracks", api.params, args, &result, P{ "plain": []string{"user", "period", "limit", "page"}, }) return }
go
func (api userApi) GetTopTracks(args map[string]interface{}) (result UserGetTopTracks, err error) { defer func() { appendCaller(err, "lastfm.User.GetTopTracks") }() err = callGet("user.gettoptracks", api.params, args, &result, P{ "plain": []string{"user", "period", "limit", "page"}, }) return }
[ "func", "(", "api", "userApi", ")", "GetTopTracks", "(", "args", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "result", "UserGetTopTracks", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "appendCaller", "(", "err", ",", ...
//user.getTopTracks
[ "user", ".", "getTopTracks" ]
29483feae85788de18215fcfdf60ff6deeff19e4
https://github.com/shkh/lastfm-go/blob/29483feae85788de18215fcfdf60ff6deeff19e4/lastfm/user.go#L93-L99
143,504
shkh/lastfm-go
lastfm/user.go
GetWeeklyAlbumChart
func (api userApi) GetWeeklyAlbumChart(args map[string]interface{}) (result UserGetWeeklyAlbumChart, err error) { defer func() { appendCaller(err, "lastfm.User.GetWeeklyAlbumChart") }() err = callGet("user.getweeklyalbumchart", api.params, args, &result, P{ "plain": []string{"user", "from", "to"}, }) return }
go
func (api userApi) GetWeeklyAlbumChart(args map[string]interface{}) (result UserGetWeeklyAlbumChart, err error) { defer func() { appendCaller(err, "lastfm.User.GetWeeklyAlbumChart") }() err = callGet("user.getweeklyalbumchart", api.params, args, &result, P{ "plain": []string{"user", "from", "to"}, }) return }
[ "func", "(", "api", "userApi", ")", "GetWeeklyAlbumChart", "(", "args", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "result", "UserGetWeeklyAlbumChart", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "appendCaller", "(", "...
//user.getWeeklyAlbumChart
[ "user", ".", "getWeeklyAlbumChart" ]
29483feae85788de18215fcfdf60ff6deeff19e4
https://github.com/shkh/lastfm-go/blob/29483feae85788de18215fcfdf60ff6deeff19e4/lastfm/user.go#L102-L108
143,505
shkh/lastfm-go
lastfm/user.go
GetWeeklyArtistChart
func (api userApi) GetWeeklyArtistChart(args map[string]interface{}) (result UserGetWeeklyArtistChart, err error) { defer func() { appendCaller(err, "lastfm.User.GetWeeklyArtistChart") }() err = callGet("user.getweeklyartistchart", api.params, args, &result, P{ "plain": []string{"user", "from", "to"}, }) return }
go
func (api userApi) GetWeeklyArtistChart(args map[string]interface{}) (result UserGetWeeklyArtistChart, err error) { defer func() { appendCaller(err, "lastfm.User.GetWeeklyArtistChart") }() err = callGet("user.getweeklyartistchart", api.params, args, &result, P{ "plain": []string{"user", "from", "to"}, }) return }
[ "func", "(", "api", "userApi", ")", "GetWeeklyArtistChart", "(", "args", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "result", "UserGetWeeklyArtistChart", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "appendCaller", "(", ...
//user.getWeeklyArtistChart
[ "user", ".", "getWeeklyArtistChart" ]
29483feae85788de18215fcfdf60ff6deeff19e4
https://github.com/shkh/lastfm-go/blob/29483feae85788de18215fcfdf60ff6deeff19e4/lastfm/user.go#L111-L117
143,506
shkh/lastfm-go
lastfm/user.go
GetWeeklyChartList
func (api userApi) GetWeeklyChartList(args map[string]interface{}) (result UserGetWeeklyChartList, err error) { defer func() { appendCaller(err, "lastfm.User.GetWeeklyChartList") }() err = callGet("user.getweeklychartlist", api.params, args, &result, P{ "plain": []string{"user"}, }) return }
go
func (api userApi) GetWeeklyChartList(args map[string]interface{}) (result UserGetWeeklyChartList, err error) { defer func() { appendCaller(err, "lastfm.User.GetWeeklyChartList") }() err = callGet("user.getweeklychartlist", api.params, args, &result, P{ "plain": []string{"user"}, }) return }
[ "func", "(", "api", "userApi", ")", "GetWeeklyChartList", "(", "args", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "result", "UserGetWeeklyChartList", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "appendCaller", "(", "er...
//user.getWeeklyChartList
[ "user", ".", "getWeeklyChartList" ]
29483feae85788de18215fcfdf60ff6deeff19e4
https://github.com/shkh/lastfm-go/blob/29483feae85788de18215fcfdf60ff6deeff19e4/lastfm/user.go#L120-L126
143,507
shkh/lastfm-go
lastfm/user.go
GetWeeklyTrackChart
func (api userApi) GetWeeklyTrackChart(args map[string]interface{}) (result UserGetWeeklyTrackChart, err error) { defer func() { appendCaller(err, "lastfm.User.GetWeeklyTrackChart") }() err = callGet("user.getweeklytrackchart", api.params, args, &result, P{ "plain": []string{"user", "from", "to"}, }) return }
go
func (api userApi) GetWeeklyTrackChart(args map[string]interface{}) (result UserGetWeeklyTrackChart, err error) { defer func() { appendCaller(err, "lastfm.User.GetWeeklyTrackChart") }() err = callGet("user.getweeklytrackchart", api.params, args, &result, P{ "plain": []string{"user", "from", "to"}, }) return }
[ "func", "(", "api", "userApi", ")", "GetWeeklyTrackChart", "(", "args", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "result", "UserGetWeeklyTrackChart", ",", "err", "error", ")", "{", "defer", "func", "(", ")", "{", "appendCaller", "(", "...
//user.getWeeklyTrackChart
[ "user", ".", "getWeeklyTrackChart" ]
29483feae85788de18215fcfdf60ff6deeff19e4
https://github.com/shkh/lastfm-go/blob/29483feae85788de18215fcfdf60ff6deeff19e4/lastfm/user.go#L129-L135
143,508
getlantern/hex
hex.go
EncodeToString
func (e *Encoding) EncodeToString(src []byte) string { dst := make([]byte, EncodedLen(len(src))) e.Encode(dst, src) return string(dst) }
go
func (e *Encoding) EncodeToString(src []byte) string { dst := make([]byte, EncodedLen(len(src))) e.Encode(dst, src) return string(dst) }
[ "func", "(", "e", "*", "Encoding", ")", "EncodeToString", "(", "src", "[", "]", "byte", ")", "string", "{", "dst", ":=", "make", "(", "[", "]", "byte", ",", "EncodedLen", "(", "len", "(", "src", ")", ")", ")", "\n", "e", ".", "Encode", "(", "ds...
// EncodeToString returns the hexadecimal encoding of src.
[ "EncodeToString", "returns", "the", "hexadecimal", "encoding", "of", "src", "." ]
c6586a6fe0b7c95eef767657ab1031cbcfc7af66
https://github.com/getlantern/hex/blob/c6586a6fe0b7c95eef767657ab1031cbcfc7af66/hex.go#L95-L99
143,509
libp2p/go-testutil
identity.go
NewIdentity
func NewIdentity(ID peer.ID, addr ma.Multiaddr, privk ci.PrivKey, pubk ci.PubKey) Identity { return &identity{PeerNetParams{ID: ID, Addr: addr, PrivKey: privk, PubKey: pubk}} }
go
func NewIdentity(ID peer.ID, addr ma.Multiaddr, privk ci.PrivKey, pubk ci.PubKey) Identity { return &identity{PeerNetParams{ID: ID, Addr: addr, PrivKey: privk, PubKey: pubk}} }
[ "func", "NewIdentity", "(", "ID", "peer", ".", "ID", ",", "addr", "ma", ".", "Multiaddr", ",", "privk", "ci", ".", "PrivKey", ",", "pubk", "ci", ".", "PubKey", ")", "Identity", "{", "return", "&", "identity", "{", "PeerNetParams", "{", "ID", ":", "ID...
// NewIdentity constructs a new identity object with specific parameters
[ "NewIdentity", "constructs", "a", "new", "identity", "object", "with", "specific", "parameters" ]
4762826eb01904e5e464d3e810cd405174d42e1e
https://github.com/libp2p/go-testutil/blob/4762826eb01904e5e464d3e810cd405174d42e1e/identity.go#L58-L60
143,510
nuveo/log
log.go
AddAdapter
func AddAdapter(name string, adapter AdapterPod) { lock.Lock() adapters[name] = adapter lock.Unlock() }
go
func AddAdapter(name string, adapter AdapterPod) { lock.Lock() adapters[name] = adapter lock.Unlock() }
[ "func", "AddAdapter", "(", "name", "string", ",", "adapter", "AdapterPod", ")", "{", "lock", ".", "Lock", "(", ")", "\n", "adapters", "[", "name", "]", "=", "adapter", "\n", "lock", ".", "Unlock", "(", ")", "\n", "}" ]
// AddAdapter allows to add an adapter and parameters
[ "AddAdapter", "allows", "to", "add", "an", "adapter", "and", "parameters" ]
44d02db6bdf8b1482f48e36274ad087a15a86c07
https://github.com/nuveo/log/blob/44d02db6bdf8b1482f48e36274ad087a15a86c07/log.go#L90-L94
143,511
nuveo/log
log.go
RemoveAdapter
func RemoveAdapter(name string) { lock.Lock() delete(adapters, name) lock.Unlock() }
go
func RemoveAdapter(name string) { lock.Lock() delete(adapters, name) lock.Unlock() }
[ "func", "RemoveAdapter", "(", "name", "string", ")", "{", "lock", ".", "Lock", "(", ")", "\n", "delete", "(", "adapters", ",", "name", ")", "\n", "lock", ".", "Unlock", "(", ")", "\n", "}" ]
// RemoveAdapter remove the adapter from list
[ "RemoveAdapter", "remove", "the", "adapter", "from", "list" ]
44d02db6bdf8b1482f48e36274ad087a15a86c07
https://github.com/nuveo/log/blob/44d02db6bdf8b1482f48e36274ad087a15a86c07/log.go#L97-L101
143,512
nuveo/log
log.go
SetAdapterConfig
func SetAdapterConfig(name string, config map[string]interface{}) { lock.Lock() a := adapters[name] a.Config = config adapters[name] = a lock.Unlock() }
go
func SetAdapterConfig(name string, config map[string]interface{}) { lock.Lock() a := adapters[name] a.Config = config adapters[name] = a lock.Unlock() }
[ "func", "SetAdapterConfig", "(", "name", "string", ",", "config", "map", "[", "string", "]", "interface", "{", "}", ")", "{", "lock", ".", "Lock", "(", ")", "\n", "a", ":=", "adapters", "[", "name", "]", "\n", "a", ".", "Config", "=", "config", "\n...
// SetAdapterConfig allows set new adapter parameters
[ "SetAdapterConfig", "allows", "set", "new", "adapter", "parameters" ]
44d02db6bdf8b1482f48e36274ad087a15a86c07
https://github.com/nuveo/log/blob/44d02db6bdf8b1482f48e36274ad087a15a86c07/log.go#L104-L110
143,513
nuveo/log
log.go
HTTPError
func HTTPError(w http.ResponseWriter, code int) { msg := http.StatusText(code) Errorln(msg) m := make(map[string]string) m["status"] = "error" m["error"] = msg b, _ := json.MarshalIndent(m, "", "\t") http.Error(w, string(b), code) }
go
func HTTPError(w http.ResponseWriter, code int) { msg := http.StatusText(code) Errorln(msg) m := make(map[string]string) m["status"] = "error" m["error"] = msg b, _ := json.MarshalIndent(m, "", "\t") http.Error(w, string(b), code) }
[ "func", "HTTPError", "(", "w", "http", ".", "ResponseWriter", ",", "code", "int", ")", "{", "msg", ":=", "http", ".", "StatusText", "(", "code", ")", "\n", "Errorln", "(", "msg", ")", "\n", "m", ":=", "make", "(", "map", "[", "string", "]", "string...
// HTTPError write lot to stdout and return json error on http.ResponseWriter with http error code.
[ "HTTPError", "write", "lot", "to", "stdout", "and", "return", "json", "error", "on", "http", ".", "ResponseWriter", "with", "http", "error", "code", "." ]
44d02db6bdf8b1482f48e36274ad087a15a86c07
https://github.com/nuveo/log/blob/44d02db6bdf8b1482f48e36274ad087a15a86c07/log.go#L121-L129
143,514
nuveo/log
log.go
DefaultAdapter
func DefaultAdapter(m MsgType, o OutType, config map[string]interface{}, msg ...interface{}) { if m == DebugLog && !DebugMode { return } var debugInfo, lineBreak, output string if DebugMode { _, fn, line, _ := runtime.Caller(5) fn = filepath.Base(fn) debugInfo = fmt.Sprintf("%s:%d ", fn, line) } if o =...
go
func DefaultAdapter(m MsgType, o OutType, config map[string]interface{}, msg ...interface{}) { if m == DebugLog && !DebugMode { return } var debugInfo, lineBreak, output string if DebugMode { _, fn, line, _ := runtime.Caller(5) fn = filepath.Base(fn) debugInfo = fmt.Sprintf("%s:%d ", fn, line) } if o =...
[ "func", "DefaultAdapter", "(", "m", "MsgType", ",", "o", "OutType", ",", "config", "map", "[", "string", "]", "interface", "{", "}", ",", "msg", "...", "interface", "{", "}", ")", "{", "if", "m", "==", "DebugLog", "&&", "!", "DebugMode", "{", "return...
// DefaultAdapter of log package
[ "DefaultAdapter", "of", "log", "package" ]
44d02db6bdf8b1482f48e36274ad087a15a86c07
https://github.com/nuveo/log/blob/44d02db6bdf8b1482f48e36274ad087a15a86c07/log.go#L180-L220
143,515
hacdias/fileutils
dir.go
Mkdir
func (d Dir) Mkdir(name string, perm os.FileMode) error { if name = d.resolve(name); name == "" { return os.ErrNotExist } return os.MkdirAll(name, perm) }
go
func (d Dir) Mkdir(name string, perm os.FileMode) error { if name = d.resolve(name); name == "" { return os.ErrNotExist } return os.MkdirAll(name, perm) }
[ "func", "(", "d", "Dir", ")", "Mkdir", "(", "name", "string", ",", "perm", "os", ".", "FileMode", ")", "error", "{", "if", "name", "=", "d", ".", "resolve", "(", "name", ")", ";", "name", "==", "\"", "\"", "{", "return", "os", ".", "ErrNotExist",...
// Mkdir implements os.Mkdir in this directory context.
[ "Mkdir", "implements", "os", ".", "Mkdir", "in", "this", "directory", "context", "." ]
227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9
https://github.com/hacdias/fileutils/blob/227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9/dir.go#L34-L39
143,516
hacdias/fileutils
dir.go
OpenFile
func (d Dir) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) { if name = d.resolve(name); name == "" { return nil, os.ErrNotExist } f, err := os.OpenFile(name, flag, perm) if err != nil { return nil, err } return f, nil }
go
func (d Dir) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) { if name = d.resolve(name); name == "" { return nil, os.ErrNotExist } f, err := os.OpenFile(name, flag, perm) if err != nil { return nil, err } return f, nil }
[ "func", "(", "d", "Dir", ")", "OpenFile", "(", "name", "string", ",", "flag", "int", ",", "perm", "os", ".", "FileMode", ")", "(", "*", "os", ".", "File", ",", "error", ")", "{", "if", "name", "=", "d", ".", "resolve", "(", "name", ")", ";", ...
// OpenFile implements os.OpenFile in this directory context.
[ "OpenFile", "implements", "os", ".", "OpenFile", "in", "this", "directory", "context", "." ]
227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9
https://github.com/hacdias/fileutils/blob/227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9/dir.go#L42-L51
143,517
hacdias/fileutils
dir.go
RemoveAll
func (d Dir) RemoveAll(name string) error { if name = d.resolve(name); name == "" { return os.ErrNotExist } if name == filepath.Clean(string(d)) { // Prohibit removing the virtual root directory. return os.ErrInvalid } return os.RemoveAll(name) }
go
func (d Dir) RemoveAll(name string) error { if name = d.resolve(name); name == "" { return os.ErrNotExist } if name == filepath.Clean(string(d)) { // Prohibit removing the virtual root directory. return os.ErrInvalid } return os.RemoveAll(name) }
[ "func", "(", "d", "Dir", ")", "RemoveAll", "(", "name", "string", ")", "error", "{", "if", "name", "=", "d", ".", "resolve", "(", "name", ")", ";", "name", "==", "\"", "\"", "{", "return", "os", ".", "ErrNotExist", "\n", "}", "\n\n", "if", "name"...
// RemoveAll implements os.RemoveAll in this directory context.
[ "RemoveAll", "implements", "os", ".", "RemoveAll", "in", "this", "directory", "context", "." ]
227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9
https://github.com/hacdias/fileutils/blob/227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9/dir.go#L54-L64
143,518
hacdias/fileutils
dir.go
Rename
func (d Dir) Rename(oldName, newName string) error { if oldName = d.resolve(oldName); oldName == "" { return os.ErrNotExist } if newName = d.resolve(newName); newName == "" { return os.ErrNotExist } if root := filepath.Clean(string(d)); root == oldName || root == newName { // Prohibit renaming from or to the...
go
func (d Dir) Rename(oldName, newName string) error { if oldName = d.resolve(oldName); oldName == "" { return os.ErrNotExist } if newName = d.resolve(newName); newName == "" { return os.ErrNotExist } if root := filepath.Clean(string(d)); root == oldName || root == newName { // Prohibit renaming from or to the...
[ "func", "(", "d", "Dir", ")", "Rename", "(", "oldName", ",", "newName", "string", ")", "error", "{", "if", "oldName", "=", "d", ".", "resolve", "(", "oldName", ")", ";", "oldName", "==", "\"", "\"", "{", "return", "os", ".", "ErrNotExist", "\n", "}...
// Rename implements os.Rename in this directory context.
[ "Rename", "implements", "os", ".", "Rename", "in", "this", "directory", "context", "." ]
227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9
https://github.com/hacdias/fileutils/blob/227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9/dir.go#L67-L79
143,519
hacdias/fileutils
dir.go
Stat
func (d Dir) Stat(name string) (os.FileInfo, error) { if name = d.resolve(name); name == "" { return nil, os.ErrNotExist } return os.Stat(name) }
go
func (d Dir) Stat(name string) (os.FileInfo, error) { if name = d.resolve(name); name == "" { return nil, os.ErrNotExist } return os.Stat(name) }
[ "func", "(", "d", "Dir", ")", "Stat", "(", "name", "string", ")", "(", "os", ".", "FileInfo", ",", "error", ")", "{", "if", "name", "=", "d", ".", "resolve", "(", "name", ")", ";", "name", "==", "\"", "\"", "{", "return", "nil", ",", "os", "....
// Stat implements os.Stat in this directory context.
[ "Stat", "implements", "os", ".", "Stat", "in", "this", "directory", "context", "." ]
227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9
https://github.com/hacdias/fileutils/blob/227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9/dir.go#L82-L88
143,520
hacdias/fileutils
dir.go
Copy
func (d Dir) Copy(src, dst string) error { if src = d.resolve(src); src == "" { return os.ErrNotExist } if dst = d.resolve(dst); dst == "" { return os.ErrNotExist } if root := filepath.Clean(string(d)); root == src || root == dst { // Prohibit copying from or to the virtual root directory. return os.ErrI...
go
func (d Dir) Copy(src, dst string) error { if src = d.resolve(src); src == "" { return os.ErrNotExist } if dst = d.resolve(dst); dst == "" { return os.ErrNotExist } if root := filepath.Clean(string(d)); root == src || root == dst { // Prohibit copying from or to the virtual root directory. return os.ErrI...
[ "func", "(", "d", "Dir", ")", "Copy", "(", "src", ",", "dst", "string", ")", "error", "{", "if", "src", "=", "d", ".", "resolve", "(", "src", ")", ";", "src", "==", "\"", "\"", "{", "return", "os", ".", "ErrNotExist", "\n", "}", "\n\n", "if", ...
// Copy copies a file or directory from src to dst. If it is // a directory, all of the files and sub-directories will be copied.
[ "Copy", "copies", "a", "file", "or", "directory", "from", "src", "to", "dst", ".", "If", "it", "is", "a", "directory", "all", "of", "the", "files", "and", "sub", "-", "directories", "will", "be", "copied", "." ]
227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9
https://github.com/hacdias/fileutils/blob/227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9/dir.go#L92-L120
143,521
hacdias/fileutils
copy.go
CopyFile
func CopyFile(source string, dest string) error { // Open the source file. src, err := os.Open(source) if err != nil { return err } defer src.Close() // Makes the directory needed to create the dst // file. err = os.MkdirAll(filepath.Dir(dest), 0666) if err != nil { return err } // Create the destinati...
go
func CopyFile(source string, dest string) error { // Open the source file. src, err := os.Open(source) if err != nil { return err } defer src.Close() // Makes the directory needed to create the dst // file. err = os.MkdirAll(filepath.Dir(dest), 0666) if err != nil { return err } // Create the destinati...
[ "func", "CopyFile", "(", "source", "string", ",", "dest", "string", ")", "error", "{", "// Open the source file.", "src", ",", "err", ":=", "os", ".", "Open", "(", "source", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", ...
// CopyFile copies a file from source to dest and returns // an error if any.
[ "CopyFile", "copies", "a", "file", "from", "source", "to", "dest", "and", "returns", "an", "error", "if", "any", "." ]
227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9
https://github.com/hacdias/fileutils/blob/227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9/copy.go#L12-L51
143,522
hacdias/fileutils
copy.go
CopyDir
func CopyDir(source string, dest string) error { // Get properties of source. srcinfo, err := os.Stat(source) if err != nil { return err } // Create the destination directory. err = os.MkdirAll(dest, srcinfo.Mode()) if err != nil { return err } dir, _ := os.Open(source) obs, err := dir.Readdir(-1) if e...
go
func CopyDir(source string, dest string) error { // Get properties of source. srcinfo, err := os.Stat(source) if err != nil { return err } // Create the destination directory. err = os.MkdirAll(dest, srcinfo.Mode()) if err != nil { return err } dir, _ := os.Open(source) obs, err := dir.Readdir(-1) if e...
[ "func", "CopyDir", "(", "source", "string", ",", "dest", "string", ")", "error", "{", "// Get properties of source.", "srcinfo", ",", "err", ":=", "os", ".", "Stat", "(", "source", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "...
// CopyDir copies a directory from source to dest and all // of its sub-directories. It doesn't stop if it finds an error // during the copy. Returns an error if any.
[ "CopyDir", "copies", "a", "directory", "from", "source", "to", "dest", "and", "all", "of", "its", "sub", "-", "directories", ".", "It", "doesn", "t", "stop", "if", "it", "finds", "an", "error", "during", "the", "copy", ".", "Returns", "an", "error", "i...
227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9
https://github.com/hacdias/fileutils/blob/227b317161a192ce96a9ebbc1c3af6bcdd9b9ed9/copy.go#L56-L106
143,523
tv42/base58
base58.go
DecodeToBig
func DecodeToBig(src []byte) (*big.Int, error) { n := new(big.Int) radix := big.NewInt(58) for i := 0; i < len(src); i++ { b := decodeMap[src[i]] if b == 0xFF { return nil, CorruptInputError(i) } n.Mul(n, radix) n.Add(n, big.NewInt(int64(b))) } return n, nil }
go
func DecodeToBig(src []byte) (*big.Int, error) { n := new(big.Int) radix := big.NewInt(58) for i := 0; i < len(src); i++ { b := decodeMap[src[i]] if b == 0xFF { return nil, CorruptInputError(i) } n.Mul(n, radix) n.Add(n, big.NewInt(int64(b))) } return n, nil }
[ "func", "DecodeToBig", "(", "src", "[", "]", "byte", ")", "(", "*", "big", ".", "Int", ",", "error", ")", "{", "n", ":=", "new", "(", "big", ".", "Int", ")", "\n", "radix", ":=", "big", ".", "NewInt", "(", "58", ")", "\n", "for", "i", ":=", ...
// Decode a big integer from the bytes. Returns an error on corrupt // input.
[ "Decode", "a", "big", "integer", "from", "the", "bytes", ".", "Returns", "an", "error", "on", "corrupt", "input", "." ]
b6649477bfe6276322b4eeaae8f5e947b49cec92
https://github.com/tv42/base58/blob/b6649477bfe6276322b4eeaae8f5e947b49cec92/base58.go#L34-L46
143,524
tv42/base58
base58.go
EncodeBig
func EncodeBig(dst []byte, src *big.Int) []byte { start := len(dst) n := new(big.Int) n.Set(src) radix := big.NewInt(58) zero := big.NewInt(0) for n.Cmp(zero) > 0 { mod := new(big.Int) n.DivMod(n, radix, mod) dst = append(dst, alphabet[mod.Int64()]) } for i, j := start, len(dst)-1; i < j; i, j = i+1, j-...
go
func EncodeBig(dst []byte, src *big.Int) []byte { start := len(dst) n := new(big.Int) n.Set(src) radix := big.NewInt(58) zero := big.NewInt(0) for n.Cmp(zero) > 0 { mod := new(big.Int) n.DivMod(n, radix, mod) dst = append(dst, alphabet[mod.Int64()]) } for i, j := start, len(dst)-1; i < j; i, j = i+1, j-...
[ "func", "EncodeBig", "(", "dst", "[", "]", "byte", ",", "src", "*", "big", ".", "Int", ")", "[", "]", "byte", "{", "start", ":=", "len", "(", "dst", ")", "\n", "n", ":=", "new", "(", "big", ".", "Int", ")", "\n", "n", ".", "Set", "(", "src"...
// Encode encodes src, appending to dst. Be sure to use the returned // new value of dst.
[ "Encode", "encodes", "src", "appending", "to", "dst", ".", "Be", "sure", "to", "use", "the", "returned", "new", "value", "of", "dst", "." ]
b6649477bfe6276322b4eeaae8f5e947b49cec92
https://github.com/tv42/base58/blob/b6649477bfe6276322b4eeaae8f5e947b49cec92/base58.go#L50-L67
143,525
decker502/dnspod-go
dnspod.go
NewClient
func NewClient(CommonParams CommonParams) *Client { var _timeout, _keepalive int _timeout = timeout _keepalive = keepAlive if CommonParams.Timeout != 0 { _timeout = CommonParams.Timeout } if CommonParams.KeepAlive != 0 { _keepalive = CommonParams.KeepAlive } cli := http.Client{ Transport: &http.Transpor...
go
func NewClient(CommonParams CommonParams) *Client { var _timeout, _keepalive int _timeout = timeout _keepalive = keepAlive if CommonParams.Timeout != 0 { _timeout = CommonParams.Timeout } if CommonParams.KeepAlive != 0 { _keepalive = CommonParams.KeepAlive } cli := http.Client{ Transport: &http.Transpor...
[ "func", "NewClient", "(", "CommonParams", "CommonParams", ")", "*", "Client", "{", "var", "_timeout", ",", "_keepalive", "int", "\n", "_timeout", "=", "timeout", "\n", "_keepalive", "=", "keepAlive", "\n\n", "if", "CommonParams", ".", "Timeout", "!=", "0", "...
// NewClient returns a new dnspod API client.
[ "NewClient", "returns", "a", "new", "dnspod", "API", "client", "." ]
71fbbdbdf1a7eeac949586de15bf96d416d3dd63
https://github.com/decker502/dnspod-go/blob/71fbbdbdf1a7eeac949586de15bf96d416d3dd63/dnspod.go#L88-L113
143,526
decker502/dnspod-go
dnspod.go
UnmarshalJSON
func (d *Date) UnmarshalJSON(data []byte) error { var s string if err := json.Unmarshal(data, &s); err != nil { return fmt.Errorf("date should be a string, got %s", data) } t, err := time.Parse("2006-01-02", s) if err != nil { return fmt.Errorf("invalid date: %v", err) } d.Time = t return nil }
go
func (d *Date) UnmarshalJSON(data []byte) error { var s string if err := json.Unmarshal(data, &s); err != nil { return fmt.Errorf("date should be a string, got %s", data) } t, err := time.Parse("2006-01-02", s) if err != nil { return fmt.Errorf("invalid date: %v", err) } d.Time = t return nil }
[ "func", "(", "d", "*", "Date", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "s", "string", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "s", ")", ";", "err", "!=", "nil", "{", "retu...
// UnmarshalJSON handles the deserialization of the custom Date type.
[ "UnmarshalJSON", "handles", "the", "deserialization", "of", "the", "custom", "Date", "type", "." ]
71fbbdbdf1a7eeac949586de15bf96d416d3dd63
https://github.com/decker502/dnspod-go/blob/71fbbdbdf1a7eeac949586de15bf96d416d3dd63/dnspod.go#L222-L233
143,527
blakesmith/ar
reader.go
NewReader
func NewReader(r io.Reader) *Reader { io.CopyN(ioutil.Discard, r, 8) // Discard global header return &Reader{r: r} }
go
func NewReader(r io.Reader) *Reader { io.CopyN(ioutil.Discard, r, 8) // Discard global header return &Reader{r: r} }
[ "func", "NewReader", "(", "r", "io", ".", "Reader", ")", "*", "Reader", "{", "io", ".", "CopyN", "(", "ioutil", ".", "Discard", ",", "r", ",", "8", ")", "// Discard global header", "\n\n", "return", "&", "Reader", "{", "r", ":", "r", "}", "\n", "}"...
// Copies read data to r. Strips the global ar header.
[ "Copies", "read", "data", "to", "r", ".", "Strips", "the", "global", "ar", "header", "." ]
809d4375e1fb5bb262c159fc3ec2e7a86a8bfd28
https://github.com/blakesmith/ar/blob/809d4375e1fb5bb262c159fc3ec2e7a86a8bfd28/reader.go#L56-L60
143,528
blakesmith/ar
reader.go
Read
func (rd *Reader) Read(b []byte) (n int, err error) { if rd.nb == 0 { return 0, io.EOF } if int64(len(b)) > rd.nb { b = b[0:rd.nb] } n, err = rd.r.Read(b) rd.nb -= int64(n) return }
go
func (rd *Reader) Read(b []byte) (n int, err error) { if rd.nb == 0 { return 0, io.EOF } if int64(len(b)) > rd.nb { b = b[0:rd.nb] } n, err = rd.r.Read(b) rd.nb -= int64(n) return }
[ "func", "(", "rd", "*", "Reader", ")", "Read", "(", "b", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "if", "rd", ".", "nb", "==", "0", "{", "return", "0", ",", "io", ".", "EOF", "\n", "}", "\n", "if", "int64", "...
// Read data from the current entry in the archive.
[ "Read", "data", "from", "the", "current", "entry", "in", "the", "archive", "." ]
809d4375e1fb5bb262c159fc3ec2e7a86a8bfd28
https://github.com/blakesmith/ar/blob/809d4375e1fb5bb262c159fc3ec2e7a86a8bfd28/reader.go#L144-L155
143,529
blakesmith/ar
writer.go
Write
func (aw *Writer) Write(b []byte) (n int, err error) { if int64(len(b)) > aw.nb { b = b[0:aw.nb] err = ErrWriteTooLong } n, werr := aw.w.Write(b) aw.nb -= int64(n) if werr != nil { return n, werr } if len(b)%2 == 1 { // data size must be aligned to an even byte n2, _ := aw.w.Write([]byte{'\n'}) return...
go
func (aw *Writer) Write(b []byte) (n int, err error) { if int64(len(b)) > aw.nb { b = b[0:aw.nb] err = ErrWriteTooLong } n, werr := aw.w.Write(b) aw.nb -= int64(n) if werr != nil { return n, werr } if len(b)%2 == 1 { // data size must be aligned to an even byte n2, _ := aw.w.Write([]byte{'\n'}) return...
[ "func", "(", "aw", "*", "Writer", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "if", "int64", "(", "len", "(", "b", ")", ")", ">", "aw", ".", "nb", "{", "b", "=", "b", "[", "0", ":", "aw...
// Writes to the current entry in the ar archive // Returns ErrWriteTooLong if more than header.Size // bytes are written after a call to WriteHeader
[ "Writes", "to", "the", "current", "entry", "in", "the", "ar", "archive", "Returns", "ErrWriteTooLong", "if", "more", "than", "header", ".", "Size", "bytes", "are", "written", "after", "a", "call", "to", "WriteHeader" ]
809d4375e1fb5bb262c159fc3ec2e7a86a8bfd28
https://github.com/blakesmith/ar/blob/809d4375e1fb5bb262c159fc3ec2e7a86a8bfd28/writer.go#L82-L99
143,530
blakesmith/ar
writer.go
WriteHeader
func (aw *Writer) WriteHeader(hdr *Header) error { aw.nb = int64(hdr.Size) header := make([]byte, HEADER_BYTE_SIZE) s := slicer(header) aw.string(s.next(16), hdr.Name) aw.numeric(s.next(12), hdr.ModTime.Unix()) aw.numeric(s.next(6), int64(hdr.Uid)) aw.numeric(s.next(6), int64(hdr.Gid)) aw.octal(s.next(8), hdr....
go
func (aw *Writer) WriteHeader(hdr *Header) error { aw.nb = int64(hdr.Size) header := make([]byte, HEADER_BYTE_SIZE) s := slicer(header) aw.string(s.next(16), hdr.Name) aw.numeric(s.next(12), hdr.ModTime.Unix()) aw.numeric(s.next(6), int64(hdr.Uid)) aw.numeric(s.next(6), int64(hdr.Gid)) aw.octal(s.next(8), hdr....
[ "func", "(", "aw", "*", "Writer", ")", "WriteHeader", "(", "hdr", "*", "Header", ")", "error", "{", "aw", ".", "nb", "=", "int64", "(", "hdr", ".", "Size", ")", "\n", "header", ":=", "make", "(", "[", "]", "byte", ",", "HEADER_BYTE_SIZE", ")", "\...
// Writes the header to the underlying writer and prepares // to receive the file payload
[ "Writes", "the", "header", "to", "the", "underlying", "writer", "and", "prepares", "to", "receive", "the", "file", "payload" ]
809d4375e1fb5bb262c159fc3ec2e7a86a8bfd28
https://github.com/blakesmith/ar/blob/809d4375e1fb5bb262c159fc3ec2e7a86a8bfd28/writer.go#L108-L124
143,531
daaku/go.zipexe
zipexe.go
Open
func Open(path string) (*zip.Reader, error) { _, rd, err := OpenCloser(path) return rd, err }
go
func Open(path string) (*zip.Reader, error) { _, rd, err := OpenCloser(path) return rd, err }
[ "func", "Open", "(", "path", "string", ")", "(", "*", "zip", ".", "Reader", ",", "error", ")", "{", "_", ",", "rd", ",", "err", ":=", "OpenCloser", "(", "path", ")", "\n", "return", "rd", ",", "err", "\n", "}" ]
// Opens a zip file by path.
[ "Opens", "a", "zip", "file", "by", "path", "." ]
db7cf2ba330f8c2d28b827826e33d6628ea7e9e0
https://github.com/daaku/go.zipexe/blob/db7cf2ba330f8c2d28b827826e33d6628ea7e9e0/zipexe.go#L15-L18
143,532
daaku/go.zipexe
zipexe.go
OpenCloser
func OpenCloser(path string) (io.Closer, *zip.Reader, error) { file, err := os.Open(path) if err != nil { return nil, nil, err } finfo, err := file.Stat() if err != nil { return nil, nil, err } zr, err := NewReader(file, finfo.Size()) if err != nil { return nil, nil, err } return file, zr, nil }
go
func OpenCloser(path string) (io.Closer, *zip.Reader, error) { file, err := os.Open(path) if err != nil { return nil, nil, err } finfo, err := file.Stat() if err != nil { return nil, nil, err } zr, err := NewReader(file, finfo.Size()) if err != nil { return nil, nil, err } return file, zr, nil }
[ "func", "OpenCloser", "(", "path", "string", ")", "(", "io", ".", "Closer", ",", "*", "zip", ".", "Reader", ",", "error", ")", "{", "file", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "n...
// OpenCloser is like Open but returns an additional Closer to avoid leaking open files.
[ "OpenCloser", "is", "like", "Open", "but", "returns", "an", "additional", "Closer", "to", "avoid", "leaking", "open", "files", "." ]
db7cf2ba330f8c2d28b827826e33d6628ea7e9e0
https://github.com/daaku/go.zipexe/blob/db7cf2ba330f8c2d28b827826e33d6628ea7e9e0/zipexe.go#L21-L35
143,533
daaku/go.zipexe
zipexe.go
NewReader
func NewReader(rda io.ReaderAt, size int64) (*zip.Reader, error) { handlers := []func(io.ReaderAt, int64) (*zip.Reader, error){ zip.NewReader, zipExeReaderMacho, zipExeReaderElf, zipExeReaderPe, } for _, handler := range handlers { zfile, err := handler(rda, size) if err == nil { return zfile, nil ...
go
func NewReader(rda io.ReaderAt, size int64) (*zip.Reader, error) { handlers := []func(io.ReaderAt, int64) (*zip.Reader, error){ zip.NewReader, zipExeReaderMacho, zipExeReaderElf, zipExeReaderPe, } for _, handler := range handlers { zfile, err := handler(rda, size) if err == nil { return zfile, nil ...
[ "func", "NewReader", "(", "rda", "io", ".", "ReaderAt", ",", "size", "int64", ")", "(", "*", "zip", ".", "Reader", ",", "error", ")", "{", "handlers", ":=", "[", "]", "func", "(", "io", ".", "ReaderAt", ",", "int64", ")", "(", "*", "zip", ".", ...
// Open a zip file, specially handling various binaries that may have been // augmented with zip data.
[ "Open", "a", "zip", "file", "specially", "handling", "various", "binaries", "that", "may", "have", "been", "augmented", "with", "zip", "data", "." ]
db7cf2ba330f8c2d28b827826e33d6628ea7e9e0
https://github.com/daaku/go.zipexe/blob/db7cf2ba330f8c2d28b827826e33d6628ea7e9e0/zipexe.go#L39-L54
143,534
stvp/tempredis
tempredis.go
Start
func Start(config Config) (server *Server, err error) { if config == nil { config = Config{} } dir, err := ioutil.TempDir(os.TempDir(), "tempredis") if err != nil { return nil, err } if _, ok := config["unixsocket"]; !ok { config["unixsocket"] = fmt.Sprintf("%s/%s", dir, "redis.sock") } if _, ok := conf...
go
func Start(config Config) (server *Server, err error) { if config == nil { config = Config{} } dir, err := ioutil.TempDir(os.TempDir(), "tempredis") if err != nil { return nil, err } if _, ok := config["unixsocket"]; !ok { config["unixsocket"] = fmt.Sprintf("%s/%s", dir, "redis.sock") } if _, ok := conf...
[ "func", "Start", "(", "config", "Config", ")", "(", "server", "*", "Server", ",", "err", "error", ")", "{", "if", "config", "==", "nil", "{", "config", "=", "Config", "{", "}", "\n", "}", "\n\n", "dir", ",", "err", ":=", "ioutil", ".", "TempDir", ...
// Start initiates a new redis-server process configured with the given // configuration. redis-server will listen on a temporary local Unix socket. An // error is returned if redis-server is unable to successfully start for any // reason.
[ "Start", "initiates", "a", "new", "redis", "-", "server", "process", "configured", "with", "the", "given", "configuration", ".", "redis", "-", "server", "will", "listen", "on", "a", "temporary", "local", "Unix", "socket", ".", "An", "error", "is", "returned"...
b82af84802032e1f0c8a153dd5bfc440b4d25ab6
https://github.com/stvp/tempredis/blob/b82af84802032e1f0c8a153dd5bfc440b4d25ab6/tempredis.go#L36-L66
143,535
stvp/tempredis
tempredis.go
waitFor
func (s *Server) waitFor(search string) (err error) { var line string scanner := bufio.NewScanner(s.stdout) for scanner.Scan() { line = scanner.Text() fmt.Fprintf(&s.stdoutBuf, "%s\n", line) if strings.Contains(line, search) { return nil } } err = scanner.Err() if err == nil { err = io.EOF } retur...
go
func (s *Server) waitFor(search string) (err error) { var line string scanner := bufio.NewScanner(s.stdout) for scanner.Scan() { line = scanner.Text() fmt.Fprintf(&s.stdoutBuf, "%s\n", line) if strings.Contains(line, search) { return nil } } err = scanner.Err() if err == nil { err = io.EOF } retur...
[ "func", "(", "s", "*", "Server", ")", "waitFor", "(", "search", "string", ")", "(", "err", "error", ")", "{", "var", "line", "string", "\n\n", "scanner", ":=", "bufio", ".", "NewScanner", "(", "s", ".", "stdout", ")", "\n", "for", "scanner", ".", "...
// waitFor blocks until redis-server prints the given string to stdout.
[ "waitFor", "blocks", "until", "redis", "-", "server", "prints", "the", "given", "string", "to", "stdout", "." ]
b82af84802032e1f0c8a153dd5bfc440b4d25ab6
https://github.com/stvp/tempredis/blob/b82af84802032e1f0c8a153dd5bfc440b4d25ab6/tempredis.go#L101-L117
143,536
stvp/tempredis
tempredis.go
Stdout
func (s *Server) Stdout() string { io.Copy(&s.stdoutBuf, s.stdout) return s.stdoutBuf.String() }
go
func (s *Server) Stdout() string { io.Copy(&s.stdoutBuf, s.stdout) return s.stdoutBuf.String() }
[ "func", "(", "s", "*", "Server", ")", "Stdout", "(", ")", "string", "{", "io", ".", "Copy", "(", "&", "s", ".", "stdoutBuf", ",", "s", ".", "stdout", ")", "\n", "return", "s", ".", "stdoutBuf", ".", "String", "(", ")", "\n", "}" ]
// Stdout blocks until redis-server returns and then returns the full stdout // output.
[ "Stdout", "blocks", "until", "redis", "-", "server", "returns", "and", "then", "returns", "the", "full", "stdout", "output", "." ]
b82af84802032e1f0c8a153dd5bfc440b4d25ab6
https://github.com/stvp/tempredis/blob/b82af84802032e1f0c8a153dd5bfc440b4d25ab6/tempredis.go#L126-L129
143,537
stvp/tempredis
tempredis.go
Stderr
func (s *Server) Stderr() string { bytes, _ := ioutil.ReadAll(s.stderr) return string(bytes) }
go
func (s *Server) Stderr() string { bytes, _ := ioutil.ReadAll(s.stderr) return string(bytes) }
[ "func", "(", "s", "*", "Server", ")", "Stderr", "(", ")", "string", "{", "bytes", ",", "_", ":=", "ioutil", ".", "ReadAll", "(", "s", ".", "stderr", ")", "\n", "return", "string", "(", "bytes", ")", "\n", "}" ]
// Stderr blocks until redis-server returns and then returns the full stdout // output.
[ "Stderr", "blocks", "until", "redis", "-", "server", "returns", "and", "then", "returns", "the", "full", "stdout", "output", "." ]
b82af84802032e1f0c8a153dd5bfc440b4d25ab6
https://github.com/stvp/tempredis/blob/b82af84802032e1f0c8a153dd5bfc440b4d25ab6/tempredis.go#L133-L136
143,538
Bowery/prompt
buffer.go
NewBuffer
func NewBuffer(prompt string, out *os.File, echo bool) *Buffer { return &Buffer{ Out: out, Prompt: prompt, Echo: echo, } }
go
func NewBuffer(prompt string, out *os.File, echo bool) *Buffer { return &Buffer{ Out: out, Prompt: prompt, Echo: echo, } }
[ "func", "NewBuffer", "(", "prompt", "string", ",", "out", "*", "os", ".", "File", ",", "echo", "bool", ")", "*", "Buffer", "{", "return", "&", "Buffer", "{", "Out", ":", "out", ",", "Prompt", ":", "prompt", ",", "Echo", ":", "echo", ",", "}", "\n...
// NewBuffer creates a buffer writing to out if echo is true.
[ "NewBuffer", "creates", "a", "buffer", "writing", "to", "out", "if", "echo", "is", "true", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/buffer.go#L22-L28
143,539
Bowery/prompt
buffer.go
Insert
func (buf *Buffer) Insert(rs ...rune) error { rsLen := len(rs) total := buf.size + rsLen if total > len(buf.data) { buf.data = append(buf.data, make([]rune, rsLen)...) } // Shift characters to make room in the correct pos. if buf.size != buf.pos { copy(buf.data[buf.pos+rsLen:buf.size+rsLen], buf.data[buf.po...
go
func (buf *Buffer) Insert(rs ...rune) error { rsLen := len(rs) total := buf.size + rsLen if total > len(buf.data) { buf.data = append(buf.data, make([]rune, rsLen)...) } // Shift characters to make room in the correct pos. if buf.size != buf.pos { copy(buf.data[buf.pos+rsLen:buf.size+rsLen], buf.data[buf.po...
[ "func", "(", "buf", "*", "Buffer", ")", "Insert", "(", "rs", "...", "rune", ")", "error", "{", "rsLen", ":=", "len", "(", "rs", ")", "\n", "total", ":=", "buf", ".", "size", "+", "rsLen", "\n\n", "if", "total", ">", "len", "(", "buf", ".", "dat...
// Insert inserts characters at the cursors position.
[ "Insert", "inserts", "characters", "at", "the", "cursors", "position", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/buffer.go#L36-L56
143,540
Bowery/prompt
buffer.go
Set
func (buf *Buffer) Set(rs ...rune) error { rsLen := len(rs) buf.data = rs buf.pos = rsLen buf.size = rsLen return buf.Refresh() }
go
func (buf *Buffer) Set(rs ...rune) error { rsLen := len(rs) buf.data = rs buf.pos = rsLen buf.size = rsLen return buf.Refresh() }
[ "func", "(", "buf", "*", "Buffer", ")", "Set", "(", "rs", "...", "rune", ")", "error", "{", "rsLen", ":=", "len", "(", "rs", ")", "\n", "buf", ".", "data", "=", "rs", "\n", "buf", ".", "pos", "=", "rsLen", "\n", "buf", ".", "size", "=", "rsLe...
// Set sets the content in the buffer.
[ "Set", "sets", "the", "content", "in", "the", "buffer", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/buffer.go#L59-L66
143,541
Bowery/prompt
buffer.go
Start
func (buf *Buffer) Start() error { if buf.pos <= 0 { return nil } buf.pos = 0 return buf.Refresh() }
go
func (buf *Buffer) Start() error { if buf.pos <= 0 { return nil } buf.pos = 0 return buf.Refresh() }
[ "func", "(", "buf", "*", "Buffer", ")", "Start", "(", ")", "error", "{", "if", "buf", ".", "pos", "<=", "0", "{", "return", "nil", "\n", "}", "\n\n", "buf", ".", "pos", "=", "0", "\n", "return", "buf", ".", "Refresh", "(", ")", "\n", "}" ]
// Start moves the cursor to the start.
[ "Start", "moves", "the", "cursor", "to", "the", "start", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/buffer.go#L69-L76
143,542
Bowery/prompt
buffer.go
End
func (buf *Buffer) End() error { if buf.pos >= buf.size { return nil } buf.pos = buf.size return buf.Refresh() }
go
func (buf *Buffer) End() error { if buf.pos >= buf.size { return nil } buf.pos = buf.size return buf.Refresh() }
[ "func", "(", "buf", "*", "Buffer", ")", "End", "(", ")", "error", "{", "if", "buf", ".", "pos", ">=", "buf", ".", "size", "{", "return", "nil", "\n", "}", "\n\n", "buf", ".", "pos", "=", "buf", ".", "size", "\n", "return", "buf", ".", "Refresh"...
// End moves the cursor to the end.
[ "End", "moves", "the", "cursor", "to", "the", "end", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/buffer.go#L79-L86
143,543
Bowery/prompt
buffer.go
Left
func (buf *Buffer) Left() error { if buf.pos <= 0 { return nil } buf.pos-- return buf.Refresh() }
go
func (buf *Buffer) Left() error { if buf.pos <= 0 { return nil } buf.pos-- return buf.Refresh() }
[ "func", "(", "buf", "*", "Buffer", ")", "Left", "(", ")", "error", "{", "if", "buf", ".", "pos", "<=", "0", "{", "return", "nil", "\n", "}", "\n\n", "buf", ".", "pos", "--", "\n", "return", "buf", ".", "Refresh", "(", ")", "\n", "}" ]
// Left moves the cursor one character left.
[ "Left", "moves", "the", "cursor", "one", "character", "left", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/buffer.go#L89-L96
143,544
Bowery/prompt
buffer.go
Right
func (buf *Buffer) Right() error { if buf.pos >= buf.size { return nil } buf.pos++ return buf.Refresh() }
go
func (buf *Buffer) Right() error { if buf.pos >= buf.size { return nil } buf.pos++ return buf.Refresh() }
[ "func", "(", "buf", "*", "Buffer", ")", "Right", "(", ")", "error", "{", "if", "buf", ".", "pos", ">=", "buf", ".", "size", "{", "return", "nil", "\n", "}", "\n\n", "buf", ".", "pos", "++", "\n", "return", "buf", ".", "Refresh", "(", ")", "\n",...
// Right moves the cursor one character right.
[ "Right", "moves", "the", "cursor", "one", "character", "right", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/buffer.go#L99-L106
143,545
Bowery/prompt
buffer.go
Del
func (buf *Buffer) Del() error { if buf.pos >= buf.size { return nil } // Shift characters after position back one. copy(buf.data[buf.pos:], buf.data[buf.pos+1:buf.size]) buf.size-- return buf.Refresh() }
go
func (buf *Buffer) Del() error { if buf.pos >= buf.size { return nil } // Shift characters after position back one. copy(buf.data[buf.pos:], buf.data[buf.pos+1:buf.size]) buf.size-- return buf.Refresh() }
[ "func", "(", "buf", "*", "Buffer", ")", "Del", "(", ")", "error", "{", "if", "buf", ".", "pos", ">=", "buf", ".", "size", "{", "return", "nil", "\n", "}", "\n\n", "// Shift characters after position back one.", "copy", "(", "buf", ".", "data", "[", "bu...
// Del removes the character at the cursor position.
[ "Del", "removes", "the", "character", "at", "the", "cursor", "position", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/buffer.go#L109-L119
143,546
Bowery/prompt
buffer.go
EndLine
func (buf *Buffer) EndLine() error { _, err := buf.Out.Write(crlf) return err }
go
func (buf *Buffer) EndLine() error { _, err := buf.Out.Write(crlf) return err }
[ "func", "(", "buf", "*", "Buffer", ")", "EndLine", "(", ")", "error", "{", "_", ",", "err", ":=", "buf", ".", "Out", ".", "Write", "(", "crlf", ")", "\n", "return", "err", "\n", "}" ]
// EndLine ends the line with CRLF.
[ "EndLine", "ends", "the", "line", "with", "CRLF", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/buffer.go#L136-L139
143,547
Bowery/prompt
buffer.go
toBytes
func toBytes(runes []rune) []byte { var bytes []byte char := make([]byte, utf8.UTFMax) for _, r := range runes { n := utf8.EncodeRune(char, r) bytes = append(bytes, char[:n]...) } return bytes }
go
func toBytes(runes []rune) []byte { var bytes []byte char := make([]byte, utf8.UTFMax) for _, r := range runes { n := utf8.EncodeRune(char, r) bytes = append(bytes, char[:n]...) } return bytes }
[ "func", "toBytes", "(", "runes", "[", "]", "rune", ")", "[", "]", "byte", "{", "var", "bytes", "[", "]", "byte", "\n", "char", ":=", "make", "(", "[", "]", "byte", ",", "utf8", ".", "UTFMax", ")", "\n\n", "for", "_", ",", "r", ":=", "range", ...
// toBytes converts a slice of runes to its equivalent in bytes.
[ "toBytes", "converts", "a", "slice", "of", "runes", "to", "its", "equivalent", "in", "bytes", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/buffer.go#L142-L152
143,548
Bowery/prompt
term_unix.go
supportsEditing
func supportsEditing() bool { term := os.Getenv("TERM") for _, t := range unsupported { if t == term { return false } } return true }
go
func supportsEditing() bool { term := os.Getenv("TERM") for _, t := range unsupported { if t == term { return false } } return true }
[ "func", "supportsEditing", "(", ")", "bool", "{", "term", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n\n", "for", "_", ",", "t", ":=", "range", "unsupported", "{", "if", "t", "==", "term", "{", "return", "false", "\n", "}", "\n", "}", "\n...
// supportsEditing checks if the terminal supports ansi escapes.
[ "supportsEditing", "checks", "if", "the", "terminal", "supports", "ansi", "escapes", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/term_unix.go#L17-L27
143,549
Bowery/prompt
prompt.go
Basic
func Basic(prefix string, required bool) (string, error) { term, err := NewTerminal() if err != nil { return "", err } defer term.Close() return term.Basic(prefix, required) }
go
func Basic(prefix string, required bool) (string, error) { term, err := NewTerminal() if err != nil { return "", err } defer term.Close() return term.Basic(prefix, required) }
[ "func", "Basic", "(", "prefix", "string", ",", "required", "bool", ")", "(", "string", ",", "error", ")", "{", "term", ",", "err", ":=", "NewTerminal", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\...
// Basic is a wrapper around Terminal.Basic.
[ "Basic", "is", "a", "wrapper", "around", "Terminal", ".", "Basic", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/prompt.go#L33-L41
143,550
Bowery/prompt
prompt.go
BasicDefault
func BasicDefault(prefix, def string) (string, error) { term, err := NewTerminal() if err != nil { return "", err } defer term.Close() return term.BasicDefault(prefix, def) }
go
func BasicDefault(prefix, def string) (string, error) { term, err := NewTerminal() if err != nil { return "", err } defer term.Close() return term.BasicDefault(prefix, def) }
[ "func", "BasicDefault", "(", "prefix", ",", "def", "string", ")", "(", "string", ",", "error", ")", "{", "term", ",", "err", ":=", "NewTerminal", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "d...
// BasicDefault is a wrapper around Terminal.BasicDefault.
[ "BasicDefault", "is", "a", "wrapper", "around", "Terminal", ".", "BasicDefault", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/prompt.go#L44-L52
143,551
Bowery/prompt
prompt.go
Ask
func Ask(question string) (bool, error) { term, err := NewTerminal() if err != nil { return false, err } defer term.Close() return term.Ask(question) }
go
func Ask(question string) (bool, error) { term, err := NewTerminal() if err != nil { return false, err } defer term.Close() return term.Ask(question) }
[ "func", "Ask", "(", "question", "string", ")", "(", "bool", ",", "error", ")", "{", "term", ",", "err", ":=", "NewTerminal", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "defer", "term", ".", "Clo...
// Ask is a wrapper around Terminal.Ask.
[ "Ask", "is", "a", "wrapper", "around", "Terminal", ".", "Ask", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/prompt.go#L55-L63
143,552
Bowery/prompt
prompt.go
Custom
func Custom(prefix string, test func(string) (string, bool)) (string, error) { term, err := NewTerminal() if err != nil { return "", err } defer term.Close() return term.Custom(prefix, test) }
go
func Custom(prefix string, test func(string) (string, bool)) (string, error) { term, err := NewTerminal() if err != nil { return "", err } defer term.Close() return term.Custom(prefix, test) }
[ "func", "Custom", "(", "prefix", "string", ",", "test", "func", "(", "string", ")", "(", "string", ",", "bool", ")", ")", "(", "string", ",", "error", ")", "{", "term", ",", "err", ":=", "NewTerminal", "(", ")", "\n", "if", "err", "!=", "nil", "{...
// Custom is a wrapper around Terminal.Custom.
[ "Custom", "is", "a", "wrapper", "around", "Terminal", ".", "Custom", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/prompt.go#L66-L74
143,553
Bowery/prompt
prompt.go
Password
func Password(prefix string) (string, error) { term, err := NewTerminal() if err != nil { return "", err } defer term.Close() return term.Password(prefix) }
go
func Password(prefix string) (string, error) { term, err := NewTerminal() if err != nil { return "", err } defer term.Close() return term.Password(prefix) }
[ "func", "Password", "(", "prefix", "string", ")", "(", "string", ",", "error", ")", "{", "term", ",", "err", ":=", "NewTerminal", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "defer", "term", "...
// Password is a wrapper around Terminal.Password.
[ "Password", "is", "a", "wrapper", "around", "Terminal", ".", "Password", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/prompt.go#L77-L85
143,554
Bowery/prompt
ansi_windows.go
shortFunction
func (ar *AnsiReader) shortFunction(ident string, shift, ctrl, alt bool) string { code := "O" if shift { code += "1;2" } else if ctrl { code += "1;5" } else if alt { code += "1;3" } return code + ident }
go
func (ar *AnsiReader) shortFunction(ident string, shift, ctrl, alt bool) string { code := "O" if shift { code += "1;2" } else if ctrl { code += "1;5" } else if alt { code += "1;3" } return code + ident }
[ "func", "(", "ar", "*", "AnsiReader", ")", "shortFunction", "(", "ident", "string", ",", "shift", ",", "ctrl", ",", "alt", "bool", ")", "string", "{", "code", ":=", "\"", "\"", "\n\n", "if", "shift", "{", "code", "+=", "\"", "\"", "\n", "}", "else"...
// shortFunction creates a short function code.
[ "shortFunction", "creates", "a", "short", "function", "code", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/ansi_windows.go#L206-L218
143,555
Bowery/prompt
ansi_windows.go
finish
func (aw *AnsiWriter) finish(parse func([]byte) error) error { var err error if parse != nil { err = parse(aw.buf[2:]) } aw.buf = nil return err }
go
func (aw *AnsiWriter) finish(parse func([]byte) error) error { var err error if parse != nil { err = parse(aw.buf[2:]) } aw.buf = nil return err }
[ "func", "(", "aw", "*", "AnsiWriter", ")", "finish", "(", "parse", "func", "(", "[", "]", "byte", ")", "error", ")", "error", "{", "var", "err", "error", "\n\n", "if", "parse", "!=", "nil", "{", "err", "=", "parse", "(", "aw", ".", "buf", "[", ...
// finish finishes an ANSI escape code and calls the parsing function. Afterwards // the escape buffer is emptied.
[ "finish", "finishes", "an", "ANSI", "escape", "code", "and", "calls", "the", "parsing", "function", ".", "Afterwards", "the", "escape", "buffer", "is", "emptied", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/ansi_windows.go#L501-L510
143,556
Bowery/prompt
buffer_windows.go
mvLeftEdge
func (buf *Buffer) mvLeftEdge(csbi *consoleScreenBufferInfo) error { coords := &coord{y: csbi.cursorPosition.y} ret, _, err := setConsoleCursorPosition.Call(buf.Out.Fd(), uintptr(*(*int32)(unsafe.Pointer(coords)))) if ret == 0 { return err } return nil }
go
func (buf *Buffer) mvLeftEdge(csbi *consoleScreenBufferInfo) error { coords := &coord{y: csbi.cursorPosition.y} ret, _, err := setConsoleCursorPosition.Call(buf.Out.Fd(), uintptr(*(*int32)(unsafe.Pointer(coords)))) if ret == 0 { return err } return nil }
[ "func", "(", "buf", "*", "Buffer", ")", "mvLeftEdge", "(", "csbi", "*", "consoleScreenBufferInfo", ")", "error", "{", "coords", ":=", "&", "coord", "{", "y", ":", "csbi", ".", "cursorPosition", ".", "y", "}", "\n\n", "ret", ",", "_", ",", "err", ":="...
// mvLeftEdge moves the cursor to the beginning of the line the csbi cursor // is positioned on.
[ "mvLeftEdge", "moves", "the", "cursor", "to", "the", "beginning", "of", "the", "line", "the", "csbi", "cursor", "is", "positioned", "on", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/buffer_windows.go#L126-L136
143,557
Bowery/prompt
term_windows.go
isNotTerminal
func isNotTerminal(err error) bool { errno, ok := err.(syscall.Errno) return ok && errno == errnoInvalidHandle }
go
func isNotTerminal(err error) bool { errno, ok := err.(syscall.Errno) return ok && errno == errnoInvalidHandle }
[ "func", "isNotTerminal", "(", "err", "error", ")", "bool", "{", "errno", ",", "ok", ":=", "err", ".", "(", "syscall", ".", "Errno", ")", "\n\n", "return", "ok", "&&", "errno", "==", "errnoInvalidHandle", "\n", "}" ]
// isNotTerminal checks if an error is related to the input not being a terminal.
[ "isNotTerminal", "checks", "if", "an", "error", "is", "related", "to", "the", "input", "not", "being", "a", "terminal", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/term_windows.go#L70-L74
143,558
Bowery/prompt
term.go
NewTerminal
func NewTerminal() (*Terminal, error) { in := os.Stdin term, err := newTerminal(in) if err != nil { return nil, err } return &Terminal{ In: in, Out: os.Stdout, History: make([]string, 0, 10), histIdx: -1, t: term, }, nil }
go
func NewTerminal() (*Terminal, error) { in := os.Stdin term, err := newTerminal(in) if err != nil { return nil, err } return &Terminal{ In: in, Out: os.Stdout, History: make([]string, 0, 10), histIdx: -1, t: term, }, nil }
[ "func", "NewTerminal", "(", ")", "(", "*", "Terminal", ",", "error", ")", "{", "in", ":=", "os", ".", "Stdin", "\n\n", "term", ",", "err", ":=", "newTerminal", "(", "in", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n"...
// NewTerminal creates a terminal and sets it to raw input mode.
[ "NewTerminal", "creates", "a", "terminal", "and", "sets", "it", "to", "raw", "input", "mode", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/term.go#L59-L74
143,559
Bowery/prompt
term.go
Basic
func (term *Terminal) Basic(prefix string, required bool) (string, error) { return term.Custom(prefix, func(input string) (string, bool) { if required && input == "" { return "", false } return input, true }) }
go
func (term *Terminal) Basic(prefix string, required bool) (string, error) { return term.Custom(prefix, func(input string) (string, bool) { if required && input == "" { return "", false } return input, true }) }
[ "func", "(", "term", "*", "Terminal", ")", "Basic", "(", "prefix", "string", ",", "required", "bool", ")", "(", "string", ",", "error", ")", "{", "return", "term", ".", "Custom", "(", "prefix", ",", "func", "(", "input", "string", ")", "(", "string",...
// Basic gets input and if required tests to ensure input was given.
[ "Basic", "gets", "input", "and", "if", "required", "tests", "to", "ensure", "input", "was", "given", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/term.go#L77-L85
143,560
Bowery/prompt
term.go
BasicDefault
func (term *Terminal) BasicDefault(prefix, def string) (string, error) { return term.Custom(prefix+" (Default: "+def+")", func(input string) (string, bool) { if input == "" { input = def } return input, true }) }
go
func (term *Terminal) BasicDefault(prefix, def string) (string, error) { return term.Custom(prefix+" (Default: "+def+")", func(input string) (string, bool) { if input == "" { input = def } return input, true }) }
[ "func", "(", "term", "*", "Terminal", ")", "BasicDefault", "(", "prefix", ",", "def", "string", ")", "(", "string", ",", "error", ")", "{", "return", "term", ".", "Custom", "(", "prefix", "+", "\"", "\"", "+", "def", "+", "\"", "\"", ",", "func", ...
// BasicDefault gets input and if empty uses the given default.
[ "BasicDefault", "gets", "input", "and", "if", "empty", "uses", "the", "given", "default", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/term.go#L88-L96
143,561
Bowery/prompt
term.go
Ask
func (term *Terminal) Ask(question string) (bool, error) { input, err := term.Custom(question+"? (y/n)", func(input string) (string, bool) { if input == "" { return "", false } input = strings.ToLower(input) if input == "y" || input == "yes" { return "yes", true } return "", true }) var ok bool ...
go
func (term *Terminal) Ask(question string) (bool, error) { input, err := term.Custom(question+"? (y/n)", func(input string) (string, bool) { if input == "" { return "", false } input = strings.ToLower(input) if input == "y" || input == "yes" { return "yes", true } return "", true }) var ok bool ...
[ "func", "(", "term", "*", "Terminal", ")", "Ask", "(", "question", "string", ")", "(", "bool", ",", "error", ")", "{", "input", ",", "err", ":=", "term", ".", "Custom", "(", "question", "+", "\"", "\"", ",", "func", "(", "input", "string", ")", "...
// Ask gets input and checks if it's truthy or not, and returns that // in a boolean fashion.
[ "Ask", "gets", "input", "and", "checks", "if", "it", "s", "truthy", "or", "not", "and", "returns", "that", "in", "a", "boolean", "fashion", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/term.go#L100-L120
143,562
Bowery/prompt
term.go
Custom
func (term *Terminal) Custom(prefix string, test func(string) (string, bool)) (string, error) { var err error var input string var ok bool for !ok { input, err = term.GetPrompt(prefix) if err != nil && err != io.EOF { return "", err } input, ok = test(input) } return input, nil }
go
func (term *Terminal) Custom(prefix string, test func(string) (string, bool)) (string, error) { var err error var input string var ok bool for !ok { input, err = term.GetPrompt(prefix) if err != nil && err != io.EOF { return "", err } input, ok = test(input) } return input, nil }
[ "func", "(", "term", "*", "Terminal", ")", "Custom", "(", "prefix", "string", ",", "test", "func", "(", "string", ")", "(", "string", ",", "bool", ")", ")", "(", "string", ",", "error", ")", "{", "var", "err", "error", "\n", "var", "input", "string...
// Custom gets input and calls the given test function with the input to // check if the input is valid, a true return will return the string.
[ "Custom", "gets", "input", "and", "calls", "the", "given", "test", "function", "with", "the", "input", "to", "check", "if", "the", "input", "is", "valid", "a", "true", "return", "will", "return", "the", "string", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/term.go#L124-L139
143,563
Bowery/prompt
term.go
Password
func (term *Terminal) Password(prefix string) (string, error) { var err error var input string for input == "" { input, err = term.GetPassword(prefix) if err != nil && err != io.EOF { return "", err } } return input, nil }
go
func (term *Terminal) Password(prefix string) (string, error) { var err error var input string for input == "" { input, err = term.GetPassword(prefix) if err != nil && err != io.EOF { return "", err } } return input, nil }
[ "func", "(", "term", "*", "Terminal", ")", "Password", "(", "prefix", "string", ")", "(", "string", ",", "error", ")", "{", "var", "err", "error", "\n", "var", "input", "string", "\n\n", "for", "input", "==", "\"", "\"", "{", "input", ",", "err", "...
// Password retrieves a password from stdin without echoing it.
[ "Password", "retrieves", "a", "password", "from", "stdin", "without", "echoing", "it", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/term.go#L142-L154
143,564
Bowery/prompt
term.go
GetPrompt
func (term *Terminal) GetPrompt(prefix string) (string, error) { prefix += " " if !term.t.supportsEditing { return term.simplePrompt(prefix) } buf := NewBuffer(prefix, term.Out, true) return term.prompt(buf, NewAnsiReader(term.In)) }
go
func (term *Terminal) GetPrompt(prefix string) (string, error) { prefix += " " if !term.t.supportsEditing { return term.simplePrompt(prefix) } buf := NewBuffer(prefix, term.Out, true) return term.prompt(buf, NewAnsiReader(term.In)) }
[ "func", "(", "term", "*", "Terminal", ")", "GetPrompt", "(", "prefix", "string", ")", "(", "string", ",", "error", ")", "{", "prefix", "+=", "\"", "\"", "\n\n", "if", "!", "term", ".", "t", ".", "supportsEditing", "{", "return", "term", ".", "simpleP...
// GetPrompt gets a line with the prefix and echos input.
[ "GetPrompt", "gets", "a", "line", "with", "the", "prefix", "and", "echos", "input", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/term.go#L157-L166
143,565
Bowery/prompt
term.go
GetPassword
func (term *Terminal) GetPassword(prefix string) (string, error) { prefix += " " if !term.t.supportsEditing { return term.simplePrompt(prefix) } buf := NewBuffer(prefix, term.Out, false) return term.password(buf, NewAnsiReader(term.In)) }
go
func (term *Terminal) GetPassword(prefix string) (string, error) { prefix += " " if !term.t.supportsEditing { return term.simplePrompt(prefix) } buf := NewBuffer(prefix, term.Out, false) return term.password(buf, NewAnsiReader(term.In)) }
[ "func", "(", "term", "*", "Terminal", ")", "GetPassword", "(", "prefix", "string", ")", "(", "string", ",", "error", ")", "{", "prefix", "+=", "\"", "\"", "\n\n", "if", "!", "term", ".", "t", ".", "supportsEditing", "{", "return", "term", ".", "simpl...
// GetPassword gets a line with the prefix and doesn't echo input.
[ "GetPassword", "gets", "a", "line", "with", "the", "prefix", "and", "doesn", "t", "echo", "input", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/term.go#L169-L178
143,566
Bowery/prompt
term.go
Reopen
func (term *Terminal) Reopen() error { in := os.Stdin t, err := newTerminal(in) if err != nil { return err } term.t = t return nil }
go
func (term *Terminal) Reopen() error { in := os.Stdin t, err := newTerminal(in) if err != nil { return err } term.t = t return nil }
[ "func", "(", "term", "*", "Terminal", ")", "Reopen", "(", ")", "error", "{", "in", ":=", "os", ".", "Stdin", "\n\n", "t", ",", "err", ":=", "newTerminal", "(", "in", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", ...
// Reopen re-opens an internal terminal.
[ "Reopen", "re", "-", "opens", "an", "internal", "terminal", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/term.go#L186-L196
143,567
Bowery/prompt
term.go
simplePrompt
func (term *Terminal) simplePrompt(prefix string) (string, error) { if term.simpleReader == nil { term.simpleReader = bufio.NewReader(term.In) } _, err := term.Out.Write([]byte(prefix)) if err != nil { return "", err } line, err := term.simpleReader.ReadString('\n') line = strings.TrimRight(line, "\r\n ") ...
go
func (term *Terminal) simplePrompt(prefix string) (string, error) { if term.simpleReader == nil { term.simpleReader = bufio.NewReader(term.In) } _, err := term.Out.Write([]byte(prefix)) if err != nil { return "", err } line, err := term.simpleReader.ReadString('\n') line = strings.TrimRight(line, "\r\n ") ...
[ "func", "(", "term", "*", "Terminal", ")", "simplePrompt", "(", "prefix", "string", ")", "(", "string", ",", "error", ")", "{", "if", "term", ".", "simpleReader", "==", "nil", "{", "term", ".", "simpleReader", "=", "bufio", ".", "NewReader", "(", "term...
// simplePrompt is a fallback prompt without line editing support.
[ "simplePrompt", "is", "a", "fallback", "prompt", "without", "line", "editing", "support", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/term.go#L199-L214
143,568
Bowery/prompt
term.go
setup
func (term *Terminal) setup(buf *Buffer, in io.Reader) (*bufio.Reader, error) { cols, _, err := TerminalSize(buf.Out) if err != nil { return nil, err } buf.Cols = cols input := bufio.NewReader(in) err = buf.Refresh() if err != nil { return nil, err } return input, nil }
go
func (term *Terminal) setup(buf *Buffer, in io.Reader) (*bufio.Reader, error) { cols, _, err := TerminalSize(buf.Out) if err != nil { return nil, err } buf.Cols = cols input := bufio.NewReader(in) err = buf.Refresh() if err != nil { return nil, err } return input, nil }
[ "func", "(", "term", "*", "Terminal", ")", "setup", "(", "buf", "*", "Buffer", ",", "in", "io", ".", "Reader", ")", "(", "*", "bufio", ".", "Reader", ",", "error", ")", "{", "cols", ",", "_", ",", "err", ":=", "TerminalSize", "(", "buf", ".", "...
// setup initializes a prompt.
[ "setup", "initializes", "a", "prompt", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/term.go#L217-L232
143,569
Bowery/prompt
term.go
read
func (term *Terminal) read(in *bufio.Reader) (int, rune, error) { char, _, err := in.ReadRune() if err != nil { return 0, 0, err } switch char { default: // Standard chars. return evChar, char, nil case tabKey, ctrlA, ctrlB, ctrlE, ctrlF, ctrlG, ctrlH, ctrlJ, ctrlK, ctrlN, ctrlO, ctrlP, ctrlQ, ctrlR, ctr...
go
func (term *Terminal) read(in *bufio.Reader) (int, rune, error) { char, _, err := in.ReadRune() if err != nil { return 0, 0, err } switch char { default: // Standard chars. return evChar, char, nil case tabKey, ctrlA, ctrlB, ctrlE, ctrlF, ctrlG, ctrlH, ctrlJ, ctrlK, ctrlN, ctrlO, ctrlP, ctrlQ, ctrlR, ctr...
[ "func", "(", "term", "*", "Terminal", ")", "read", "(", "in", "*", "bufio", ".", "Reader", ")", "(", "int", ",", "rune", ",", "error", ")", "{", "char", ",", "_", ",", "err", ":=", "in", ".", "ReadRune", "(", ")", "\n", "if", "err", "!=", "ni...
// read reads a rune and parses ANSI escape sequences found
[ "read", "reads", "a", "rune", "and", "parses", "ANSI", "escape", "sequences", "found" ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/term.go#L235-L327
143,570
Bowery/prompt
term.go
password
func (term *Terminal) password(buf *Buffer, in io.Reader) (string, error) { input, err := term.setup(buf, in) if err != nil { return "", err } for { typ, char, err := term.read(input) if err != nil { return buf.String(), err } switch typ { case evChar: err = buf.Insert(char) if err != nil { ...
go
func (term *Terminal) password(buf *Buffer, in io.Reader) (string, error) { input, err := term.setup(buf, in) if err != nil { return "", err } for { typ, char, err := term.read(input) if err != nil { return buf.String(), err } switch typ { case evChar: err = buf.Insert(char) if err != nil { ...
[ "func", "(", "term", "*", "Terminal", ")", "password", "(", "buf", "*", "Buffer", ",", "in", "io", ".", "Reader", ")", "(", "string", ",", "error", ")", "{", "input", ",", "err", ":=", "term", ".", "setup", "(", "buf", ",", "in", ")", "\n", "if...
// password reads from in and parses restricted ANSI escapes writing to buf.
[ "password", "reads", "from", "in", "and", "parses", "restricted", "ANSI", "escapes", "writing", "to", "buf", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/term.go#L452-L501
143,571
Bowery/prompt
ansi_unix.go
Read
func (ar *AnsiReader) Read(b []byte) (int, error) { return ar.file.Read(b) }
go
func (ar *AnsiReader) Read(b []byte) (int, error) { return ar.file.Read(b) }
[ "func", "(", "ar", "*", "AnsiReader", ")", "Read", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "return", "ar", ".", "file", ".", "Read", "(", "b", ")", "\n", "}" ]
// Read reads data from the input file into b.
[ "Read", "reads", "data", "from", "the", "input", "file", "into", "b", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/ansi_unix.go#L22-L24
143,572
Bowery/prompt
ansi_unix.go
Write
func (aw *AnsiWriter) Write(b []byte) (int, error) { return aw.file.Write(b) }
go
func (aw *AnsiWriter) Write(b []byte) (int, error) { return aw.file.Write(b) }
[ "func", "(", "aw", "*", "AnsiWriter", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "return", "aw", ".", "file", ".", "Write", "(", "b", ")", "\n", "}" ]
// Write writes data from b into the input file.
[ "Write", "writes", "data", "from", "b", "into", "the", "input", "file", "." ]
972d0ceb96f55132a1ba9714cb771ce19b3821ab
https://github.com/Bowery/prompt/blob/972d0ceb96f55132a1ba9714cb771ce19b3821ab/ansi_unix.go#L37-L39
143,573
asticode/go-astitools
ssh/auth.go
AuthMethodPublicKey
func AuthMethodPublicKey(paths ...string) (m ssh.AuthMethod, err error) { // Loop through paths var ss []ssh.Signer for _, p := range paths { // Read private key var b []byte if b, err = ioutil.ReadFile(p); err != nil { err = errors.Wrapf(err, "main: reading private key %s failed", p) return } // Pa...
go
func AuthMethodPublicKey(paths ...string) (m ssh.AuthMethod, err error) { // Loop through paths var ss []ssh.Signer for _, p := range paths { // Read private key var b []byte if b, err = ioutil.ReadFile(p); err != nil { err = errors.Wrapf(err, "main: reading private key %s failed", p) return } // Pa...
[ "func", "AuthMethodPublicKey", "(", "paths", "...", "string", ")", "(", "m", "ssh", ".", "AuthMethod", ",", "err", "error", ")", "{", "// Loop through paths", "var", "ss", "[", "]", "ssh", ".", "Signer", "\n", "for", "_", ",", "p", ":=", "range", "path...
// AuthMethodPublicKey creates a public key auth method
[ "AuthMethodPublicKey", "creates", "a", "public", "key", "auth", "method" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/ssh/auth.go#L11-L36
143,574
asticode/go-astitools
os/copy.go
Copy
func Copy(ctx context.Context, src, dst string) (err error) { // Check context if err = ctx.Err(); err != nil { return } // Stat src var statSrc os.FileInfo if statSrc, err = os.Stat(src); err != nil { err = errors.Wrapf(err, "stating %s failed", src) return } // Check context if err = ctx.Err(); err !...
go
func Copy(ctx context.Context, src, dst string) (err error) { // Check context if err = ctx.Err(); err != nil { return } // Stat src var statSrc os.FileInfo if statSrc, err = os.Stat(src); err != nil { err = errors.Wrapf(err, "stating %s failed", src) return } // Check context if err = ctx.Err(); err !...
[ "func", "Copy", "(", "ctx", "context", ".", "Context", ",", "src", ",", "dst", "string", ")", "(", "err", "error", ")", "{", "// Check context", "if", "err", "=", "ctx", ".", "Err", "(", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n...
// Copy is a cross partitions cancellable copy // If src is a file, dst must be the full path to file once copied // If src is a dir, dst must be the full path to the dir once copied
[ "Copy", "is", "a", "cross", "partitions", "cancellable", "copy", "If", "src", "is", "a", "file", "dst", "must", "be", "the", "full", "path", "to", "file", "once", "copied", "If", "src", "is", "a", "dir", "dst", "must", "be", "the", "full", "path", "t...
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/os/copy.go#L16-L106
143,575
asticode/go-astitools
worker/executer.go
Exec
func (w *Worker) Exec(name string, args ...string) (ExecHandler, error) { // Create handler h := &defaultExecHandler{} h.ctx, h.cancel = context.WithCancel(context.Background()) // Start cmd := exec.CommandContext(h.ctx, name, args...) n := strings.Join(append([]string{name}, args...), " ") astilog.Infof("astiw...
go
func (w *Worker) Exec(name string, args ...string) (ExecHandler, error) { // Create handler h := &defaultExecHandler{} h.ctx, h.cancel = context.WithCancel(context.Background()) // Start cmd := exec.CommandContext(h.ctx, name, args...) n := strings.Join(append([]string{name}, args...), " ") astilog.Infof("astiw...
[ "func", "(", "w", "*", "Worker", ")", "Exec", "(", "name", "string", ",", "args", "...", "string", ")", "(", "ExecHandler", ",", "error", ")", "{", "// Create handler", "h", ":=", "&", "defaultExecHandler", "{", "}", "\n", "h", ".", "ctx", ",", "h", ...
// Exec executes a cmd // The process will be stopped when the worker stops
[ "Exec", "executes", "a", "cmd", "The", "process", "will", "be", "stopped", "when", "the", "worker", "stops" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/worker/executer.go#L53-L78
143,576
asticode/go-astitools
exec/cmd.go
NewCmd
func NewCmd(ctx context.Context, args ...string) (cmd *Cmd) { cmd = &Cmd{ Args: args, ctx: ctx, } return }
go
func NewCmd(ctx context.Context, args ...string) (cmd *Cmd) { cmd = &Cmd{ Args: args, ctx: ctx, } return }
[ "func", "NewCmd", "(", "ctx", "context", ".", "Context", ",", "args", "...", "string", ")", "(", "cmd", "*", "Cmd", ")", "{", "cmd", "=", "&", "Cmd", "{", "Args", ":", "args", ",", "ctx", ":", "ctx", ",", "}", "\n", "return", "\n", "}" ]
// NewCmd creates a new command
[ "NewCmd", "creates", "a", "new", "command" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/exec/cmd.go#L19-L25
143,577
asticode/go-astitools
unicode/reader.go
NewReader
func NewReader(i io.Reader) (o io.Reader, err error) { // Create reader r := bufio.NewReader(i) // Read first 4 bytes var b []byte if b, err = r.Peek(4); err != nil { err = errors.Wrap(err, "astiunicode: reading first 4 bytes failed") return } // Create transformer if bytes.HasPrefix(b, bomHeaderUTF32BE) ...
go
func NewReader(i io.Reader) (o io.Reader, err error) { // Create reader r := bufio.NewReader(i) // Read first 4 bytes var b []byte if b, err = r.Peek(4); err != nil { err = errors.Wrap(err, "astiunicode: reading first 4 bytes failed") return } // Create transformer if bytes.HasPrefix(b, bomHeaderUTF32BE) ...
[ "func", "NewReader", "(", "i", "io", ".", "Reader", ")", "(", "o", "io", ".", "Reader", ",", "err", "error", ")", "{", "// Create reader", "r", ":=", "bufio", ".", "NewReader", "(", "i", ")", "\n\n", "// Read first 4 bytes", "var", "b", "[", "]", "by...
// NewReader creates a new unicode reader
[ "NewReader", "creates", "a", "new", "unicode", "reader" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/unicode/reader.go#L23-L48
143,578
asticode/go-astitools
string/length.go
ToLength
func ToLength(i, rpl string, length int) string { if len(i) == length { return i } else if len(i) > length { return i[:length] } else { for idx := 0; idx <= length-len(i); idx++ { i += rpl } return i } }
go
func ToLength(i, rpl string, length int) string { if len(i) == length { return i } else if len(i) > length { return i[:length] } else { for idx := 0; idx <= length-len(i); idx++ { i += rpl } return i } }
[ "func", "ToLength", "(", "i", ",", "rpl", "string", ",", "length", "int", ")", "string", "{", "if", "len", "(", "i", ")", "==", "length", "{", "return", "i", "\n", "}", "else", "if", "len", "(", "i", ")", ">", "length", "{", "return", "i", "[",...
// ToLength forces the length of a string
[ "ToLength", "forces", "the", "length", "of", "a", "string" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/string/length.go#L4-L15
143,579
asticode/go-astitools
image/color.go
NewRGBA
func NewRGBA(a, b, g, r uint8) *RGBA { return &RGBA{RGBA: color.RGBA{ A: a, B: b, G: g, R: r, }} }
go
func NewRGBA(a, b, g, r uint8) *RGBA { return &RGBA{RGBA: color.RGBA{ A: a, B: b, G: g, R: r, }} }
[ "func", "NewRGBA", "(", "a", ",", "b", ",", "g", ",", "r", "uint8", ")", "*", "RGBA", "{", "return", "&", "RGBA", "{", "RGBA", ":", "color", ".", "RGBA", "{", "A", ":", "a", ",", "B", ":", "b", ",", "G", ":", "g", ",", "R", ":", "r", ",...
// NewRGBA creates a new RGBA color
[ "NewRGBA", "creates", "a", "new", "RGBA", "color" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/image/color.go#L16-L23
143,580
asticode/go-astitools
audio/convert.go
ConvertSampleRate
func ConvertSampleRate(srcSamples []int32, srcSampleRate, dstSampleRate int) (dstSamples []int32, err error) { // Do nothing if srcSampleRate == dstSampleRate { dstSamples = srcSamples return } // For now we don't handle data loss if srcSampleRate < dstSampleRate { err = errors.New("astiaudio: src sample ra...
go
func ConvertSampleRate(srcSamples []int32, srcSampleRate, dstSampleRate int) (dstSamples []int32, err error) { // Do nothing if srcSampleRate == dstSampleRate { dstSamples = srcSamples return } // For now we don't handle data loss if srcSampleRate < dstSampleRate { err = errors.New("astiaudio: src sample ra...
[ "func", "ConvertSampleRate", "(", "srcSamples", "[", "]", "int32", ",", "srcSampleRate", ",", "dstSampleRate", "int", ")", "(", "dstSamples", "[", "]", "int32", ",", "err", "error", ")", "{", "// Do nothing", "if", "srcSampleRate", "==", "dstSampleRate", "{", ...
// ConvertSampleRate converts the sample rate
[ "ConvertSampleRate", "converts", "the", "sample", "rate" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/audio/convert.go#L10-L44
143,581
asticode/go-astitools
audio/convert.go
ConvertBitDepth
func ConvertBitDepth(srcSample int32, srcBitDepth, dstBitDepth int) (dstSample int32, err error) { // Nothing to do if srcBitDepth == dstBitDepth { return } // For now we don't handle data loss if srcBitDepth < dstBitDepth { err = errors.New("astiaudio: src bit depth < dst bit depth") return } // Convert...
go
func ConvertBitDepth(srcSample int32, srcBitDepth, dstBitDepth int) (dstSample int32, err error) { // Nothing to do if srcBitDepth == dstBitDepth { return } // For now we don't handle data loss if srcBitDepth < dstBitDepth { err = errors.New("astiaudio: src bit depth < dst bit depth") return } // Convert...
[ "func", "ConvertBitDepth", "(", "srcSample", "int32", ",", "srcBitDepth", ",", "dstBitDepth", "int", ")", "(", "dstSample", "int32", ",", "err", "error", ")", "{", "// Nothing to do", "if", "srcBitDepth", "==", "dstBitDepth", "{", "return", "\n", "}", "\n\n", ...
// ConvertBitDepth converts the bit depth
[ "ConvertBitDepth", "converts", "the", "bit", "depth" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/audio/convert.go#L47-L62
143,582
asticode/go-astitools
http/sender.go
NewSender
func NewSender(o SenderOptions) (s *Sender) { s = &Sender{ client: o.Client, retryFunc: o.RetryFunc, retryMax: o.RetryMax, retrySleep: o.RetrySleep, } if s.client == nil { s.client = &http.Client{} } if s.retryFunc == nil { s.retryFunc = defaultRetryFunc } return }
go
func NewSender(o SenderOptions) (s *Sender) { s = &Sender{ client: o.Client, retryFunc: o.RetryFunc, retryMax: o.RetryMax, retrySleep: o.RetrySleep, } if s.client == nil { s.client = &http.Client{} } if s.retryFunc == nil { s.retryFunc = defaultRetryFunc } return }
[ "func", "NewSender", "(", "o", "SenderOptions", ")", "(", "s", "*", "Sender", ")", "{", "s", "=", "&", "Sender", "{", "client", ":", "o", ".", "Client", ",", "retryFunc", ":", "o", ".", "RetryFunc", ",", "retryMax", ":", "o", ".", "RetryMax", ",", ...
// NewSender creates a new sender
[ "NewSender", "creates", "a", "new", "sender" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/sender.go#L43-L57
143,583
asticode/go-astitools
http/sender.go
ExecWithRetry
func (s *Sender) ExecWithRetry(name string, fn func() (*http.Response, error)) (resp *http.Response, err error) { // Loop // We start at retryMax + 1 so that it runs at least once even if retryMax == 0 tries := 0 for retriesLeft := s.retryMax + 1; retriesLeft > 0; retriesLeft-- { // Get request name nr := fmt.S...
go
func (s *Sender) ExecWithRetry(name string, fn func() (*http.Response, error)) (resp *http.Response, err error) { // Loop // We start at retryMax + 1 so that it runs at least once even if retryMax == 0 tries := 0 for retriesLeft := s.retryMax + 1; retriesLeft > 0; retriesLeft-- { // Get request name nr := fmt.S...
[ "func", "(", "s", "*", "Sender", ")", "ExecWithRetry", "(", "name", "string", ",", "fn", "func", "(", ")", "(", "*", "http", ".", "Response", ",", "error", ")", ")", "(", "resp", "*", "http", ".", "Response", ",", "err", "error", ")", "{", "// Lo...
// ExecWithRetry handles retrying when fetching a response // name is used for logging purposes only
[ "ExecWithRetry", "handles", "retrying", "when", "fetching", "a", "response", "name", "is", "used", "for", "logging", "purposes", "only" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/sender.go#L71-L110
143,584
asticode/go-astitools
http/downloader.go
NewDownloader
func NewDownloader(o DownloaderOptions) (d *Downloader) { d = &Downloader{ bp: &sync.Pool{New: func() interface{} { return &bytes.Buffer{} }}, ignoreErrors: o.IgnoreErrors, mc: &sync.Mutex{}, mw: &sync.Mutex{}, numberOfWorkers: o.NumberOfWorkers, s: N...
go
func NewDownloader(o DownloaderOptions) (d *Downloader) { d = &Downloader{ bp: &sync.Pool{New: func() interface{} { return &bytes.Buffer{} }}, ignoreErrors: o.IgnoreErrors, mc: &sync.Mutex{}, mw: &sync.Mutex{}, numberOfWorkers: o.NumberOfWorkers, s: N...
[ "func", "NewDownloader", "(", "o", "DownloaderOptions", ")", "(", "d", "*", "Downloader", ")", "{", "d", "=", "&", "Downloader", "{", "bp", ":", "&", "sync", ".", "Pool", "{", "New", ":", "func", "(", ")", "interface", "{", "}", "{", "return", "&",...
// NewDownloader creates a new downloader
[ "NewDownloader", "creates", "a", "new", "downloader" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/downloader.go#L42-L56
143,585
asticode/go-astitools
http/downloader.go
Download
func (d *Downloader) Download(parentCtx context.Context, paths []string, fn DownloaderFunc) (err error) { // Init ctx, cancel := context.WithCancel(parentCtx) m := &sync.Mutex{} // Locks err gwg := &sync.WaitGroup{} gwg.Add(len(paths)) lwg := &sync.WaitGroup{} // Loop through src paths var idx int for idx < l...
go
func (d *Downloader) Download(parentCtx context.Context, paths []string, fn DownloaderFunc) (err error) { // Init ctx, cancel := context.WithCancel(parentCtx) m := &sync.Mutex{} // Locks err gwg := &sync.WaitGroup{} gwg.Add(len(paths)) lwg := &sync.WaitGroup{} // Loop through src paths var idx int for idx < l...
[ "func", "(", "d", "*", "Downloader", ")", "Download", "(", "parentCtx", "context", ".", "Context", ",", "paths", "[", "]", "string", ",", "fn", "DownloaderFunc", ")", "(", "err", "error", ")", "{", "// Init", "ctx", ",", "cancel", ":=", "context", ".",...
// Download downloads in parallel a set of src paths and executes a custom callback on each downloaded buffers
[ "Download", "downloads", "in", "parallel", "a", "set", "of", "src", "paths", "and", "executes", "a", "custom", "callback", "on", "each", "downloaded", "buffers" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/downloader.go#L59-L123
143,586
asticode/go-astitools
http/downloader.go
DownloadInDirectory
func (d *Downloader) DownloadInDirectory(ctx context.Context, dst string, paths ...string) error { return d.Download(ctx, paths, func(ctx context.Context, idx int, path string, r io.ReadCloser) (err error) { // Make sure to close the reader defer r.Close() // Make sure destination directory exists if err = os...
go
func (d *Downloader) DownloadInDirectory(ctx context.Context, dst string, paths ...string) error { return d.Download(ctx, paths, func(ctx context.Context, idx int, path string, r io.ReadCloser) (err error) { // Make sure to close the reader defer r.Close() // Make sure destination directory exists if err = os...
[ "func", "(", "d", "*", "Downloader", ")", "DownloadInDirectory", "(", "ctx", "context", ".", "Context", ",", "dst", "string", ",", "paths", "...", "string", ")", "error", "{", "return", "d", ".", "Download", "(", "ctx", ",", "paths", ",", "func", "(", ...
// DownloadInDirectory downloads in parallel a set of src paths and saves them in a dst directory
[ "DownloadInDirectory", "downloads", "in", "parallel", "a", "set", "of", "src", "paths", "and", "saves", "them", "in", "a", "dst", "directory" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/downloader.go#L203-L230
143,587
asticode/go-astitools
http/downloader.go
DownloadInWriter
func (d *Downloader) DownloadInWriter(ctx context.Context, w io.Writer, paths ...string) (err error) { // Download var cs []chunk var m sync.Mutex // Locks cs var requiredIdx int err = d.Download(ctx, paths, func(ctx context.Context, idx int, path string, r io.ReadCloser) (err error) { // Lock m.Lock() defer...
go
func (d *Downloader) DownloadInWriter(ctx context.Context, w io.Writer, paths ...string) (err error) { // Download var cs []chunk var m sync.Mutex // Locks cs var requiredIdx int err = d.Download(ctx, paths, func(ctx context.Context, idx int, path string, r io.ReadCloser) (err error) { // Lock m.Lock() defer...
[ "func", "(", "d", "*", "Downloader", ")", "DownloadInWriter", "(", "ctx", "context", ".", "Context", ",", "w", "io", ".", "Writer", ",", "paths", "...", "string", ")", "(", "err", "error", ")", "{", "// Download", "var", "cs", "[", "]", "chunk", "\n"...
// DownloadInWriter downloads in parallel a set of src paths and concatenates them in order in a writer
[ "DownloadInWriter", "downloads", "in", "parallel", "a", "set", "of", "src", "paths", "and", "concatenates", "them", "in", "order", "in", "a", "writer" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/downloader.go#L239-L305
143,588
asticode/go-astitools
http/downloader.go
DownloadInFile
func (d *Downloader) DownloadInFile(ctx context.Context, dst string, paths ...string) (err error) { // Make sure destination directory exists if err = os.MkdirAll(filepath.Dir(dst), 0700); err != nil { err = errors.Wrapf(err, "astihttp: mkdirall %s failed", filepath.Dir(dst)) return } // Create destination fil...
go
func (d *Downloader) DownloadInFile(ctx context.Context, dst string, paths ...string) (err error) { // Make sure destination directory exists if err = os.MkdirAll(filepath.Dir(dst), 0700); err != nil { err = errors.Wrapf(err, "astihttp: mkdirall %s failed", filepath.Dir(dst)) return } // Create destination fil...
[ "func", "(", "d", "*", "Downloader", ")", "DownloadInFile", "(", "ctx", "context", ".", "Context", ",", "dst", "string", ",", "paths", "...", "string", ")", "(", "err", "error", ")", "{", "// Make sure destination directory exists", "if", "err", "=", "os", ...
// DownloadInFile downloads in parallel a set of src paths and concatenates them in order in a writer
[ "DownloadInFile", "downloads", "in", "parallel", "a", "set", "of", "src", "paths", "and", "concatenates", "them", "in", "order", "in", "a", "writer" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/http/downloader.go#L308-L325
143,589
asticode/go-astitools
unicode/utf8.go
StripUTF8Chars
func StripUTF8Chars(i []byte) (o []byte) { buf := i for len(buf) > 0 { r, size := utf8.DecodeRune(buf) if r == utf8.RuneError && size == 1 { buf = buf[size:] continue } o = append(o, buf[:size]...) buf = buf[size:] } return }
go
func StripUTF8Chars(i []byte) (o []byte) { buf := i for len(buf) > 0 { r, size := utf8.DecodeRune(buf) if r == utf8.RuneError && size == 1 { buf = buf[size:] continue } o = append(o, buf[:size]...) buf = buf[size:] } return }
[ "func", "StripUTF8Chars", "(", "i", "[", "]", "byte", ")", "(", "o", "[", "]", "byte", ")", "{", "buf", ":=", "i", "\n", "for", "len", "(", "buf", ")", ">", "0", "{", "r", ",", "size", ":=", "utf8", ".", "DecodeRune", "(", "buf", ")", "\n", ...
// StripUTF8Chars strips UTF8 chars
[ "StripUTF8Chars", "strips", "UTF8", "chars" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/unicode/utf8.go#L8-L20
143,590
asticode/go-astitools
defer/closer.go
Add
func (c *Closer) Add(f CloseFunc) { c.m.Lock() defer c.m.Unlock() c.fs = append([]CloseFunc{f}, c.fs...) }
go
func (c *Closer) Add(f CloseFunc) { c.m.Lock() defer c.m.Unlock() c.fs = append([]CloseFunc{f}, c.fs...) }
[ "func", "(", "c", "*", "Closer", ")", "Add", "(", "f", "CloseFunc", ")", "{", "c", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "m", ".", "Unlock", "(", ")", "\n", "c", ".", "fs", "=", "append", "(", "[", "]", "CloseFunc", "{",...
// Add adds a close func at the beginning of the list
[ "Add", "adds", "a", "close", "func", "at", "the", "beginning", "of", "the", "list" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/defer/closer.go#L54-L58
143,591
asticode/go-astitools
defer/closer.go
NewChild
func (c *Closer) NewChild() (child *Closer) { child = NewCloser() c.Add(child.Close) return }
go
func (c *Closer) NewChild() (child *Closer) { child = NewCloser() c.Add(child.Close) return }
[ "func", "(", "c", "*", "Closer", ")", "NewChild", "(", ")", "(", "child", "*", "Closer", ")", "{", "child", "=", "NewCloser", "(", ")", "\n", "c", ".", "Add", "(", "child", ".", "Close", ")", "\n", "return", "\n", "}" ]
// NewChild creates a new child closer
[ "NewChild", "creates", "a", "new", "child", "closer" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/defer/closer.go#L61-L65
143,592
asticode/go-astitools
sync/queue.go
NewCtxQueue
func NewCtxQueue() *CtxQueue { return &CtxQueue{ c: make(chan ctxQueueMessage), o: &sync.Once{}, startC: sync.NewCond(&sync.Mutex{}), statListen: astistat.NewDurationRatioStat(), } }
go
func NewCtxQueue() *CtxQueue { return &CtxQueue{ c: make(chan ctxQueueMessage), o: &sync.Once{}, startC: sync.NewCond(&sync.Mutex{}), statListen: astistat.NewDurationRatioStat(), } }
[ "func", "NewCtxQueue", "(", ")", "*", "CtxQueue", "{", "return", "&", "CtxQueue", "{", "c", ":", "make", "(", "chan", "ctxQueueMessage", ")", ",", "o", ":", "&", "sync", ".", "Once", "{", "}", ",", "startC", ":", "sync", ".", "NewCond", "(", "&", ...
// NewCtxQueue creates a new ctx queue
[ "NewCtxQueue", "creates", "a", "new", "ctx", "queue" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/sync/queue.go#L30-L37
143,593
asticode/go-astitools
sync/queue.go
HandleCtx
func (q *CtxQueue) HandleCtx(ctx context.Context) { // Wait for ctx to be done <-ctx.Done() // Broadcast q.startC.L.Lock() atomic.StoreUint32(&q.ctxIsDone, 1) q.startC.Broadcast() q.startC.L.Unlock() // If the queue has started, send the ctx message if d := atomic.LoadUint32(&q.hasStarted); d == 1 { q.c <-...
go
func (q *CtxQueue) HandleCtx(ctx context.Context) { // Wait for ctx to be done <-ctx.Done() // Broadcast q.startC.L.Lock() atomic.StoreUint32(&q.ctxIsDone, 1) q.startC.Broadcast() q.startC.L.Unlock() // If the queue has started, send the ctx message if d := atomic.LoadUint32(&q.hasStarted); d == 1 { q.c <-...
[ "func", "(", "q", "*", "CtxQueue", ")", "HandleCtx", "(", "ctx", "context", ".", "Context", ")", "{", "// Wait for ctx to be done", "<-", "ctx", ".", "Done", "(", ")", "\n\n", "// Broadcast", "q", ".", "startC", ".", "L", ".", "Lock", "(", ")", "\n", ...
// HandleCtx handles the ctx
[ "HandleCtx", "handles", "the", "ctx" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/sync/queue.go#L40-L54
143,594
asticode/go-astitools
sync/queue.go
Start
func (q *CtxQueue) Start(fn func(p interface{})) { // Make sure the queue can only be started once q.o.Do(func() { // Reset ctx atomic.StoreUint32(&q.ctxIsDone, 0) // Broadcast q.startC.L.Lock() q.startC.Broadcast() atomic.StoreUint32(&q.hasStarted, 1) q.startC.L.Unlock() // Wait is starting q.sta...
go
func (q *CtxQueue) Start(fn func(p interface{})) { // Make sure the queue can only be started once q.o.Do(func() { // Reset ctx atomic.StoreUint32(&q.ctxIsDone, 0) // Broadcast q.startC.L.Lock() q.startC.Broadcast() atomic.StoreUint32(&q.hasStarted, 1) q.startC.L.Unlock() // Wait is starting q.sta...
[ "func", "(", "q", "*", "CtxQueue", ")", "Start", "(", "fn", "func", "(", "p", "interface", "{", "}", ")", ")", "{", "// Make sure the queue can only be started once", "q", ".", "o", ".", "Do", "(", "func", "(", ")", "{", "// Reset ctx", "atomic", ".", ...
// Start starts the queue
[ "Start", "starts", "the", "queue" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/sync/queue.go#L57-L97
143,595
asticode/go-astitools
sync/queue.go
Send
func (q *CtxQueue) Send(p interface{}) { // Make sure to lock here q.startC.L.Lock() // Context is done if d := atomic.LoadUint32(&q.ctxIsDone); d == 1 { q.startC.L.Unlock() return } // Check whether queue has been started if d := atomic.LoadUint32(&q.hasStarted); d == 0 { // We either wait for the queue...
go
func (q *CtxQueue) Send(p interface{}) { // Make sure to lock here q.startC.L.Lock() // Context is done if d := atomic.LoadUint32(&q.ctxIsDone); d == 1 { q.startC.L.Unlock() return } // Check whether queue has been started if d := atomic.LoadUint32(&q.hasStarted); d == 0 { // We either wait for the queue...
[ "func", "(", "q", "*", "CtxQueue", ")", "Send", "(", "p", "interface", "{", "}", ")", "{", "// Make sure to lock here", "q", ".", "startC", ".", "L", ".", "Lock", "(", ")", "\n\n", "// Context is done", "if", "d", ":=", "atomic", ".", "LoadUint32", "("...
// Send sends a message in the queue and blocks until the message has been fully processed // Block indicates whether to block until the message has been fully processed
[ "Send", "sends", "a", "message", "in", "the", "queue", "and", "blocks", "until", "the", "message", "has", "been", "fully", "processed", "Block", "indicates", "whether", "to", "block", "until", "the", "message", "has", "been", "fully", "processed" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/sync/queue.go#L101-L136
143,596
asticode/go-astitools
sync/queue.go
Stop
func (q *CtxQueue) Stop() { atomic.StoreUint32(&q.hasStarted, 0) q.o = &sync.Once{} }
go
func (q *CtxQueue) Stop() { atomic.StoreUint32(&q.hasStarted, 0) q.o = &sync.Once{} }
[ "func", "(", "q", "*", "CtxQueue", ")", "Stop", "(", ")", "{", "atomic", ".", "StoreUint32", "(", "&", "q", ".", "hasStarted", ",", "0", ")", "\n", "q", ".", "o", "=", "&", "sync", ".", "Once", "{", "}", "\n", "}" ]
// Stop stops the queue properly
[ "Stop", "stops", "the", "queue", "properly" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/sync/queue.go#L139-L142
143,597
asticode/go-astitools
sync/queue.go
AddStats
func (q *CtxQueue) AddStats(s *astistat.Stater) { // Add wait stat s.AddStat(astistat.StatMetadata{ Description: "Percentage of time spent listening and waiting for new object", Label: "Listen ratio", Unit: "%", }, q.statListen) }
go
func (q *CtxQueue) AddStats(s *astistat.Stater) { // Add wait stat s.AddStat(astistat.StatMetadata{ Description: "Percentage of time spent listening and waiting for new object", Label: "Listen ratio", Unit: "%", }, q.statListen) }
[ "func", "(", "q", "*", "CtxQueue", ")", "AddStats", "(", "s", "*", "astistat", ".", "Stater", ")", "{", "// Add wait stat", "s", ".", "AddStat", "(", "astistat", ".", "StatMetadata", "{", "Description", ":", "\"", "\"", ",", "Label", ":", "\"", "\"", ...
// AddStats adds queue stats
[ "AddStats", "adds", "queue", "stats" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/sync/queue.go#L145-L152
143,598
asticode/go-astitools
sync/mutex.go
NewRWMutex
func NewRWMutex(name string, log bool) *RWMutex { return &RWMutex{ log: log, mutex: &sync.RWMutex{}, name: name, } }
go
func NewRWMutex(name string, log bool) *RWMutex { return &RWMutex{ log: log, mutex: &sync.RWMutex{}, name: name, } }
[ "func", "NewRWMutex", "(", "name", "string", ",", "log", "bool", ")", "*", "RWMutex", "{", "return", "&", "RWMutex", "{", "log", ":", "log", ",", "mutex", ":", "&", "sync", ".", "RWMutex", "{", "}", ",", "name", ":", "name", ",", "}", "\n", "}" ]
// NewRWMutex creates a new RWMutex
[ "NewRWMutex", "creates", "a", "new", "RWMutex" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/sync/mutex.go#L21-L27
143,599
asticode/go-astitools
sync/mutex.go
Lock
func (m *RWMutex) Lock() { var caller string if _, file, line, ok := runtime.Caller(1); ok { caller = fmt.Sprintf("%s:%d", file, line) } if m.log { astilog.Debugf("Requesting lock for %s at %s", m.name, caller) } m.mutex.Lock() if m.log { astilog.Debugf("Lock acquired for %s at %s", m.name, caller) } m.l...
go
func (m *RWMutex) Lock() { var caller string if _, file, line, ok := runtime.Caller(1); ok { caller = fmt.Sprintf("%s:%d", file, line) } if m.log { astilog.Debugf("Requesting lock for %s at %s", m.name, caller) } m.mutex.Lock() if m.log { astilog.Debugf("Lock acquired for %s at %s", m.name, caller) } m.l...
[ "func", "(", "m", "*", "RWMutex", ")", "Lock", "(", ")", "{", "var", "caller", "string", "\n", "if", "_", ",", "file", ",", "line", ",", "ok", ":=", "runtime", ".", "Caller", "(", "1", ")", ";", "ok", "{", "caller", "=", "fmt", ".", "Sprintf", ...
// Lock write locks the mutex
[ "Lock", "write", "locks", "the", "mutex" ]
e078684fbd9fa6697ab3f018a9e089a06c7b6f51
https://github.com/asticode/go-astitools/blob/e078684fbd9fa6697ab3f018a9e089a06c7b6f51/sync/mutex.go#L30-L43