id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
140,700
coreos/go-systemd
activation/listeners.go
TLSListeners
func TLSListeners(tlsConfig *tls.Config) ([]net.Listener, error) { listeners, err := Listeners() if listeners == nil || err != nil { return nil, err } if tlsConfig != nil && err == nil { for i, l := range listeners { // Activate TLS only for TCP sockets if l.Addr().Network() == "tcp" { listeners[i] ...
go
func TLSListeners(tlsConfig *tls.Config) ([]net.Listener, error) { listeners, err := Listeners() if listeners == nil || err != nil { return nil, err } if tlsConfig != nil && err == nil { for i, l := range listeners { // Activate TLS only for TCP sockets if l.Addr().Network() == "tcp" { listeners[i] ...
[ "func", "TLSListeners", "(", "tlsConfig", "*", "tls", ".", "Config", ")", "(", "[", "]", "net", ".", "Listener", ",", "error", ")", "{", "listeners", ",", "err", ":=", "Listeners", "(", ")", "\n\n", "if", "listeners", "==", "nil", "||", "err", "!=", ...
// TLSListeners returns a slice containing a net.listener for each matching TCP socket type // passed to this process. // It uses default Listeners func and forces TCP sockets handlers to use TLS based on tlsConfig.
[ "TLSListeners", "returns", "a", "slice", "containing", "a", "net", ".", "listener", "for", "each", "matching", "TCP", "socket", "type", "passed", "to", "this", "process", ".", "It", "uses", "default", "Listeners", "func", "and", "forces", "TCP", "sockets", "...
95778dfbb74eb7e4dbaf43bf7d71809650ef8076
https://github.com/coreos/go-systemd/blob/95778dfbb74eb7e4dbaf43bf7d71809650ef8076/activation/listeners.go#L63-L80
140,701
coreos/go-systemd
activation/listeners.go
TLSListenersWithNames
func TLSListenersWithNames(tlsConfig *tls.Config) (map[string][]net.Listener, error) { listeners, err := ListenersWithNames() if listeners == nil || err != nil { return nil, err } if tlsConfig != nil && err == nil { for _, ll := range listeners { // Activate TLS only for TCP sockets for i, l := range ll...
go
func TLSListenersWithNames(tlsConfig *tls.Config) (map[string][]net.Listener, error) { listeners, err := ListenersWithNames() if listeners == nil || err != nil { return nil, err } if tlsConfig != nil && err == nil { for _, ll := range listeners { // Activate TLS only for TCP sockets for i, l := range ll...
[ "func", "TLSListenersWithNames", "(", "tlsConfig", "*", "tls", ".", "Config", ")", "(", "map", "[", "string", "]", "[", "]", "net", ".", "Listener", ",", "error", ")", "{", "listeners", ",", "err", ":=", "ListenersWithNames", "(", ")", "\n\n", "if", "l...
// TLSListenersWithNames maps a listener name to a net.Listener with // the associated TLS configuration.
[ "TLSListenersWithNames", "maps", "a", "listener", "name", "to", "a", "net", ".", "Listener", "with", "the", "associated", "TLS", "configuration", "." ]
95778dfbb74eb7e4dbaf43bf7d71809650ef8076
https://github.com/coreos/go-systemd/blob/95778dfbb74eb7e4dbaf43bf7d71809650ef8076/activation/listeners.go#L84-L103
140,702
pkg/sftp
request-example.go
InMemHandler
func InMemHandler() Handlers { root := &root{ files: make(map[string]*memFile), } root.memFile = newMemFile("/", true) return Handlers{root, root, root, root} }
go
func InMemHandler() Handlers { root := &root{ files: make(map[string]*memFile), } root.memFile = newMemFile("/", true) return Handlers{root, root, root, root} }
[ "func", "InMemHandler", "(", ")", "Handlers", "{", "root", ":=", "&", "root", "{", "files", ":", "make", "(", "map", "[", "string", "]", "*", "memFile", ")", ",", "}", "\n", "root", ".", "memFile", "=", "newMemFile", "(", "\"", "\"", ",", "true", ...
// InMemHandler returns a Hanlders object with the test handlers.
[ "InMemHandler", "returns", "a", "Hanlders", "object", "with", "the", "test", "handlers", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request-example.go#L20-L26
140,703
pkg/sftp
request-example.go
newMemFile
func newMemFile(name string, isdir bool) *memFile { return &memFile{ name: name, modtime: time.Now(), isdir: isdir, } }
go
func newMemFile(name string, isdir bool) *memFile { return &memFile{ name: name, modtime: time.Now(), isdir: isdir, } }
[ "func", "newMemFile", "(", "name", "string", ",", "isdir", "bool", ")", "*", "memFile", "{", "return", "&", "memFile", "{", "name", ":", "name", ",", "modtime", ":", "time", ".", "Now", "(", ")", ",", "isdir", ":", "isdir", ",", "}", "\n", "}" ]
// factory to make sure modtime is set
[ "factory", "to", "make", "sure", "modtime", "is", "set" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request-example.go#L212-L218
140,704
pkg/sftp
request.go
requestFromPacket
func requestFromPacket(ctx context.Context, pkt hasPath) *Request { method := requestMethod(pkt) request := NewRequest(method, pkt.getPath()) request.ctx, request.cancelCtx = context.WithCancel(ctx) switch p := pkt.(type) { case *sshFxpOpenPacket: request.Flags = p.Pflags case *sshFxpSetstatPacket: request.F...
go
func requestFromPacket(ctx context.Context, pkt hasPath) *Request { method := requestMethod(pkt) request := NewRequest(method, pkt.getPath()) request.ctx, request.cancelCtx = context.WithCancel(ctx) switch p := pkt.(type) { case *sshFxpOpenPacket: request.Flags = p.Pflags case *sshFxpSetstatPacket: request.F...
[ "func", "requestFromPacket", "(", "ctx", "context", ".", "Context", ",", "pkt", "hasPath", ")", "*", "Request", "{", "method", ":=", "requestMethod", "(", "pkt", ")", "\n", "request", ":=", "NewRequest", "(", "method", ",", "pkt", ".", "getPath", "(", ")...
// New Request initialized based on packet data
[ "New", "Request", "initialized", "based", "on", "packet", "data" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request.go#L44-L61
140,705
pkg/sftp
request.go
NewRequest
func NewRequest(method, path string) *Request { return &Request{Method: method, Filepath: cleanPath(path), state: state{RWMutex: new(sync.RWMutex)}} }
go
func NewRequest(method, path string) *Request { return &Request{Method: method, Filepath: cleanPath(path), state: state{RWMutex: new(sync.RWMutex)}} }
[ "func", "NewRequest", "(", "method", ",", "path", "string", ")", "*", "Request", "{", "return", "&", "Request", "{", "Method", ":", "method", ",", "Filepath", ":", "cleanPath", "(", "path", ")", ",", "state", ":", "state", "{", "RWMutex", ":", "new", ...
// NewRequest creates a new Request object.
[ "NewRequest", "creates", "a", "new", "Request", "object", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request.go#L64-L67
140,706
pkg/sftp
request.go
copy
func (r *Request) copy() *Request { r.state.Lock() defer r.state.Unlock() r2 := new(Request) *r2 = *r return r2 }
go
func (r *Request) copy() *Request { r.state.Lock() defer r.state.Unlock() r2 := new(Request) *r2 = *r return r2 }
[ "func", "(", "r", "*", "Request", ")", "copy", "(", ")", "*", "Request", "{", "r", ".", "state", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "state", ".", "Unlock", "(", ")", "\n", "r2", ":=", "new", "(", "Request", ")", "\n", "*", "r2", ...
// shallow copy of existing request
[ "shallow", "copy", "of", "existing", "request" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request.go#L70-L76
140,707
pkg/sftp
request.go
Context
func (r *Request) Context() context.Context { if r.ctx != nil { return r.ctx } return context.Background() }
go
func (r *Request) Context() context.Context { if r.ctx != nil { return r.ctx } return context.Background() }
[ "func", "(", "r", "*", "Request", ")", "Context", "(", ")", "context", ".", "Context", "{", "if", "r", ".", "ctx", "!=", "nil", "{", "return", "r", ".", "ctx", "\n", "}", "\n", "return", "context", ".", "Background", "(", ")", "\n", "}" ]
// Context returns the request's context. To change the context, // use WithContext. // // The returned context is always non-nil; it defaults to the // background context. // // For incoming server requests, the context is canceled when the // request is complete or the client's connection closes.
[ "Context", "returns", "the", "request", "s", "context", ".", "To", "change", "the", "context", "use", "WithContext", ".", "The", "returned", "context", "is", "always", "non", "-", "nil", ";", "it", "defaults", "to", "the", "background", "context", ".", "Fo...
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request.go#L86-L91
140,708
pkg/sftp
request.go
WithContext
func (r *Request) WithContext(ctx context.Context) *Request { if ctx == nil { panic("nil context") } r2 := r.copy() r2.ctx = ctx r2.cancelCtx = nil return r2 }
go
func (r *Request) WithContext(ctx context.Context) *Request { if ctx == nil { panic("nil context") } r2 := r.copy() r2.ctx = ctx r2.cancelCtx = nil return r2 }
[ "func", "(", "r", "*", "Request", ")", "WithContext", "(", "ctx", "context", ".", "Context", ")", "*", "Request", "{", "if", "ctx", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "r2", ":=", "r", ".", "copy", "(", ")", "\n", ...
// WithContext returns a copy of r with its context changed to ctx. // The provided ctx must be non-nil.
[ "WithContext", "returns", "a", "copy", "of", "r", "with", "its", "context", "changed", "to", "ctx", ".", "The", "provided", "ctx", "must", "be", "non", "-", "nil", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request.go#L95-L103
140,709
pkg/sftp
request.go
lsNext
func (r *Request) lsNext() int64 { r.state.RLock() defer r.state.RUnlock() return r.state.lsoffset }
go
func (r *Request) lsNext() int64 { r.state.RLock() defer r.state.RUnlock() return r.state.lsoffset }
[ "func", "(", "r", "*", "Request", ")", "lsNext", "(", ")", "int64", "{", "r", ".", "state", ".", "RLock", "(", ")", "\n", "defer", "r", ".", "state", ".", "RUnlock", "(", ")", "\n", "return", "r", ".", "state", ".", "lsoffset", "\n", "}" ]
// Returns current offset for file list
[ "Returns", "current", "offset", "for", "file", "list" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request.go#L106-L110
140,710
pkg/sftp
request.go
lsInc
func (r *Request) lsInc(offset int64) { r.state.Lock() defer r.state.Unlock() r.state.lsoffset = r.state.lsoffset + offset }
go
func (r *Request) lsInc(offset int64) { r.state.Lock() defer r.state.Unlock() r.state.lsoffset = r.state.lsoffset + offset }
[ "func", "(", "r", "*", "Request", ")", "lsInc", "(", "offset", "int64", ")", "{", "r", ".", "state", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "state", ".", "Unlock", "(", ")", "\n", "r", ".", "state", ".", "lsoffset", "=", "r", ".", "s...
// Increases next offset
[ "Increases", "next", "offset" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request.go#L113-L117
140,711
pkg/sftp
request.go
open
func (r *Request) open(h Handlers, pkt requestPacket) responsePacket { flags := r.Pflags() var err error switch { case flags.Write, flags.Append, flags.Creat, flags.Trunc: r.Method = "Put" r.state.writerAt, err = h.FilePut.Filewrite(r) case flags.Read: r.Method = "Get" r.state.readerAt, err = h.FileGet.Fil...
go
func (r *Request) open(h Handlers, pkt requestPacket) responsePacket { flags := r.Pflags() var err error switch { case flags.Write, flags.Append, flags.Creat, flags.Trunc: r.Method = "Put" r.state.writerAt, err = h.FilePut.Filewrite(r) case flags.Read: r.Method = "Get" r.state.readerAt, err = h.FileGet.Fil...
[ "func", "(", "r", "*", "Request", ")", "open", "(", "h", "Handlers", ",", "pkt", "requestPacket", ")", "responsePacket", "{", "flags", ":=", "r", ".", "Pflags", "(", ")", "\n", "var", "err", "error", "\n", "switch", "{", "case", "flags", ".", "Write"...
// Additional initialization for Open packets
[ "Additional", "initialization", "for", "Open", "packets" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request.go#L174-L191
140,712
pkg/sftp
request.go
fileget
func fileget(h FileReader, r *Request, pkt requestPacket) responsePacket { //fmt.Println("fileget", r) r.state.RLock() reader := r.state.readerAt r.state.RUnlock() if reader == nil { return statusFromError(pkt, errors.New("unexpected read packet")) } _, offset, length := packetData(pkt) data := make([]byte, ...
go
func fileget(h FileReader, r *Request, pkt requestPacket) responsePacket { //fmt.Println("fileget", r) r.state.RLock() reader := r.state.readerAt r.state.RUnlock() if reader == nil { return statusFromError(pkt, errors.New("unexpected read packet")) } _, offset, length := packetData(pkt) data := make([]byte, ...
[ "func", "fileget", "(", "h", "FileReader", ",", "r", "*", "Request", ",", "pkt", "requestPacket", ")", "responsePacket", "{", "//fmt.Println(\"fileget\", r)", "r", ".", "state", ".", "RLock", "(", ")", "\n", "reader", ":=", "r", ".", "state", ".", "readerA...
// wrap FileReader handler
[ "wrap", "FileReader", "handler" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request.go#L207-L228
140,713
pkg/sftp
request.go
fileput
func fileput(h FileWriter, r *Request, pkt requestPacket) responsePacket { //fmt.Println("fileput", r) r.state.RLock() writer := r.state.writerAt r.state.RUnlock() if writer == nil { return statusFromError(pkt, errors.New("unexpected write packet")) } data, offset, _ := packetData(pkt) _, err := writer.Write...
go
func fileput(h FileWriter, r *Request, pkt requestPacket) responsePacket { //fmt.Println("fileput", r) r.state.RLock() writer := r.state.writerAt r.state.RUnlock() if writer == nil { return statusFromError(pkt, errors.New("unexpected write packet")) } data, offset, _ := packetData(pkt) _, err := writer.Write...
[ "func", "fileput", "(", "h", "FileWriter", ",", "r", "*", "Request", ",", "pkt", "requestPacket", ")", "responsePacket", "{", "//fmt.Println(\"fileput\", r)", "r", ".", "state", ".", "RLock", "(", ")", "\n", "writer", ":=", "r", ".", "state", ".", "writerA...
// wrap FileWriter handler
[ "wrap", "FileWriter", "handler" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request.go#L231-L243
140,714
pkg/sftp
request.go
filecmd
func filecmd(h FileCmder, r *Request, pkt requestPacket) responsePacket { switch p := pkt.(type) { case *sshFxpFsetstatPacket: r.Flags = p.Flags r.Attrs = p.Attrs.([]byte) } err := h.Filecmd(r) return statusFromError(pkt, err) }
go
func filecmd(h FileCmder, r *Request, pkt requestPacket) responsePacket { switch p := pkt.(type) { case *sshFxpFsetstatPacket: r.Flags = p.Flags r.Attrs = p.Attrs.([]byte) } err := h.Filecmd(r) return statusFromError(pkt, err) }
[ "func", "filecmd", "(", "h", "FileCmder", ",", "r", "*", "Request", ",", "pkt", "requestPacket", ")", "responsePacket", "{", "switch", "p", ":=", "pkt", ".", "(", "type", ")", "{", "case", "*", "sshFxpFsetstatPacket", ":", "r", ".", "Flags", "=", "p", ...
// wrap FileCmder handler
[ "wrap", "FileCmder", "handler" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request.go#L260-L269
140,715
pkg/sftp
request.go
filelist
func filelist(h FileLister, r *Request, pkt requestPacket) responsePacket { var err error lister := r.getLister() if lister == nil { return statusFromError(pkt, errors.New("unexpected dir packet")) } offset := r.lsNext() finfo := make([]os.FileInfo, MaxFilelist) n, err := lister.ListAt(finfo, offset) r.lsInc...
go
func filelist(h FileLister, r *Request, pkt requestPacket) responsePacket { var err error lister := r.getLister() if lister == nil { return statusFromError(pkt, errors.New("unexpected dir packet")) } offset := r.lsNext() finfo := make([]os.FileInfo, MaxFilelist) n, err := lister.ListAt(finfo, offset) r.lsInc...
[ "func", "filelist", "(", "h", "FileLister", ",", "r", "*", "Request", ",", "pkt", "requestPacket", ")", "responsePacket", "{", "var", "err", "error", "\n", "lister", ":=", "r", ".", "getLister", "(", ")", "\n", "if", "lister", "==", "nil", "{", "return...
// wrap FileLister handler
[ "wrap", "FileLister", "handler" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request.go#L272-L309
140,716
pkg/sftp
request.go
requestMethod
func requestMethod(p requestPacket) (method string) { switch p.(type) { case *sshFxpReadPacket, *sshFxpWritePacket, *sshFxpOpenPacket: // set in open() above case *sshFxpOpendirPacket, *sshFxpReaddirPacket: // set in opendir() above case *sshFxpSetstatPacket, *sshFxpFsetstatPacket: method = "Setstat" case *s...
go
func requestMethod(p requestPacket) (method string) { switch p.(type) { case *sshFxpReadPacket, *sshFxpWritePacket, *sshFxpOpenPacket: // set in open() above case *sshFxpOpendirPacket, *sshFxpReaddirPacket: // set in opendir() above case *sshFxpSetstatPacket, *sshFxpFsetstatPacket: method = "Setstat" case *s...
[ "func", "requestMethod", "(", "p", "requestPacket", ")", "(", "method", "string", ")", "{", "switch", "p", ".", "(", "type", ")", "{", "case", "*", "sshFxpReadPacket", ",", "*", "sshFxpWritePacket", ",", "*", "sshFxpOpenPacket", ":", "// set in open() above", ...
// init attributes of request object from packet data
[ "init", "attributes", "of", "request", "object", "from", "packet", "data" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request.go#L359-L383
140,717
pkg/sftp
client.go
MaxConcurrentRequestsPerFile
func MaxConcurrentRequestsPerFile(n int) ClientOption { return func(c *Client) error { if n < 1 { return errors.Errorf("n must be greater or equal to 1") } c.maxConcurrentRequests = n return nil } }
go
func MaxConcurrentRequestsPerFile(n int) ClientOption { return func(c *Client) error { if n < 1 { return errors.Errorf("n must be greater or equal to 1") } c.maxConcurrentRequests = n return nil } }
[ "func", "MaxConcurrentRequestsPerFile", "(", "n", "int", ")", "ClientOption", "{", "return", "func", "(", "c", "*", "Client", ")", "error", "{", "if", "n", "<", "1", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "c", ...
// MaxConcurrentRequestsPerFile sets the maximum concurrent requests allowed for a single file. // // The default maximum concurrent requests is 64.
[ "MaxConcurrentRequestsPerFile", "sets", "the", "maximum", "concurrent", "requests", "allowed", "for", "a", "single", "file", ".", "The", "default", "maximum", "concurrent", "requests", "is", "64", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L82-L90
140,718
pkg/sftp
client.go
NewClient
func NewClient(conn *ssh.Client, opts ...ClientOption) (*Client, error) { s, err := conn.NewSession() if err != nil { return nil, err } if err := s.RequestSubsystem("sftp"); err != nil { return nil, err } pw, err := s.StdinPipe() if err != nil { return nil, err } pr, err := s.StdoutPipe() if err != nil ...
go
func NewClient(conn *ssh.Client, opts ...ClientOption) (*Client, error) { s, err := conn.NewSession() if err != nil { return nil, err } if err := s.RequestSubsystem("sftp"); err != nil { return nil, err } pw, err := s.StdinPipe() if err != nil { return nil, err } pr, err := s.StdoutPipe() if err != nil ...
[ "func", "NewClient", "(", "conn", "*", "ssh", ".", "Client", ",", "opts", "...", "ClientOption", ")", "(", "*", "Client", ",", "error", ")", "{", "s", ",", "err", ":=", "conn", ".", "NewSession", "(", ")", "\n", "if", "err", "!=", "nil", "{", "re...
// NewClient creates a new SFTP client on conn, using zero or more option // functions.
[ "NewClient", "creates", "a", "new", "SFTP", "client", "on", "conn", "using", "zero", "or", "more", "option", "functions", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L94-L112
140,719
pkg/sftp
client.go
Walk
func (c *Client) Walk(root string) *fs.Walker { return fs.WalkFS(root, c) }
go
func (c *Client) Walk(root string) *fs.Walker { return fs.WalkFS(root, c) }
[ "func", "(", "c", "*", "Client", ")", "Walk", "(", "root", "string", ")", "*", "fs", ".", "Walker", "{", "return", "fs", ".", "WalkFS", "(", "root", ",", "c", ")", "\n", "}" ]
// Walk returns a new Walker rooted at root.
[ "Walk", "returns", "a", "new", "Walker", "rooted", "at", "root", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L199-L201
140,720
pkg/sftp
client.go
ReadDir
func (c *Client) ReadDir(p string) ([]os.FileInfo, error) { handle, err := c.opendir(p) if err != nil { return nil, err } defer c.close(handle) // this has to defer earlier than the lock below var attrs []os.FileInfo var done = false for !done { id := c.nextID() typ, data, err1 := c.sendPacket(sshFxpReaddi...
go
func (c *Client) ReadDir(p string) ([]os.FileInfo, error) { handle, err := c.opendir(p) if err != nil { return nil, err } defer c.close(handle) // this has to defer earlier than the lock below var attrs []os.FileInfo var done = false for !done { id := c.nextID() typ, data, err1 := c.sendPacket(sshFxpReaddi...
[ "func", "(", "c", "*", "Client", ")", "ReadDir", "(", "p", "string", ")", "(", "[", "]", "os", ".", "FileInfo", ",", "error", ")", "{", "handle", ",", "err", ":=", "c", ".", "opendir", "(", "p", ")", "\n", "if", "err", "!=", "nil", "{", "retu...
// ReadDir reads the directory named by dirname and returns a list of // directory entries.
[ "ReadDir", "reads", "the", "directory", "named", "by", "dirname", "and", "returns", "a", "list", "of", "directory", "entries", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L205-L254
140,721
pkg/sftp
client.go
Stat
func (c *Client) Stat(p string) (os.FileInfo, error) { id := c.nextID() typ, data, err := c.sendPacket(sshFxpStatPacket{ ID: id, Path: p, }) if err != nil { return nil, err } switch typ { case ssh_FXP_ATTRS: sid, data := unmarshalUint32(data) if sid != id { return nil, &unexpectedIDErr{id, sid} ...
go
func (c *Client) Stat(p string) (os.FileInfo, error) { id := c.nextID() typ, data, err := c.sendPacket(sshFxpStatPacket{ ID: id, Path: p, }) if err != nil { return nil, err } switch typ { case ssh_FXP_ATTRS: sid, data := unmarshalUint32(data) if sid != id { return nil, &unexpectedIDErr{id, sid} ...
[ "func", "(", "c", "*", "Client", ")", "Stat", "(", "p", "string", ")", "(", "os", ".", "FileInfo", ",", "error", ")", "{", "id", ":=", "c", ".", "nextID", "(", ")", "\n", "typ", ",", "data", ",", "err", ":=", "c", ".", "sendPacket", "(", "ssh...
// Stat returns a FileInfo structure describing the file specified by path 'p'. // If 'p' is a symbolic link, the returned FileInfo structure describes the referent file.
[ "Stat", "returns", "a", "FileInfo", "structure", "describing", "the", "file", "specified", "by", "path", "p", ".", "If", "p", "is", "a", "symbolic", "link", "the", "returned", "FileInfo", "structure", "describes", "the", "referent", "file", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L282-L304
140,722
pkg/sftp
client.go
ReadLink
func (c *Client) ReadLink(p string) (string, error) { id := c.nextID() typ, data, err := c.sendPacket(sshFxpReadlinkPacket{ ID: id, Path: p, }) if err != nil { return "", err } switch typ { case ssh_FXP_NAME: sid, data := unmarshalUint32(data) if sid != id { return "", &unexpectedIDErr{id, sid} ...
go
func (c *Client) ReadLink(p string) (string, error) { id := c.nextID() typ, data, err := c.sendPacket(sshFxpReadlinkPacket{ ID: id, Path: p, }) if err != nil { return "", err } switch typ { case ssh_FXP_NAME: sid, data := unmarshalUint32(data) if sid != id { return "", &unexpectedIDErr{id, sid} ...
[ "func", "(", "c", "*", "Client", ")", "ReadLink", "(", "p", "string", ")", "(", "string", ",", "error", ")", "{", "id", ":=", "c", ".", "nextID", "(", ")", "\n", "typ", ",", "data", ",", "err", ":=", "c", ".", "sendPacket", "(", "sshFxpReadlinkPa...
// ReadLink reads the target of a symbolic link.
[ "ReadLink", "reads", "the", "target", "of", "a", "symbolic", "link", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L333-L359
140,723
pkg/sftp
client.go
Symlink
func (c *Client) Symlink(oldname, newname string) error { id := c.nextID() typ, data, err := c.sendPacket(sshFxpSymlinkPacket{ ID: id, Linkpath: newname, Targetpath: oldname, }) if err != nil { return err } switch typ { case ssh_FXP_STATUS: return normaliseError(unmarshalStatus(id, data)) de...
go
func (c *Client) Symlink(oldname, newname string) error { id := c.nextID() typ, data, err := c.sendPacket(sshFxpSymlinkPacket{ ID: id, Linkpath: newname, Targetpath: oldname, }) if err != nil { return err } switch typ { case ssh_FXP_STATUS: return normaliseError(unmarshalStatus(id, data)) de...
[ "func", "(", "c", "*", "Client", ")", "Symlink", "(", "oldname", ",", "newname", "string", ")", "error", "{", "id", ":=", "c", ".", "nextID", "(", ")", "\n", "typ", ",", "data", ",", "err", ":=", "c", ".", "sendPacket", "(", "sshFxpSymlinkPacket", ...
// Symlink creates a symbolic link at 'newname', pointing at target 'oldname'
[ "Symlink", "creates", "a", "symbolic", "link", "at", "newname", "pointing", "at", "target", "oldname" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L362-L378
140,724
pkg/sftp
client.go
setstat
func (c *Client) setstat(path string, flags uint32, attrs interface{}) error { id := c.nextID() typ, data, err := c.sendPacket(sshFxpSetstatPacket{ ID: id, Path: path, Flags: flags, Attrs: attrs, }) if err != nil { return err } switch typ { case ssh_FXP_STATUS: return normaliseError(unmarshalStat...
go
func (c *Client) setstat(path string, flags uint32, attrs interface{}) error { id := c.nextID() typ, data, err := c.sendPacket(sshFxpSetstatPacket{ ID: id, Path: path, Flags: flags, Attrs: attrs, }) if err != nil { return err } switch typ { case ssh_FXP_STATUS: return normaliseError(unmarshalStat...
[ "func", "(", "c", "*", "Client", ")", "setstat", "(", "path", "string", ",", "flags", "uint32", ",", "attrs", "interface", "{", "}", ")", "error", "{", "id", ":=", "c", ".", "nextID", "(", ")", "\n", "typ", ",", "data", ",", "err", ":=", "c", "...
// setstat is a convience wrapper to allow for changing of various parts of the file descriptor.
[ "setstat", "is", "a", "convience", "wrapper", "to", "allow", "for", "changing", "of", "various", "parts", "of", "the", "file", "descriptor", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L381-L398
140,725
pkg/sftp
client.go
Chown
func (c *Client) Chown(path string, uid, gid int) error { type owner struct { UID uint32 GID uint32 } attrs := owner{uint32(uid), uint32(gid)} return c.setstat(path, ssh_FILEXFER_ATTR_UIDGID, attrs) }
go
func (c *Client) Chown(path string, uid, gid int) error { type owner struct { UID uint32 GID uint32 } attrs := owner{uint32(uid), uint32(gid)} return c.setstat(path, ssh_FILEXFER_ATTR_UIDGID, attrs) }
[ "func", "(", "c", "*", "Client", ")", "Chown", "(", "path", "string", ",", "uid", ",", "gid", "int", ")", "error", "{", "type", "owner", "struct", "{", "UID", "uint32", "\n", "GID", "uint32", "\n", "}", "\n", "attrs", ":=", "owner", "{", "uint32", ...
// Chown changes the user and group owners of the named file.
[ "Chown", "changes", "the", "user", "and", "group", "owners", "of", "the", "named", "file", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L411-L418
140,726
pkg/sftp
client.go
Chmod
func (c *Client) Chmod(path string, mode os.FileMode) error { return c.setstat(path, ssh_FILEXFER_ATTR_PERMISSIONS, uint32(mode)) }
go
func (c *Client) Chmod(path string, mode os.FileMode) error { return c.setstat(path, ssh_FILEXFER_ATTR_PERMISSIONS, uint32(mode)) }
[ "func", "(", "c", "*", "Client", ")", "Chmod", "(", "path", "string", ",", "mode", "os", ".", "FileMode", ")", "error", "{", "return", "c", ".", "setstat", "(", "path", ",", "ssh_FILEXFER_ATTR_PERMISSIONS", ",", "uint32", "(", "mode", ")", ")", "\n", ...
// Chmod changes the permissions of the named file.
[ "Chmod", "changes", "the", "permissions", "of", "the", "named", "file", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L421-L423
140,727
pkg/sftp
client.go
Truncate
func (c *Client) Truncate(path string, size int64) error { return c.setstat(path, ssh_FILEXFER_ATTR_SIZE, uint64(size)) }
go
func (c *Client) Truncate(path string, size int64) error { return c.setstat(path, ssh_FILEXFER_ATTR_SIZE, uint64(size)) }
[ "func", "(", "c", "*", "Client", ")", "Truncate", "(", "path", "string", ",", "size", "int64", ")", "error", "{", "return", "c", ".", "setstat", "(", "path", ",", "ssh_FILEXFER_ATTR_SIZE", ",", "uint64", "(", "size", ")", ")", "\n", "}" ]
// Truncate sets the size of the named file. Although it may be safely assumed // that if the size is less than its current size it will be truncated to fit, // the SFTP protocol does not specify what behavior the server should do when setting // size greater than the current size.
[ "Truncate", "sets", "the", "size", "of", "the", "named", "file", ".", "Although", "it", "may", "be", "safely", "assumed", "that", "if", "the", "size", "is", "less", "than", "its", "current", "size", "it", "will", "be", "truncated", "to", "fit", "the", ...
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L429-L431
140,728
pkg/sftp
client.go
Open
func (c *Client) Open(path string) (*File, error) { return c.open(path, flags(os.O_RDONLY)) }
go
func (c *Client) Open(path string) (*File, error) { return c.open(path, flags(os.O_RDONLY)) }
[ "func", "(", "c", "*", "Client", ")", "Open", "(", "path", "string", ")", "(", "*", "File", ",", "error", ")", "{", "return", "c", ".", "open", "(", "path", ",", "flags", "(", "os", ".", "O_RDONLY", ")", ")", "\n", "}" ]
// Open opens the named file for reading. If successful, methods on the // returned file can be used for reading; the associated file descriptor // has mode O_RDONLY.
[ "Open", "opens", "the", "named", "file", "for", "reading", ".", "If", "successful", "methods", "on", "the", "returned", "file", "can", "be", "used", "for", "reading", ";", "the", "associated", "file", "descriptor", "has", "mode", "O_RDONLY", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L436-L438
140,729
pkg/sftp
client.go
close
func (c *Client) close(handle string) error { id := c.nextID() typ, data, err := c.sendPacket(sshFxpClosePacket{ ID: id, Handle: handle, }) if err != nil { return err } switch typ { case ssh_FXP_STATUS: return normaliseError(unmarshalStatus(id, data)) default: return unimplementedPacketErr(typ) }...
go
func (c *Client) close(handle string) error { id := c.nextID() typ, data, err := c.sendPacket(sshFxpClosePacket{ ID: id, Handle: handle, }) if err != nil { return err } switch typ { case ssh_FXP_STATUS: return normaliseError(unmarshalStatus(id, data)) default: return unimplementedPacketErr(typ) }...
[ "func", "(", "c", "*", "Client", ")", "close", "(", "handle", "string", ")", "error", "{", "id", ":=", "c", ".", "nextID", "(", ")", "\n", "typ", ",", "data", ",", "err", ":=", "c", ".", "sendPacket", "(", "sshFxpClosePacket", "{", "ID", ":", "id...
// close closes a handle handle previously returned in the response // to SSH_FXP_OPEN or SSH_FXP_OPENDIR. The handle becomes invalid // immediately after this request has been sent.
[ "close", "closes", "a", "handle", "handle", "previously", "returned", "in", "the", "response", "to", "SSH_FXP_OPEN", "or", "SSH_FXP_OPENDIR", ".", "The", "handle", "becomes", "invalid", "immediately", "after", "this", "request", "has", "been", "sent", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L475-L490
140,730
pkg/sftp
client.go
StatVFS
func (c *Client) StatVFS(path string) (*StatVFS, error) { // send the StatVFS packet to the server id := c.nextID() typ, data, err := c.sendPacket(sshFxpStatvfsPacket{ ID: id, Path: path, }) if err != nil { return nil, err } switch typ { // server responded with valid data case ssh_FXP_EXTENDED_REPLY:...
go
func (c *Client) StatVFS(path string) (*StatVFS, error) { // send the StatVFS packet to the server id := c.nextID() typ, data, err := c.sendPacket(sshFxpStatvfsPacket{ ID: id, Path: path, }) if err != nil { return nil, err } switch typ { // server responded with valid data case ssh_FXP_EXTENDED_REPLY:...
[ "func", "(", "c", "*", "Client", ")", "StatVFS", "(", "path", "string", ")", "(", "*", "StatVFS", ",", "error", ")", "{", "// send the StatVFS packet to the server", "id", ":=", "c", ".", "nextID", "(", ")", "\n", "typ", ",", "data", ",", "err", ":=", ...
// StatVFS retrieves VFS statistics from a remote host. // // It implements the statvfs@openssh.com SSH_FXP_EXTENDED feature // from http://www.opensource.apple.com/source/OpenSSH/OpenSSH-175/openssh/PROTOCOL?txt.
[ "StatVFS", "retrieves", "VFS", "statistics", "from", "a", "remote", "host", ".", "It", "implements", "the", "statvfs" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L520-L549
140,731
pkg/sftp
client.go
Remove
func (c *Client) Remove(path string) error { err := c.removeFile(path) if err, ok := err.(*StatusError); ok { switch err.Code { // some servers, *cough* osx *cough*, return EPERM, not ENODIR. // serv-u returns ssh_FX_FILE_IS_A_DIRECTORY case ssh_FX_PERMISSION_DENIED, ssh_FX_FAILURE, ssh_FX_FILE_IS_A_DIRECTORY...
go
func (c *Client) Remove(path string) error { err := c.removeFile(path) if err, ok := err.(*StatusError); ok { switch err.Code { // some servers, *cough* osx *cough*, return EPERM, not ENODIR. // serv-u returns ssh_FX_FILE_IS_A_DIRECTORY case ssh_FX_PERMISSION_DENIED, ssh_FX_FAILURE, ssh_FX_FILE_IS_A_DIRECTORY...
[ "func", "(", "c", "*", "Client", ")", "Remove", "(", "path", "string", ")", "error", "{", "err", ":=", "c", ".", "removeFile", "(", "path", ")", "\n", "if", "err", ",", "ok", ":=", "err", ".", "(", "*", "StatusError", ")", ";", "ok", "{", "swit...
// Remove removes the specified file or directory. An error will be returned if no // file or directory with the specified path exists, or if the specified directory // is not empty.
[ "Remove", "removes", "the", "specified", "file", "or", "directory", ".", "An", "error", "will", "be", "returned", "if", "no", "file", "or", "directory", "with", "the", "specified", "path", "exists", "or", "if", "the", "specified", "directory", "is", "not", ...
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L559-L570
140,732
pkg/sftp
client.go
Rename
func (c *Client) Rename(oldname, newname string) error { id := c.nextID() typ, data, err := c.sendPacket(sshFxpRenamePacket{ ID: id, Oldpath: oldname, Newpath: newname, }) if err != nil { return err } switch typ { case ssh_FXP_STATUS: return normaliseError(unmarshalStatus(id, data)) default: re...
go
func (c *Client) Rename(oldname, newname string) error { id := c.nextID() typ, data, err := c.sendPacket(sshFxpRenamePacket{ ID: id, Oldpath: oldname, Newpath: newname, }) if err != nil { return err } switch typ { case ssh_FXP_STATUS: return normaliseError(unmarshalStatus(id, data)) default: re...
[ "func", "(", "c", "*", "Client", ")", "Rename", "(", "oldname", ",", "newname", "string", ")", "error", "{", "id", ":=", "c", ".", "nextID", "(", ")", "\n", "typ", ",", "data", ",", "err", ":=", "c", ".", "sendPacket", "(", "sshFxpRenamePacket", "{...
// Rename renames a file.
[ "Rename", "renames", "a", "file", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L608-L624
140,733
pkg/sftp
client.go
MkdirAll
func (c *Client) MkdirAll(path string) error { // Most of this code mimics https://golang.org/src/os/path.go?s=514:561#L13 // Fast path: if we can tell whether path is a directory or file, stop with success or error. dir, err := c.Stat(path) if err == nil { if dir.IsDir() { return nil } return &os.PathErro...
go
func (c *Client) MkdirAll(path string) error { // Most of this code mimics https://golang.org/src/os/path.go?s=514:561#L13 // Fast path: if we can tell whether path is a directory or file, stop with success or error. dir, err := c.Stat(path) if err == nil { if dir.IsDir() { return nil } return &os.PathErro...
[ "func", "(", "c", "*", "Client", ")", "MkdirAll", "(", "path", "string", ")", "error", "{", "// Most of this code mimics https://golang.org/src/os/path.go?s=514:561#L13", "// Fast path: if we can tell whether path is a directory or file, stop with success or error.", "dir", ",", "e...
// MkdirAll creates a directory named path, along with any necessary parents, // and returns nil, or else returns an error. // If path is already a directory, MkdirAll does nothing and returns nil. // If path contains a regular file, an error is returned
[ "MkdirAll", "creates", "a", "directory", "named", "path", "along", "with", "any", "necessary", "parents", "and", "returns", "nil", "or", "else", "returns", "an", "error", ".", "If", "path", "is", "already", "a", "directory", "MkdirAll", "does", "nothing", "a...
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L704-L746
140,734
pkg/sftp
client.go
applyOptions
func (c *Client) applyOptions(opts ...ClientOption) error { for _, f := range opts { if err := f(c); err != nil { return err } } return nil }
go
func (c *Client) applyOptions(opts ...ClientOption) error { for _, f := range opts { if err := f(c); err != nil { return err } } return nil }
[ "func", "(", "c", "*", "Client", ")", "applyOptions", "(", "opts", "...", "ClientOption", ")", "error", "{", "for", "_", ",", "f", ":=", "range", "opts", "{", "if", "err", ":=", "f", "(", "c", ")", ";", "err", "!=", "nil", "{", "return", "err", ...
// applyOptions applies options functions to the Client. // If an error is encountered, option processing ceases.
[ "applyOptions", "applies", "options", "functions", "to", "the", "Client", ".", "If", "an", "error", "is", "encountered", "option", "processing", "ceases", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L750-L757
140,735
pkg/sftp
client.go
Stat
func (f *File) Stat() (os.FileInfo, error) { fs, err := f.c.fstat(f.handle) if err != nil { return nil, err } return fileInfoFromStat(fs, path.Base(f.path)), nil }
go
func (f *File) Stat() (os.FileInfo, error) { fs, err := f.c.fstat(f.handle) if err != nil { return nil, err } return fileInfoFromStat(fs, path.Base(f.path)), nil }
[ "func", "(", "f", "*", "File", ")", "Stat", "(", ")", "(", "os", ".", "FileInfo", ",", "error", ")", "{", "fs", ",", "err", ":=", "f", ".", "c", ".", "fstat", "(", "f", ".", "handle", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil...
// Stat returns the FileInfo structure describing file. If there is an // error.
[ "Stat", "returns", "the", "FileInfo", "structure", "describing", "file", ".", "If", "there", "is", "an", "error", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L1020-L1026
140,736
pkg/sftp
client.go
Seek
func (f *File) Seek(offset int64, whence int) (int64, error) { switch whence { case io.SeekStart: f.offset = uint64(offset) case io.SeekCurrent: f.offset = uint64(int64(f.offset) + offset) case io.SeekEnd: fi, err := f.Stat() if err != nil { return int64(f.offset), err } f.offset = uint64(fi.Size() +...
go
func (f *File) Seek(offset int64, whence int) (int64, error) { switch whence { case io.SeekStart: f.offset = uint64(offset) case io.SeekCurrent: f.offset = uint64(int64(f.offset) + offset) case io.SeekEnd: fi, err := f.Stat() if err != nil { return int64(f.offset), err } f.offset = uint64(fi.Size() +...
[ "func", "(", "f", "*", "File", ")", "Seek", "(", "offset", "int64", ",", "whence", "int", ")", "(", "int64", ",", "error", ")", "{", "switch", "whence", "{", "case", "io", ".", "SeekStart", ":", "f", ".", "offset", "=", "uint64", "(", "offset", "...
// Seek implements io.Seeker by setting the client offset for the next Read or // Write. It returns the next offset read. Seeking before or after the end of // the file is undefined. Seeking relative to the end calls Stat.
[ "Seek", "implements", "io", ".", "Seeker", "by", "setting", "the", "client", "offset", "for", "the", "next", "Read", "or", "Write", ".", "It", "returns", "the", "next", "offset", "read", ".", "Seeking", "before", "or", "after", "the", "end", "of", "the",...
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L1172-L1188
140,737
pkg/sftp
client.go
Chmod
func (f *File) Chmod(mode os.FileMode) error { return f.c.Chmod(f.path, mode) }
go
func (f *File) Chmod(mode os.FileMode) error { return f.c.Chmod(f.path, mode) }
[ "func", "(", "f", "*", "File", ")", "Chmod", "(", "mode", "os", ".", "FileMode", ")", "error", "{", "return", "f", ".", "c", ".", "Chmod", "(", "f", ".", "path", ",", "mode", ")", "\n", "}" ]
// Chmod changes the permissions of the current file.
[ "Chmod", "changes", "the", "permissions", "of", "the", "current", "file", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L1196-L1198
140,738
pkg/sftp
client.go
Truncate
func (f *File) Truncate(size int64) error { return f.c.Truncate(f.path, size) }
go
func (f *File) Truncate(size int64) error { return f.c.Truncate(f.path, size) }
[ "func", "(", "f", "*", "File", ")", "Truncate", "(", "size", "int64", ")", "error", "{", "return", "f", ".", "c", ".", "Truncate", "(", "f", ".", "path", ",", "size", ")", "\n", "}" ]
// Truncate sets the size of the current file. Although it may be safely assumed // that if the size is less than its current size it will be truncated to fit, // the SFTP protocol does not specify what behavior the server should do when setting // size greater than the current size.
[ "Truncate", "sets", "the", "size", "of", "the", "current", "file", ".", "Although", "it", "may", "be", "safely", "assumed", "that", "if", "the", "size", "is", "less", "than", "its", "current", "size", "it", "will", "be", "truncated", "to", "fit", "the", ...
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L1204-L1206
140,739
pkg/sftp
client.go
normaliseError
func normaliseError(err error) error { switch err := err.(type) { case *StatusError: switch err.Code { case ssh_FX_EOF: return io.EOF case ssh_FX_NO_SUCH_FILE: return os.ErrNotExist case ssh_FX_OK: return nil default: return err } default: return err } }
go
func normaliseError(err error) error { switch err := err.(type) { case *StatusError: switch err.Code { case ssh_FX_EOF: return io.EOF case ssh_FX_NO_SUCH_FILE: return os.ErrNotExist case ssh_FX_OK: return nil default: return err } default: return err } }
[ "func", "normaliseError", "(", "err", "error", ")", "error", "{", "switch", "err", ":=", "err", ".", "(", "type", ")", "{", "case", "*", "StatusError", ":", "switch", "err", ".", "Code", "{", "case", "ssh_FX_EOF", ":", "return", "io", ".", "EOF", "\n...
// normaliseError normalises an error into a more standard form that can be // checked against stdlib errors like io.EOF or os.ErrNotExist.
[ "normaliseError", "normalises", "an", "error", "into", "a", "more", "standard", "form", "that", "can", "be", "checked", "against", "stdlib", "errors", "like", "io", ".", "EOF", "or", "os", ".", "ErrNotExist", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L1217-L1233
140,740
pkg/sftp
client.go
flags
func flags(f int) uint32 { var out uint32 switch f & os.O_WRONLY { case os.O_WRONLY: out |= ssh_FXF_WRITE case os.O_RDONLY: out |= ssh_FXF_READ } if f&os.O_RDWR == os.O_RDWR { out |= ssh_FXF_READ | ssh_FXF_WRITE } if f&os.O_APPEND == os.O_APPEND { out |= ssh_FXF_APPEND } if f&os.O_CREATE == os.O_CREAT...
go
func flags(f int) uint32 { var out uint32 switch f & os.O_WRONLY { case os.O_WRONLY: out |= ssh_FXF_WRITE case os.O_RDONLY: out |= ssh_FXF_READ } if f&os.O_RDWR == os.O_RDWR { out |= ssh_FXF_READ | ssh_FXF_WRITE } if f&os.O_APPEND == os.O_APPEND { out |= ssh_FXF_APPEND } if f&os.O_CREATE == os.O_CREAT...
[ "func", "flags", "(", "f", "int", ")", "uint32", "{", "var", "out", "uint32", "\n", "switch", "f", "&", "os", ".", "O_WRONLY", "{", "case", "os", ".", "O_WRONLY", ":", "out", "|=", "ssh_FXF_WRITE", "\n", "case", "os", ".", "O_RDONLY", ":", "out", "...
// flags converts the flags passed to OpenFile into ssh flags. // Unsupported flags are ignored.
[ "flags", "converts", "the", "flags", "passed", "to", "OpenFile", "into", "ssh", "flags", ".", "Unsupported", "flags", "are", "ignored", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/client.go#L1259-L1283
140,741
pkg/sftp
attrs.go
toFileMode
func toFileMode(mode uint32) os.FileMode { var fm = os.FileMode(mode & 0777) switch mode & syscall.S_IFMT { case syscall.S_IFBLK: fm |= os.ModeDevice case syscall.S_IFCHR: fm |= os.ModeDevice | os.ModeCharDevice case syscall.S_IFDIR: fm |= os.ModeDir case syscall.S_IFIFO: fm |= os.ModeNamedPipe case sysc...
go
func toFileMode(mode uint32) os.FileMode { var fm = os.FileMode(mode & 0777) switch mode & syscall.S_IFMT { case syscall.S_IFBLK: fm |= os.ModeDevice case syscall.S_IFCHR: fm |= os.ModeDevice | os.ModeCharDevice case syscall.S_IFDIR: fm |= os.ModeDir case syscall.S_IFIFO: fm |= os.ModeNamedPipe case sysc...
[ "func", "toFileMode", "(", "mode", "uint32", ")", "os", ".", "FileMode", "{", "var", "fm", "=", "os", ".", "FileMode", "(", "mode", "&", "0777", ")", "\n", "switch", "mode", "&", "syscall", ".", "S_IFMT", "{", "case", "syscall", ".", "S_IFBLK", ":", ...
// toFileMode converts sftp filemode bits to the os.FileMode specification
[ "toFileMode", "converts", "sftp", "filemode", "bits", "to", "the", "os", ".", "FileMode", "specification" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/attrs.go#L174-L202
140,742
pkg/sftp
attrs.go
fromFileMode
func fromFileMode(mode os.FileMode) uint32 { ret := uint32(0) if mode&os.ModeDevice != 0 { if mode&os.ModeCharDevice != 0 { ret |= syscall.S_IFCHR } else { ret |= syscall.S_IFBLK } } if mode&os.ModeDir != 0 { ret |= syscall.S_IFDIR } if mode&os.ModeSymlink != 0 { ret |= syscall.S_IFLNK } if mod...
go
func fromFileMode(mode os.FileMode) uint32 { ret := uint32(0) if mode&os.ModeDevice != 0 { if mode&os.ModeCharDevice != 0 { ret |= syscall.S_IFCHR } else { ret |= syscall.S_IFBLK } } if mode&os.ModeDir != 0 { ret |= syscall.S_IFDIR } if mode&os.ModeSymlink != 0 { ret |= syscall.S_IFLNK } if mod...
[ "func", "fromFileMode", "(", "mode", "os", ".", "FileMode", ")", "uint32", "{", "ret", ":=", "uint32", "(", "0", ")", "\n\n", "if", "mode", "&", "os", ".", "ModeDevice", "!=", "0", "{", "if", "mode", "&", "os", ".", "ModeCharDevice", "!=", "0", "{"...
// fromFileMode converts from the os.FileMode specification to sftp filemode bits
[ "fromFileMode", "converts", "from", "the", "os", ".", "FileMode", "specification", "to", "sftp", "filemode", "bits" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/attrs.go#L205-L243
140,743
pkg/sftp
server.go
WithDebug
func WithDebug(w io.Writer) ServerOption { return func(s *Server) error { s.debugStream = w return nil } }
go
func WithDebug(w io.Writer) ServerOption { return func(s *Server) error { s.debugStream = w return nil } }
[ "func", "WithDebug", "(", "w", "io", ".", "Writer", ")", "ServerOption", "{", "return", "func", "(", "s", "*", "Server", ")", "error", "{", "s", ".", "debugStream", "=", "w", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// WithDebug enables Server debugging output to the supplied io.Writer.
[ "WithDebug", "enables", "Server", "debugging", "output", "to", "the", "supplied", "io", ".", "Writer", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/server.go#L105-L110
140,744
pkg/sftp
server.go
sftpServerWorker
func (svr *Server) sftpServerWorker(pktChan chan orderedRequest) error { for pkt := range pktChan { // readonly checks readonly := true switch pkt := pkt.requestPacket.(type) { case notReadOnly: readonly = false case *sshFxpOpenPacket: readonly = pkt.readonly() case *sshFxpExtendedPacket: readonly...
go
func (svr *Server) sftpServerWorker(pktChan chan orderedRequest) error { for pkt := range pktChan { // readonly checks readonly := true switch pkt := pkt.requestPacket.(type) { case notReadOnly: readonly = false case *sshFxpOpenPacket: readonly = pkt.readonly() case *sshFxpExtendedPacket: readonly...
[ "func", "(", "svr", "*", "Server", ")", "sftpServerWorker", "(", "pktChan", "chan", "orderedRequest", ")", "error", "{", "for", "pkt", ":=", "range", "pktChan", "{", "// readonly checks", "readonly", ":=", "true", "\n", "switch", "pkt", ":=", "pkt", ".", "...
// Up to N parallel servers
[ "Up", "to", "N", "parallel", "servers" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/server.go#L126-L153
140,745
pkg/sftp
server.go
Serve
func (svr *Server) Serve() error { var wg sync.WaitGroup runWorker := func(ch chan orderedRequest) { wg.Add(1) go func() { defer wg.Done() if err := svr.sftpServerWorker(ch); err != nil { svr.conn.Close() // shuts down recvPacket } }() } pktChan := svr.pktMgr.workerChan(runWorker) var err error...
go
func (svr *Server) Serve() error { var wg sync.WaitGroup runWorker := func(ch chan orderedRequest) { wg.Add(1) go func() { defer wg.Done() if err := svr.sftpServerWorker(ch); err != nil { svr.conn.Close() // shuts down recvPacket } }() } pktChan := svr.pktMgr.workerChan(runWorker) var err error...
[ "func", "(", "svr", "*", "Server", ")", "Serve", "(", ")", "error", "{", "var", "wg", "sync", ".", "WaitGroup", "\n", "runWorker", ":=", "func", "(", "ch", "chan", "orderedRequest", ")", "{", "wg", ".", "Add", "(", "1", ")", "\n", "go", "func", "...
// Serve serves SFTP connections until the streams stop or the SFTP subsystem // is stopped.
[ "Serve", "serves", "SFTP", "connections", "until", "the", "streams", "stop", "or", "the", "SFTP", "subsystem", "is", "stopped", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/server.go#L291-L342
140,746
pkg/sftp
server.go
translateErrno
func translateErrno(errno syscall.Errno) uint32 { switch errno { case 0: return ssh_FX_OK case syscall.ENOENT: return ssh_FX_NO_SUCH_FILE case syscall.EPERM: return ssh_FX_PERMISSION_DENIED } return ssh_FX_FAILURE }
go
func translateErrno(errno syscall.Errno) uint32 { switch errno { case 0: return ssh_FX_OK case syscall.ENOENT: return ssh_FX_NO_SUCH_FILE case syscall.EPERM: return ssh_FX_PERMISSION_DENIED } return ssh_FX_FAILURE }
[ "func", "translateErrno", "(", "errno", "syscall", ".", "Errno", ")", "uint32", "{", "switch", "errno", "{", "case", "0", ":", "return", "ssh_FX_OK", "\n", "case", "syscall", ".", "ENOENT", ":", "return", "ssh_FX_NO_SUCH_FILE", "\n", "case", "syscall", ".", ...
// translateErrno translates a syscall error number to a SFTP error code.
[ "translateErrno", "translates", "a", "syscall", "error", "number", "to", "a", "SFTP", "error", "code", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/server.go#L526-L537
140,747
pkg/sftp
match.go
Split
func Split(path string) (dir, file string) { i := len(path) - 1 for i >= 0 && !isPathSeparator(path[i]) { i-- } return path[:i+1], path[i+1:] }
go
func Split(path string) (dir, file string) { i := len(path) - 1 for i >= 0 && !isPathSeparator(path[i]) { i-- } return path[:i+1], path[i+1:] }
[ "func", "Split", "(", "path", "string", ")", "(", "dir", ",", "file", "string", ")", "{", "i", ":=", "len", "(", "path", ")", "-", "1", "\n", "for", "i", ">=", "0", "&&", "!", "isPathSeparator", "(", "path", "[", "i", "]", ")", "{", "i", "--"...
// Split splits path immediately following the final Separator, // separating it into a directory and file name component. // If there is no Separator in path, Split returns an empty dir // and file set to path. // The returned values have the property that path = dir+file.
[ "Split", "splits", "path", "immediately", "following", "the", "final", "Separator", "separating", "it", "into", "a", "directory", "and", "file", "name", "component", ".", "If", "there", "is", "no", "Separator", "in", "path", "Split", "returns", "an", "empty", ...
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/match.go#L186-L192
140,748
pkg/sftp
match.go
cleanGlobPath
func cleanGlobPath(path string) string { switch path { case "": return "." case string(separator): // do nothing to the path return path default: return path[0 : len(path)-1] // chop off trailing separator } }
go
func cleanGlobPath(path string) string { switch path { case "": return "." case string(separator): // do nothing to the path return path default: return path[0 : len(path)-1] // chop off trailing separator } }
[ "func", "cleanGlobPath", "(", "path", "string", ")", "string", "{", "switch", "path", "{", "case", "\"", "\"", ":", "return", "\"", "\"", "\n", "case", "string", "(", "separator", ")", ":", "// do nothing to the path", "return", "path", "\n", "default", ":...
// cleanGlobPath prepares path for glob matching.
[ "cleanGlobPath", "prepares", "path", "for", "glob", "matching", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/match.go#L240-L250
140,749
pkg/sftp
packet-typing.go
makePacket
func makePacket(p rxPacket) (requestPacket, error) { var pkt requestPacket switch p.pktType { case ssh_FXP_INIT: pkt = &sshFxInitPacket{} case ssh_FXP_LSTAT: pkt = &sshFxpLstatPacket{} case ssh_FXP_OPEN: pkt = &sshFxpOpenPacket{} case ssh_FXP_CLOSE: pkt = &sshFxpClosePacket{} case ssh_FXP_READ: pkt = &...
go
func makePacket(p rxPacket) (requestPacket, error) { var pkt requestPacket switch p.pktType { case ssh_FXP_INIT: pkt = &sshFxInitPacket{} case ssh_FXP_LSTAT: pkt = &sshFxpLstatPacket{} case ssh_FXP_OPEN: pkt = &sshFxpOpenPacket{} case ssh_FXP_CLOSE: pkt = &sshFxpClosePacket{} case ssh_FXP_READ: pkt = &...
[ "func", "makePacket", "(", "p", "rxPacket", ")", "(", "requestPacket", ",", "error", ")", "{", "var", "pkt", "requestPacket", "\n", "switch", "p", ".", "pktType", "{", "case", "ssh_FXP_INIT", ":", "pkt", "=", "&", "sshFxInitPacket", "{", "}", "\n", "case...
// take raw incoming packet data and build packet objects
[ "take", "raw", "incoming", "packet", "data", "and", "build", "packet", "objects" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/packet-typing.go#L82-L134
140,750
pkg/sftp
packet.go
sendPacket
func sendPacket(w io.Writer, m encoding.BinaryMarshaler) error { bb, err := m.MarshalBinary() if err != nil { return errors.Errorf("binary marshaller failed: %v", err) } if debugDumpTxPacketBytes { debug("send packet: %s %d bytes %x", fxp(bb[0]), len(bb), bb[1:]) } else if debugDumpTxPacket { debug("send pac...
go
func sendPacket(w io.Writer, m encoding.BinaryMarshaler) error { bb, err := m.MarshalBinary() if err != nil { return errors.Errorf("binary marshaller failed: %v", err) } if debugDumpTxPacketBytes { debug("send packet: %s %d bytes %x", fxp(bb[0]), len(bb), bb[1:]) } else if debugDumpTxPacket { debug("send pac...
[ "func", "sendPacket", "(", "w", "io", ".", "Writer", ",", "m", "encoding", ".", "BinaryMarshaler", ")", "error", "{", "bb", ",", "err", ":=", "m", ".", "MarshalBinary", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Errorf",...
// sendPacket marshals p according to RFC 4234.
[ "sendPacket", "marshals", "p", "according", "to", "RFC", "4234", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/packet.go#L118-L138
140,751
pkg/sftp
packet.go
MarshalBinary
func (p *StatVFS) MarshalBinary() ([]byte, error) { var buf bytes.Buffer buf.Write([]byte{ssh_FXP_EXTENDED_REPLY}) err := binary.Write(&buf, binary.BigEndian, p) return buf.Bytes(), err }
go
func (p *StatVFS) MarshalBinary() ([]byte, error) { var buf bytes.Buffer buf.Write([]byte{ssh_FXP_EXTENDED_REPLY}) err := binary.Write(&buf, binary.BigEndian, p) return buf.Bytes(), err }
[ "func", "(", "p", "*", "StatVFS", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "buf", ".", "Write", "(", "[", "]", "byte", "{", "ssh_FXP_EXTENDED_REPLY", "}", ")", "\n", ...
// Convert to ssh_FXP_EXTENDED_REPLY packet binary format
[ "Convert", "to", "ssh_FXP_EXTENDED_REPLY", "packet", "binary", "format" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/packet.go#L860-L865
140,752
pkg/sftp
packet-manager.go
readyPacket
func (s *packetManager) readyPacket(pkt orderedResponse) { s.responses <- pkt s.working.Done() }
go
func (s *packetManager) readyPacket(pkt orderedResponse) { s.responses <- pkt s.working.Done() }
[ "func", "(", "s", "*", "packetManager", ")", "readyPacket", "(", "pkt", "orderedResponse", ")", "{", "s", ".", "responses", "<-", "pkt", "\n", "s", ".", "working", ".", "Done", "(", ")", "\n", "}" ]
// register outgoing packets as being ready
[ "register", "outgoing", "packets", "as", "being", "ready" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/packet-manager.go#L90-L93
140,753
pkg/sftp
packet-manager.go
workerChan
func (s *packetManager) workerChan(runWorker func(chan orderedRequest), ) chan orderedRequest { // multiple workers for faster read/writes rwChan := make(chan orderedRequest, SftpServerWorkerCount) for i := 0; i < SftpServerWorkerCount; i++ { runWorker(rwChan) } // single worker to enforce sequential processin...
go
func (s *packetManager) workerChan(runWorker func(chan orderedRequest), ) chan orderedRequest { // multiple workers for faster read/writes rwChan := make(chan orderedRequest, SftpServerWorkerCount) for i := 0; i < SftpServerWorkerCount; i++ { runWorker(rwChan) } // single worker to enforce sequential processin...
[ "func", "(", "s", "*", "packetManager", ")", "workerChan", "(", "runWorker", "func", "(", "chan", "orderedRequest", ")", ",", ")", "chan", "orderedRequest", "{", "// multiple workers for faster read/writes", "rwChan", ":=", "make", "(", "chan", "orderedRequest", "...
// Passed a worker function, returns a channel for incoming packets. // Keep process packet responses in the order they are received while // maximizing throughput of file transfers.
[ "Passed", "a", "worker", "function", "returns", "a", "channel", "for", "incoming", "packets", ".", "Keep", "process", "packet", "responses", "in", "the", "order", "they", "are", "received", "while", "maximizing", "throughput", "of", "file", "transfers", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/packet-manager.go#L105-L141
140,754
pkg/sftp
packet-manager.go
maybeSendPackets
func (s *packetManager) maybeSendPackets() { for { if len(s.outgoing) == 0 || len(s.incoming) == 0 { debug("break! -- outgoing: %v; incoming: %v", len(s.outgoing), len(s.incoming)) break } out := s.outgoing[0] in := s.incoming[0] // debug("incoming: %v", ids(s.incoming)) // debug("outgoing: %v", ...
go
func (s *packetManager) maybeSendPackets() { for { if len(s.outgoing) == 0 || len(s.incoming) == 0 { debug("break! -- outgoing: %v; incoming: %v", len(s.outgoing), len(s.incoming)) break } out := s.outgoing[0] in := s.incoming[0] // debug("incoming: %v", ids(s.incoming)) // debug("outgoing: %v", ...
[ "func", "(", "s", "*", "packetManager", ")", "maybeSendPackets", "(", ")", "{", "for", "{", "if", "len", "(", "s", ".", "outgoing", ")", "==", "0", "||", "len", "(", "s", ".", "incoming", ")", "==", "0", "{", "debug", "(", "\"", "\"", ",", "len...
// send as many packets as are ready
[ "send", "as", "many", "packets", "as", "are", "ready" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/packet-manager.go#L163-L188
140,755
pkg/sftp
conn.go
Close
func (c *clientConn) Close() error { defer c.wg.Wait() return c.conn.Close() }
go
func (c *clientConn) Close() error { defer c.wg.Wait() return c.conn.Close() }
[ "func", "(", "c", "*", "clientConn", ")", "Close", "(", ")", "error", "{", "defer", "c", ".", "wg", ".", "Wait", "(", ")", "\n", "return", "c", ".", "conn", ".", "Close", "(", ")", "\n", "}" ]
// Close closes the SFTP session.
[ "Close", "closes", "the", "SFTP", "session", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/conn.go#L53-L56
140,756
pkg/sftp
conn.go
recv
func (c *clientConn) recv() error { defer func() { c.conn.Lock() c.conn.Close() c.conn.Unlock() }() for { typ, data, err := c.recvPacket() if err != nil { return err } sid, _ := unmarshalUint32(data) c.Lock() ch, ok := c.inflight[sid] delete(c.inflight, sid) c.Unlock() if !ok { // This ...
go
func (c *clientConn) recv() error { defer func() { c.conn.Lock() c.conn.Close() c.conn.Unlock() }() for { typ, data, err := c.recvPacket() if err != nil { return err } sid, _ := unmarshalUint32(data) c.Lock() ch, ok := c.inflight[sid] delete(c.inflight, sid) c.Unlock() if !ok { // This ...
[ "func", "(", "c", "*", "clientConn", ")", "recv", "(", ")", "error", "{", "defer", "func", "(", ")", "{", "c", ".", "conn", ".", "Lock", "(", ")", "\n", "c", ".", "conn", ".", "Close", "(", ")", "\n", "c", ".", "conn", ".", "Unlock", "(", "...
// recv continuously reads from the server and forwards responses to the // appropriate channel.
[ "recv", "continuously", "reads", "from", "the", "server", "and", "forwards", "responses", "to", "the", "appropriate", "channel", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/conn.go#L68-L92
140,757
pkg/sftp
conn.go
broadcastErr
func (c *clientConn) broadcastErr(err error) { c.Lock() listeners := make([]chan<- result, 0, len(c.inflight)) for _, ch := range c.inflight { listeners = append(listeners, ch) } c.Unlock() for _, ch := range listeners { ch <- result{err: err} } c.err = err close(c.closed) }
go
func (c *clientConn) broadcastErr(err error) { c.Lock() listeners := make([]chan<- result, 0, len(c.inflight)) for _, ch := range c.inflight { listeners = append(listeners, ch) } c.Unlock() for _, ch := range listeners { ch <- result{err: err} } c.err = err close(c.closed) }
[ "func", "(", "c", "*", "clientConn", ")", "broadcastErr", "(", "err", "error", ")", "{", "c", ".", "Lock", "(", ")", "\n", "listeners", ":=", "make", "(", "[", "]", "chan", "<-", "result", ",", "0", ",", "len", "(", "c", ".", "inflight", ")", "...
// broadcastErr sends an error to all goroutines waiting for a response.
[ "broadcastErr", "sends", "an", "error", "to", "all", "goroutines", "waiting", "for", "a", "response", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/conn.go#L126-L138
140,758
pkg/sftp
request-server.go
closeRequest
func (rs *RequestServer) closeRequest(handle string) error { rs.openRequestLock.Lock() defer rs.openRequestLock.Unlock() if r, ok := rs.openRequests[handle]; ok { delete(rs.openRequests, handle) return r.close() } return syscall.EBADF }
go
func (rs *RequestServer) closeRequest(handle string) error { rs.openRequestLock.Lock() defer rs.openRequestLock.Unlock() if r, ok := rs.openRequests[handle]; ok { delete(rs.openRequests, handle) return r.close() } return syscall.EBADF }
[ "func", "(", "rs", "*", "RequestServer", ")", "closeRequest", "(", "handle", "string", ")", "error", "{", "rs", ".", "openRequestLock", ".", "Lock", "(", ")", "\n", "defer", "rs", ".", "openRequestLock", ".", "Unlock", "(", ")", "\n", "if", "r", ",", ...
// Close the Request and clear from openRequests map
[ "Close", "the", "Request", "and", "clear", "from", "openRequests", "map" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request-server.go#L76-L84
140,759
pkg/sftp
request-server.go
Serve
func (rs *RequestServer) Serve() error { ctx, cancel := context.WithCancel(context.Background()) defer cancel() var wg sync.WaitGroup runWorker := func(ch chan orderedRequest) { wg.Add(1) go func() { defer wg.Done() if err := rs.packetWorker(ctx, ch); err != nil { rs.conn.Close() // shuts down recvPac...
go
func (rs *RequestServer) Serve() error { ctx, cancel := context.WithCancel(context.Background()) defer cancel() var wg sync.WaitGroup runWorker := func(ch chan orderedRequest) { wg.Add(1) go func() { defer wg.Done() if err := rs.packetWorker(ctx, ch); err != nil { rs.conn.Close() // shuts down recvPac...
[ "func", "(", "rs", "*", "RequestServer", ")", "Serve", "(", ")", "error", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", "context", ".", "Background", "(", ")", ")", "\n", "defer", "cancel", "(", ")", "\n", "var", "wg", "sync", ...
// Serve requests for user session
[ "Serve", "requests", "for", "user", "session" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request-server.go#L90-L145
140,760
pkg/sftp
request-server.go
cleanPacketPath
func cleanPacketPath(pkt *sshFxpRealpathPacket) responsePacket { path := cleanPath(pkt.getPath()) return &sshFxpNamePacket{ ID: pkt.id(), NameAttrs: []sshFxpNameAttr{{ Name: path, LongName: path, Attrs: emptyFileStat, }}, } }
go
func cleanPacketPath(pkt *sshFxpRealpathPacket) responsePacket { path := cleanPath(pkt.getPath()) return &sshFxpNamePacket{ ID: pkt.id(), NameAttrs: []sshFxpNameAttr{{ Name: path, LongName: path, Attrs: emptyFileStat, }}, } }
[ "func", "cleanPacketPath", "(", "pkt", "*", "sshFxpRealpathPacket", ")", "responsePacket", "{", "path", ":=", "cleanPath", "(", "pkt", ".", "getPath", "(", ")", ")", "\n", "return", "&", "sshFxpNamePacket", "{", "ID", ":", "pkt", ".", "id", "(", ")", ","...
// clean and return name packet for file
[ "clean", "and", "return", "name", "packet", "for", "file" ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request-server.go#L200-L210
140,761
pkg/sftp
request-attrs.go
Attributes
func (r *Request) Attributes() *FileStat { fs, _ := getFileStat(r.Flags, r.Attrs) return fs }
go
func (r *Request) Attributes() *FileStat { fs, _ := getFileStat(r.Flags, r.Attrs) return fs }
[ "func", "(", "r", "*", "Request", ")", "Attributes", "(", ")", "*", "FileStat", "{", "fs", ",", "_", ":=", "getFileStat", "(", "r", ".", "Flags", ",", "r", ".", "Attrs", ")", "\n", "return", "fs", "\n", "}" ]
// Attributres parses file attributes byte blob and return them in a // FileStat object.
[ "Attributres", "parses", "file", "attributes", "byte", "blob", "and", "return", "them", "in", "a", "FileStat", "object", "." ]
5bcd86d72480cb6de4bc5804f832e27855ba033f
https://github.com/pkg/sftp/blob/5bcd86d72480cb6de4bc5804f832e27855ba033f/request-attrs.go#L60-L63
140,762
shurcooL/graphql
ident/ident.go
ToMixedCaps
func (n Name) ToMixedCaps() string { for i, word := range n { if strings.EqualFold(word, "IDs") { // Special case, plural form of ID initialism. n[i] = "IDs" continue } if initialism, ok := isInitialism(word); ok { n[i] = initialism continue } if brand, ok := isBrand(word); ok { n[i] = brand ...
go
func (n Name) ToMixedCaps() string { for i, word := range n { if strings.EqualFold(word, "IDs") { // Special case, plural form of ID initialism. n[i] = "IDs" continue } if initialism, ok := isInitialism(word); ok { n[i] = initialism continue } if brand, ok := isBrand(word); ok { n[i] = brand ...
[ "func", "(", "n", "Name", ")", "ToMixedCaps", "(", ")", "string", "{", "for", "i", ",", "word", ":=", "range", "n", "{", "if", "strings", ".", "EqualFold", "(", "word", ",", "\"", "\"", ")", "{", "// Special case, plural form of ID initialism.", "n", "["...
// ToMixedCaps expresses identifer name in MixedCaps naming convention. // // E.g., "ClientMutationID".
[ "ToMixedCaps", "expresses", "identifer", "name", "in", "MixedCaps", "naming", "convention", ".", "E", ".", "g", ".", "ClientMutationID", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/ident/ident.go#L124-L142
140,763
shurcooL/graphql
ident/ident.go
ToLowerCamelCase
func (n Name) ToLowerCamelCase() string { for i, word := range n { if i == 0 { n[i] = strings.ToLower(word) continue } r, size := utf8.DecodeRuneInString(word) n[i] = string(unicode.ToUpper(r)) + strings.ToLower(word[size:]) } return strings.Join(n, "") }
go
func (n Name) ToLowerCamelCase() string { for i, word := range n { if i == 0 { n[i] = strings.ToLower(word) continue } r, size := utf8.DecodeRuneInString(word) n[i] = string(unicode.ToUpper(r)) + strings.ToLower(word[size:]) } return strings.Join(n, "") }
[ "func", "(", "n", "Name", ")", "ToLowerCamelCase", "(", ")", "string", "{", "for", "i", ",", "word", ":=", "range", "n", "{", "if", "i", "==", "0", "{", "n", "[", "i", "]", "=", "strings", ".", "ToLower", "(", "word", ")", "\n", "continue", "\n...
// ToLowerCamelCase expresses identifer name in lowerCamelCase naming convention. // // E.g., "clientMutationId".
[ "ToLowerCamelCase", "expresses", "identifer", "name", "in", "lowerCamelCase", "naming", "convention", ".", "E", ".", "g", ".", "clientMutationId", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/ident/ident.go#L147-L157
140,764
shurcooL/graphql
ident/ident.go
isInitialism
func isInitialism(word string) (string, bool) { initialism := strings.ToUpper(word) _, ok := initialisms[initialism] return initialism, ok }
go
func isInitialism(word string) (string, bool) { initialism := strings.ToUpper(word) _, ok := initialisms[initialism] return initialism, ok }
[ "func", "isInitialism", "(", "word", "string", ")", "(", "string", ",", "bool", ")", "{", "initialism", ":=", "strings", ".", "ToUpper", "(", "word", ")", "\n", "_", ",", "ok", ":=", "initialisms", "[", "initialism", "]", "\n", "return", "initialism", ...
// isInitialism reports whether word is an initialism.
[ "isInitialism", "reports", "whether", "word", "is", "an", "initialism", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/ident/ident.go#L160-L164
140,765
shurcooL/graphql
ident/ident.go
isTwoInitialisms
func isTwoInitialisms(word string) (string, string, bool) { word = strings.ToUpper(word) for i := 2; i <= len(word)-2; i++ { // Shortest initialism is 2 characters long. _, ok1 := initialisms[word[:i]] _, ok2 := initialisms[word[i:]] if ok1 && ok2 { return word[:i], word[i:], true } } return "", "", fals...
go
func isTwoInitialisms(word string) (string, string, bool) { word = strings.ToUpper(word) for i := 2; i <= len(word)-2; i++ { // Shortest initialism is 2 characters long. _, ok1 := initialisms[word[:i]] _, ok2 := initialisms[word[i:]] if ok1 && ok2 { return word[:i], word[i:], true } } return "", "", fals...
[ "func", "isTwoInitialisms", "(", "word", "string", ")", "(", "string", ",", "string", ",", "bool", ")", "{", "word", "=", "strings", ".", "ToUpper", "(", "word", ")", "\n", "for", "i", ":=", "2", ";", "i", "<=", "len", "(", "word", ")", "-", "2",...
// isTwoInitialisms reports whether word is two initialisms.
[ "isTwoInitialisms", "reports", "whether", "word", "is", "two", "initialisms", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/ident/ident.go#L167-L177
140,766
shurcooL/graphql
ident/ident.go
isBrand
func isBrand(word string) (string, bool) { brand, ok := brands[strings.ToLower(word)] return brand, ok }
go
func isBrand(word string) (string, bool) { brand, ok := brands[strings.ToLower(word)] return brand, ok }
[ "func", "isBrand", "(", "word", "string", ")", "(", "string", ",", "bool", ")", "{", "brand", ",", "ok", ":=", "brands", "[", "strings", ".", "ToLower", "(", "word", ")", "]", "\n", "return", "brand", ",", "ok", "\n", "}" ]
// isBrand reports whether word is a brand.
[ "isBrand", "reports", "whether", "word", "is", "a", "brand", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/ident/ident.go#L229-L232
140,767
shurcooL/graphql
query.go
writeQuery
func writeQuery(w io.Writer, t reflect.Type, inline bool) { switch t.Kind() { case reflect.Ptr, reflect.Slice: writeQuery(w, t.Elem(), false) case reflect.Struct: // If the type implements json.Unmarshaler, it's a scalar. Don't expand it. if reflect.PtrTo(t).Implements(jsonUnmarshaler) { return } if !in...
go
func writeQuery(w io.Writer, t reflect.Type, inline bool) { switch t.Kind() { case reflect.Ptr, reflect.Slice: writeQuery(w, t.Elem(), false) case reflect.Struct: // If the type implements json.Unmarshaler, it's a scalar. Don't expand it. if reflect.PtrTo(t).Implements(jsonUnmarshaler) { return } if !in...
[ "func", "writeQuery", "(", "w", "io", ".", "Writer", ",", "t", "reflect", ".", "Type", ",", "inline", "bool", ")", "{", "switch", "t", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Ptr", ",", "reflect", ".", "Slice", ":", "writeQuery", "(", ...
// writeQuery writes a minified query for t to w. // If inline is true, the struct fields of t are inlined into parent struct.
[ "writeQuery", "writes", "a", "minified", "query", "for", "t", "to", "w", ".", "If", "inline", "is", "true", "the", "struct", "fields", "of", "t", "are", "inlined", "into", "parent", "struct", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/query.go#L97-L129
140,768
shurcooL/graphql
graphql.go
NewClient
func NewClient(url string, httpClient *http.Client) *Client { if httpClient == nil { httpClient = http.DefaultClient } return &Client{ url: url, httpClient: httpClient, } }
go
func NewClient(url string, httpClient *http.Client) *Client { if httpClient == nil { httpClient = http.DefaultClient } return &Client{ url: url, httpClient: httpClient, } }
[ "func", "NewClient", "(", "url", "string", ",", "httpClient", "*", "http", ".", "Client", ")", "*", "Client", "{", "if", "httpClient", "==", "nil", "{", "httpClient", "=", "http", ".", "DefaultClient", "\n", "}", "\n", "return", "&", "Client", "{", "ur...
// NewClient creates a GraphQL client targeting the specified GraphQL server URL. // If httpClient is nil, then http.DefaultClient is used.
[ "NewClient", "creates", "a", "GraphQL", "client", "targeting", "the", "specified", "GraphQL", "server", "URL", ".", "If", "httpClient", "is", "nil", "then", "http", ".", "DefaultClient", "is", "used", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/graphql.go#L23-L31
140,769
shurcooL/graphql
graphql.go
Query
func (c *Client) Query(ctx context.Context, q interface{}, variables map[string]interface{}) error { return c.do(ctx, queryOperation, q, variables) }
go
func (c *Client) Query(ctx context.Context, q interface{}, variables map[string]interface{}) error { return c.do(ctx, queryOperation, q, variables) }
[ "func", "(", "c", "*", "Client", ")", "Query", "(", "ctx", "context", ".", "Context", ",", "q", "interface", "{", "}", ",", "variables", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "return", "c", ".", "do", "(", "ctx", ",...
// Query executes a single GraphQL query request, // with a query derived from q, populating the response into it. // q should be a pointer to struct that corresponds to the GraphQL schema.
[ "Query", "executes", "a", "single", "GraphQL", "query", "request", "with", "a", "query", "derived", "from", "q", "populating", "the", "response", "into", "it", ".", "q", "should", "be", "a", "pointer", "to", "struct", "that", "corresponds", "to", "the", "G...
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/graphql.go#L36-L38
140,770
shurcooL/graphql
graphql.go
Mutate
func (c *Client) Mutate(ctx context.Context, m interface{}, variables map[string]interface{}) error { return c.do(ctx, mutationOperation, m, variables) }
go
func (c *Client) Mutate(ctx context.Context, m interface{}, variables map[string]interface{}) error { return c.do(ctx, mutationOperation, m, variables) }
[ "func", "(", "c", "*", "Client", ")", "Mutate", "(", "ctx", "context", ".", "Context", ",", "m", "interface", "{", "}", ",", "variables", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "return", "c", ".", "do", "(", "ctx", "...
// Mutate executes a single GraphQL mutation request, // with a mutation derived from m, populating the response into it. // m should be a pointer to struct that corresponds to the GraphQL schema.
[ "Mutate", "executes", "a", "single", "GraphQL", "mutation", "request", "with", "a", "mutation", "derived", "from", "m", "populating", "the", "response", "into", "it", ".", "m", "should", "be", "a", "pointer", "to", "struct", "that", "corresponds", "to", "the...
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/graphql.go#L43-L45
140,771
shurcooL/graphql
graphql.go
do
func (c *Client) do(ctx context.Context, op operationType, v interface{}, variables map[string]interface{}) error { var query string switch op { case queryOperation: query = constructQuery(v, variables) case mutationOperation: query = constructMutation(v, variables) } in := struct { Query string ...
go
func (c *Client) do(ctx context.Context, op operationType, v interface{}, variables map[string]interface{}) error { var query string switch op { case queryOperation: query = constructQuery(v, variables) case mutationOperation: query = constructMutation(v, variables) } in := struct { Query string ...
[ "func", "(", "c", "*", "Client", ")", "do", "(", "ctx", "context", ".", "Context", ",", "op", "operationType", ",", "v", "interface", "{", "}", ",", "variables", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "var", "query", "...
// do executes a single GraphQL operation.
[ "do", "executes", "a", "single", "GraphQL", "operation", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/graphql.go#L48-L98
140,772
shurcooL/graphql
internal/jsonutil/graphql.go
Decode
func (d *decoder) Decode(v interface{}) error { rv := reflect.ValueOf(v) if rv.Kind() != reflect.Ptr { return fmt.Errorf("cannot decode into non-pointer %T", v) } d.vs = [][]reflect.Value{{rv.Elem()}} return d.decode() }
go
func (d *decoder) Decode(v interface{}) error { rv := reflect.ValueOf(v) if rv.Kind() != reflect.Ptr { return fmt.Errorf("cannot decode into non-pointer %T", v) } d.vs = [][]reflect.Value{{rv.Elem()}} return d.decode() }
[ "func", "(", "d", "*", "decoder", ")", "Decode", "(", "v", "interface", "{", "}", ")", "error", "{", "rv", ":=", "reflect", ".", "ValueOf", "(", "v", ")", "\n", "if", "rv", ".", "Kind", "(", ")", "!=", "reflect", ".", "Ptr", "{", "return", "fmt...
// Decode decodes a single JSON value from d.tokenizer into v.
[ "Decode", "decodes", "a", "single", "JSON", "value", "from", "d", ".", "tokenizer", "into", "v", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/internal/jsonutil/graphql.go#L60-L67
140,773
shurcooL/graphql
internal/jsonutil/graphql.go
pushState
func (d *decoder) pushState(s json.Delim) { d.parseState = append(d.parseState, s) }
go
func (d *decoder) pushState(s json.Delim) { d.parseState = append(d.parseState, s) }
[ "func", "(", "d", "*", "decoder", ")", "pushState", "(", "s", "json", ".", "Delim", ")", "{", "d", ".", "parseState", "=", "append", "(", "d", ".", "parseState", ",", "s", ")", "\n", "}" ]
// pushState pushes a new parse state s onto the stack.
[ "pushState", "pushes", "a", "new", "parse", "state", "s", "onto", "the", "stack", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/internal/jsonutil/graphql.go#L225-L227
140,774
shurcooL/graphql
internal/jsonutil/graphql.go
state
func (d *decoder) state() json.Delim { if len(d.parseState) == 0 { return 0 } return d.parseState[len(d.parseState)-1] }
go
func (d *decoder) state() json.Delim { if len(d.parseState) == 0 { return 0 } return d.parseState[len(d.parseState)-1] }
[ "func", "(", "d", "*", "decoder", ")", "state", "(", ")", "json", ".", "Delim", "{", "if", "len", "(", "d", ".", "parseState", ")", "==", "0", "{", "return", "0", "\n", "}", "\n", "return", "d", ".", "parseState", "[", "len", "(", "d", ".", "...
// state reports the parse state on top of stack, or 0 if empty.
[ "state", "reports", "the", "parse", "state", "on", "top", "of", "stack", "or", "0", "if", "empty", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/internal/jsonutil/graphql.go#L236-L241
140,775
shurcooL/graphql
internal/jsonutil/graphql.go
popAllVs
func (d *decoder) popAllVs() { var nonEmpty [][]reflect.Value for i := range d.vs { d.vs[i] = d.vs[i][:len(d.vs[i])-1] if len(d.vs[i]) > 0 { nonEmpty = append(nonEmpty, d.vs[i]) } } d.vs = nonEmpty }
go
func (d *decoder) popAllVs() { var nonEmpty [][]reflect.Value for i := range d.vs { d.vs[i] = d.vs[i][:len(d.vs[i])-1] if len(d.vs[i]) > 0 { nonEmpty = append(nonEmpty, d.vs[i]) } } d.vs = nonEmpty }
[ "func", "(", "d", "*", "decoder", ")", "popAllVs", "(", ")", "{", "var", "nonEmpty", "[", "]", "[", "]", "reflect", ".", "Value", "\n", "for", "i", ":=", "range", "d", ".", "vs", "{", "d", ".", "vs", "[", "i", "]", "=", "d", ".", "vs", "[",...
// popAllVs pops from all d.vs stacks, keeping only non-empty ones.
[ "popAllVs", "pops", "from", "all", "d", ".", "vs", "stacks", "keeping", "only", "non", "-", "empty", "ones", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/internal/jsonutil/graphql.go#L244-L253
140,776
shurcooL/graphql
internal/jsonutil/graphql.go
fieldByGraphQLName
func fieldByGraphQLName(v reflect.Value, name string) reflect.Value { for i := 0; i < v.NumField(); i++ { if v.Type().Field(i).PkgPath != "" { // Skip unexported field. continue } if hasGraphQLName(v.Type().Field(i), name) { return v.Field(i) } } return reflect.Value{} }
go
func fieldByGraphQLName(v reflect.Value, name string) reflect.Value { for i := 0; i < v.NumField(); i++ { if v.Type().Field(i).PkgPath != "" { // Skip unexported field. continue } if hasGraphQLName(v.Type().Field(i), name) { return v.Field(i) } } return reflect.Value{} }
[ "func", "fieldByGraphQLName", "(", "v", "reflect", ".", "Value", ",", "name", "string", ")", "reflect", ".", "Value", "{", "for", "i", ":=", "0", ";", "i", "<", "v", ".", "NumField", "(", ")", ";", "i", "++", "{", "if", "v", ".", "Type", "(", "...
// fieldByGraphQLName returns an exported struct field of struct v // that matches GraphQL name, or invalid reflect.Value if none found.
[ "fieldByGraphQLName", "returns", "an", "exported", "struct", "field", "of", "struct", "v", "that", "matches", "GraphQL", "name", "or", "invalid", "reflect", ".", "Value", "if", "none", "found", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/internal/jsonutil/graphql.go#L257-L268
140,777
shurcooL/graphql
internal/jsonutil/graphql.go
hasGraphQLName
func hasGraphQLName(f reflect.StructField, name string) bool { value, ok := f.Tag.Lookup("graphql") if !ok { // TODO: caseconv package is relatively slow. Optimize it, then consider using it here. //return caseconv.MixedCapsToLowerCamelCase(f.Name) == name return strings.EqualFold(f.Name, name) } value = stri...
go
func hasGraphQLName(f reflect.StructField, name string) bool { value, ok := f.Tag.Lookup("graphql") if !ok { // TODO: caseconv package is relatively slow. Optimize it, then consider using it here. //return caseconv.MixedCapsToLowerCamelCase(f.Name) == name return strings.EqualFold(f.Name, name) } value = stri...
[ "func", "hasGraphQLName", "(", "f", "reflect", ".", "StructField", ",", "name", "string", ")", "bool", "{", "value", ",", "ok", ":=", "f", ".", "Tag", ".", "Lookup", "(", "\"", "\"", ")", "\n", "if", "!", "ok", "{", "// TODO: caseconv package is relative...
// hasGraphQLName reports whether struct field f has GraphQL name.
[ "hasGraphQLName", "reports", "whether", "struct", "field", "f", "has", "GraphQL", "name", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/internal/jsonutil/graphql.go#L271-L290
140,778
shurcooL/graphql
internal/jsonutil/graphql.go
isGraphQLFragment
func isGraphQLFragment(f reflect.StructField) bool { value, ok := f.Tag.Lookup("graphql") if !ok { return false } value = strings.TrimSpace(value) // TODO: Parse better. return strings.HasPrefix(value, "...") }
go
func isGraphQLFragment(f reflect.StructField) bool { value, ok := f.Tag.Lookup("graphql") if !ok { return false } value = strings.TrimSpace(value) // TODO: Parse better. return strings.HasPrefix(value, "...") }
[ "func", "isGraphQLFragment", "(", "f", "reflect", ".", "StructField", ")", "bool", "{", "value", ",", "ok", ":=", "f", ".", "Tag", ".", "Lookup", "(", "\"", "\"", ")", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", "value", "=", ...
// isGraphQLFragment reports whether struct field f is a GraphQL fragment.
[ "isGraphQLFragment", "reports", "whether", "struct", "field", "f", "is", "a", "GraphQL", "fragment", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/internal/jsonutil/graphql.go#L293-L300
140,779
shurcooL/graphql
internal/jsonutil/graphql.go
unmarshalValue
func unmarshalValue(value json.Token, v reflect.Value) error { b, err := json.Marshal(value) // TODO: Short-circuit (if profiling says it's worth it). if err != nil { return err } return json.Unmarshal(b, v.Addr().Interface()) }
go
func unmarshalValue(value json.Token, v reflect.Value) error { b, err := json.Marshal(value) // TODO: Short-circuit (if profiling says it's worth it). if err != nil { return err } return json.Unmarshal(b, v.Addr().Interface()) }
[ "func", "unmarshalValue", "(", "value", "json", ".", "Token", ",", "v", "reflect", ".", "Value", ")", "error", "{", "b", ",", "err", ":=", "json", ".", "Marshal", "(", "value", ")", "// TODO: Short-circuit (if profiling says it's worth it).", "\n", "if", "err"...
// unmarshalValue unmarshals JSON value into v. // v must be addressable and not obtained by the use of unexported // struct fields, otherwise unmarshalValue will panic.
[ "unmarshalValue", "unmarshals", "JSON", "value", "into", "v", ".", "v", "must", "be", "addressable", "and", "not", "obtained", "by", "the", "use", "of", "unexported", "struct", "fields", "otherwise", "unmarshalValue", "will", "panic", "." ]
d48a9a75455f6af30244670bc0c9d0e38e7392b5
https://github.com/shurcooL/graphql/blob/d48a9a75455f6af30244670bc0c9d0e38e7392b5/internal/jsonutil/graphql.go#L305-L311
140,780
h2non/bimg
image.go
Resize
func (i *Image) Resize(width, height int) ([]byte, error) { options := Options{ Width: width, Height: height, Embed: true, } return i.Process(options) }
go
func (i *Image) Resize(width, height int) ([]byte, error) { options := Options{ Width: width, Height: height, Embed: true, } return i.Process(options) }
[ "func", "(", "i", "*", "Image", ")", "Resize", "(", "width", ",", "height", "int", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "options", ":=", "Options", "{", "Width", ":", "width", ",", "Height", ":", "height", ",", "Embed", ":", "true"...
// Resize resizes the image to fixed width and height.
[ "Resize", "resizes", "the", "image", "to", "fixed", "width", "and", "height", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/image.go#L14-L21
140,781
h2non/bimg
image.go
Crop
func (i *Image) Crop(width, height int, gravity Gravity) ([]byte, error) { options := Options{ Width: width, Height: height, Gravity: gravity, Crop: true, } return i.Process(options) }
go
func (i *Image) Crop(width, height int, gravity Gravity) ([]byte, error) { options := Options{ Width: width, Height: height, Gravity: gravity, Crop: true, } return i.Process(options) }
[ "func", "(", "i", "*", "Image", ")", "Crop", "(", "width", ",", "height", "int", ",", "gravity", "Gravity", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "options", ":=", "Options", "{", "Width", ":", "width", ",", "Height", ":", "height", ...
// Crop crops the image to the exact size specified.
[ "Crop", "crops", "the", "image", "to", "the", "exact", "size", "specified", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/image.go#L93-L101
140,782
h2non/bimg
image.go
Watermark
func (i *Image) Watermark(w Watermark) ([]byte, error) { options := Options{Watermark: w} return i.Process(options) }
go
func (i *Image) Watermark(w Watermark) ([]byte, error) { options := Options{Watermark: w} return i.Process(options) }
[ "func", "(", "i", "*", "Image", ")", "Watermark", "(", "w", "Watermark", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "options", ":=", "Options", "{", "Watermark", ":", "w", "}", "\n", "return", "i", ".", "Process", "(", "options", ")", "\...
// Watermark adds text as watermark on the given image.
[ "Watermark", "adds", "text", "as", "watermark", "on", "the", "given", "image", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/image.go#L133-L136
140,783
h2non/bimg
image.go
WatermarkImage
func (i *Image) WatermarkImage(w WatermarkImage) ([]byte, error) { options := Options{WatermarkImage: w} return i.Process(options) }
go
func (i *Image) WatermarkImage(w WatermarkImage) ([]byte, error) { options := Options{WatermarkImage: w} return i.Process(options) }
[ "func", "(", "i", "*", "Image", ")", "WatermarkImage", "(", "w", "WatermarkImage", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "options", ":=", "Options", "{", "WatermarkImage", ":", "w", "}", "\n", "return", "i", ".", "Process", "(", "option...
// WatermarkImage adds image as watermark on the given image.
[ "WatermarkImage", "adds", "image", "as", "watermark", "on", "the", "given", "image", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/image.go#L139-L142
140,784
h2non/bimg
image.go
Flip
func (i *Image) Flip() ([]byte, error) { options := Options{Flip: true} return i.Process(options) }
go
func (i *Image) Flip() ([]byte, error) { options := Options{Flip: true} return i.Process(options) }
[ "func", "(", "i", "*", "Image", ")", "Flip", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "options", ":=", "Options", "{", "Flip", ":", "true", "}", "\n", "return", "i", ".", "Process", "(", "options", ")", "\n", "}" ]
// Flip flips the image about the vertical Y axis.
[ "Flip", "flips", "the", "image", "about", "the", "vertical", "Y", "axis", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/image.go#L158-L161
140,785
h2non/bimg
image.go
Convert
func (i *Image) Convert(t ImageType) ([]byte, error) { options := Options{Type: t} return i.Process(options) }
go
func (i *Image) Convert(t ImageType) ([]byte, error) { options := Options{Type: t} return i.Process(options) }
[ "func", "(", "i", "*", "Image", ")", "Convert", "(", "t", "ImageType", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "options", ":=", "Options", "{", "Type", ":", "t", "}", "\n", "return", "i", ".", "Process", "(", "options", ")", "\n", "...
// Convert converts image to another format.
[ "Convert", "converts", "image", "to", "another", "format", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/image.go#L170-L173
140,786
h2non/bimg
image.go
Colourspace
func (i *Image) Colourspace(c Interpretation) ([]byte, error) { options := Options{Interpretation: c} return i.Process(options) }
go
func (i *Image) Colourspace(c Interpretation) ([]byte, error) { options := Options{Interpretation: c} return i.Process(options) }
[ "func", "(", "i", "*", "Image", ")", "Colourspace", "(", "c", "Interpretation", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "options", ":=", "Options", "{", "Interpretation", ":", "c", "}", "\n", "return", "i", ".", "Process", "(", "options",...
// Colourspace performs a color space conversion bsaed on the given interpretation.
[ "Colourspace", "performs", "a", "color", "space", "conversion", "bsaed", "on", "the", "given", "interpretation", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/image.go#L176-L179
140,787
h2non/bimg
image.go
Process
func (i *Image) Process(o Options) ([]byte, error) { image, err := Resize(i.buffer, o) if err != nil { return nil, err } i.buffer = image return image, nil }
go
func (i *Image) Process(o Options) ([]byte, error) { image, err := Resize(i.buffer, o) if err != nil { return nil, err } i.buffer = image return image, nil }
[ "func", "(", "i", "*", "Image", ")", "Process", "(", "o", "Options", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "image", ",", "err", ":=", "Resize", "(", "i", ".", "buffer", ",", "o", ")", "\n", "if", "err", "!=", "nil", "{", "return...
// Process processes the image based on the given transformation options, // talking with libvips bindings accordingly and returning the resultant // image buffer.
[ "Process", "processes", "the", "image", "based", "on", "the", "given", "transformation", "options", "talking", "with", "libvips", "bindings", "accordingly", "and", "returning", "the", "resultant", "image", "buffer", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/image.go#L191-L198
140,788
h2non/bimg
metadata.go
Size
func Size(buf []byte) (ImageSize, error) { metadata, err := Metadata(buf) if err != nil { return ImageSize{}, err } return ImageSize{ Width: int(metadata.Size.Width), Height: int(metadata.Size.Height), }, nil }
go
func Size(buf []byte) (ImageSize, error) { metadata, err := Metadata(buf) if err != nil { return ImageSize{}, err } return ImageSize{ Width: int(metadata.Size.Width), Height: int(metadata.Size.Height), }, nil }
[ "func", "Size", "(", "buf", "[", "]", "byte", ")", "(", "ImageSize", ",", "error", ")", "{", "metadata", ",", "err", ":=", "Metadata", "(", "buf", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ImageSize", "{", "}", ",", "err", "\n", "}", ...
// Size returns the image size by width and height pixels.
[ "Size", "returns", "the", "image", "size", "by", "width", "and", "height", "pixels", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/metadata.go#L28-L38
140,789
h2non/bimg
resize.go
Resize
func Resize(buf []byte, o Options) ([]byte, error) { // Required in order to prevent premature garbage collection. See: // https://github.com/h2non/bimg/pull/162 defer runtime.KeepAlive(buf) return resizer(buf, o) }
go
func Resize(buf []byte, o Options) ([]byte, error) { // Required in order to prevent premature garbage collection. See: // https://github.com/h2non/bimg/pull/162 defer runtime.KeepAlive(buf) return resizer(buf, o) }
[ "func", "Resize", "(", "buf", "[", "]", "byte", ",", "o", "Options", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Required in order to prevent premature garbage collection. See:", "// https://github.com/h2non/bimg/pull/162", "defer", "runtime", ".", "KeepAl...
// Resize is used to transform a given image as byte buffer // with the passed options.
[ "Resize", "is", "used", "to", "transform", "a", "given", "image", "as", "byte", "buffer", "with", "the", "passed", "options", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/resize.go#L11-L16
140,790
h2non/bimg
file.go
Write
func Write(path string, buf []byte) error { return ioutil.WriteFile(path, buf, 0644) }
go
func Write(path string, buf []byte) error { return ioutil.WriteFile(path, buf, 0644) }
[ "func", "Write", "(", "path", "string", ",", "buf", "[", "]", "byte", ")", "error", "{", "return", "ioutil", ".", "WriteFile", "(", "path", ",", "buf", ",", "0644", ")", "\n", "}" ]
// Write writes the given byte buffer into disk // to the given file path.
[ "Write", "writes", "the", "given", "byte", "buffer", "into", "disk", "to", "the", "given", "file", "path", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/file.go#L13-L15
140,791
h2non/bimg
type.go
discoverSupportedImageTypes
func discoverSupportedImageTypes() { imageMutex.Lock() for imageType := range ImageTypes { SupportedImageTypes[imageType] = SupportedImageType{ Load: VipsIsTypeSupported(imageType), Save: VipsIsTypeSupportedSave(imageType), } } imageMutex.Unlock() }
go
func discoverSupportedImageTypes() { imageMutex.Lock() for imageType := range ImageTypes { SupportedImageTypes[imageType] = SupportedImageType{ Load: VipsIsTypeSupported(imageType), Save: VipsIsTypeSupportedSave(imageType), } } imageMutex.Unlock() }
[ "func", "discoverSupportedImageTypes", "(", ")", "{", "imageMutex", ".", "Lock", "(", ")", "\n", "for", "imageType", ":=", "range", "ImageTypes", "{", "SupportedImageTypes", "[", "imageType", "]", "=", "SupportedImageType", "{", "Load", ":", "VipsIsTypeSupported",...
// discoverSupportedImageTypes is used to fill SupportedImageTypes map.
[ "discoverSupportedImageTypes", "is", "used", "to", "fill", "SupportedImageTypes", "map", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/type.go#L68-L77
140,792
h2non/bimg
type.go
isBinary
func isBinary(buf []byte) bool { if len(buf) < 24 { return false } for i := 0; i < 24; i++ { charCode, _ := utf8.DecodeRuneInString(string(buf[i])) if charCode == 65533 || charCode <= 8 { return true } } return false }
go
func isBinary(buf []byte) bool { if len(buf) < 24 { return false } for i := 0; i < 24; i++ { charCode, _ := utf8.DecodeRuneInString(string(buf[i])) if charCode == 65533 || charCode <= 8 { return true } } return false }
[ "func", "isBinary", "(", "buf", "[", "]", "byte", ")", "bool", "{", "if", "len", "(", "buf", ")", "<", "24", "{", "return", "false", "\n", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "24", ";", "i", "++", "{", "charCode", ",", "_", ":=...
// isBinary checks if the given buffer is a binary file.
[ "isBinary", "checks", "if", "the", "given", "buffer", "is", "a", "binary", "file", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/type.go#L80-L91
140,793
h2non/bimg
type.go
IsSVGImage
func IsSVGImage(buf []byte) bool { return !isBinary(buf) && svgRegex.Match(htmlCommentRegex.ReplaceAll(buf, []byte{})) }
go
func IsSVGImage(buf []byte) bool { return !isBinary(buf) && svgRegex.Match(htmlCommentRegex.ReplaceAll(buf, []byte{})) }
[ "func", "IsSVGImage", "(", "buf", "[", "]", "byte", ")", "bool", "{", "return", "!", "isBinary", "(", "buf", ")", "&&", "svgRegex", ".", "Match", "(", "htmlCommentRegex", ".", "ReplaceAll", "(", "buf", ",", "[", "]", "byte", "{", "}", ")", ")", "\n...
// IsSVGImage returns true if the given buffer is a valid SVG image.
[ "IsSVGImage", "returns", "true", "if", "the", "given", "buffer", "is", "a", "valid", "SVG", "image", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/type.go#L94-L96
140,794
h2non/bimg
type.go
IsImageTypeSupportedByVips
func IsImageTypeSupportedByVips(t ImageType) SupportedImageType { imageMutex.RLock() // Discover supported image types and cache the result itShouldDiscover := len(SupportedImageTypes) == 0 if itShouldDiscover { imageMutex.RUnlock() discoverSupportedImageTypes() } // Check if image type is actually supporte...
go
func IsImageTypeSupportedByVips(t ImageType) SupportedImageType { imageMutex.RLock() // Discover supported image types and cache the result itShouldDiscover := len(SupportedImageTypes) == 0 if itShouldDiscover { imageMutex.RUnlock() discoverSupportedImageTypes() } // Check if image type is actually supporte...
[ "func", "IsImageTypeSupportedByVips", "(", "t", "ImageType", ")", "SupportedImageType", "{", "imageMutex", ".", "RLock", "(", ")", "\n\n", "// Discover supported image types and cache the result", "itShouldDiscover", ":=", "len", "(", "SupportedImageTypes", ")", "==", "0"...
// IsImageTypeSupportedByVips returns true if the given image type // is supported by current libvips compilation.
[ "IsImageTypeSupportedByVips", "returns", "true", "if", "the", "given", "image", "type", "is", "supported", "by", "current", "libvips", "compilation", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/type.go#L110-L130
140,795
h2non/bimg
type.go
IsTypeSupported
func IsTypeSupported(t ImageType) bool { _, ok := ImageTypes[t] return ok && IsImageTypeSupportedByVips(t).Load }
go
func IsTypeSupported(t ImageType) bool { _, ok := ImageTypes[t] return ok && IsImageTypeSupportedByVips(t).Load }
[ "func", "IsTypeSupported", "(", "t", "ImageType", ")", "bool", "{", "_", ",", "ok", ":=", "ImageTypes", "[", "t", "]", "\n", "return", "ok", "&&", "IsImageTypeSupportedByVips", "(", "t", ")", ".", "Load", "\n", "}" ]
// IsTypeSupported checks if a given image type is supported
[ "IsTypeSupported", "checks", "if", "a", "given", "image", "type", "is", "supported" ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/type.go#L133-L136
140,796
h2non/bimg
type.go
IsTypeNameSupported
func IsTypeNameSupported(t string) bool { for imageType, name := range ImageTypes { if name == t { return IsImageTypeSupportedByVips(imageType).Load } } return false }
go
func IsTypeNameSupported(t string) bool { for imageType, name := range ImageTypes { if name == t { return IsImageTypeSupportedByVips(imageType).Load } } return false }
[ "func", "IsTypeNameSupported", "(", "t", "string", ")", "bool", "{", "for", "imageType", ",", "name", ":=", "range", "ImageTypes", "{", "if", "name", "==", "t", "{", "return", "IsImageTypeSupportedByVips", "(", "imageType", ")", ".", "Load", "\n", "}", "\n...
// IsTypeNameSupported checks if a given image type name is supported
[ "IsTypeNameSupported", "checks", "if", "a", "given", "image", "type", "name", "is", "supported" ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/type.go#L139-L146
140,797
h2non/bimg
type.go
IsTypeSupportedSave
func IsTypeSupportedSave(t ImageType) bool { _, ok := ImageTypes[t] return ok && IsImageTypeSupportedByVips(t).Save }
go
func IsTypeSupportedSave(t ImageType) bool { _, ok := ImageTypes[t] return ok && IsImageTypeSupportedByVips(t).Save }
[ "func", "IsTypeSupportedSave", "(", "t", "ImageType", ")", "bool", "{", "_", ",", "ok", ":=", "ImageTypes", "[", "t", "]", "\n", "return", "ok", "&&", "IsImageTypeSupportedByVips", "(", "t", ")", ".", "Save", "\n", "}" ]
// IsTypeSupportedSave checks if a given image type is support for saving
[ "IsTypeSupportedSave", "checks", "if", "a", "given", "image", "type", "is", "support", "for", "saving" ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/type.go#L149-L152
140,798
h2non/bimg
type.go
IsTypeNameSupportedSave
func IsTypeNameSupportedSave(t string) bool { for imageType, name := range ImageTypes { if name == t { return IsImageTypeSupportedByVips(imageType).Save } } return false }
go
func IsTypeNameSupportedSave(t string) bool { for imageType, name := range ImageTypes { if name == t { return IsImageTypeSupportedByVips(imageType).Save } } return false }
[ "func", "IsTypeNameSupportedSave", "(", "t", "string", ")", "bool", "{", "for", "imageType", ",", "name", ":=", "range", "ImageTypes", "{", "if", "name", "==", "t", "{", "return", "IsImageTypeSupportedByVips", "(", "imageType", ")", ".", "Save", "\n", "}", ...
// IsTypeNameSupportedSave checks if a given image type name is supported for // saving
[ "IsTypeNameSupportedSave", "checks", "if", "a", "given", "image", "type", "name", "is", "supported", "for", "saving" ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/type.go#L156-L163
140,799
h2non/bimg
vips.go
Initialize
func Initialize() { if C.VIPS_MAJOR_VERSION <= 7 && C.VIPS_MINOR_VERSION < 40 { panic("unsupported libvips version!") } m.Lock() runtime.LockOSThread() defer m.Unlock() defer runtime.UnlockOSThread() err := C.vips_init(C.CString("bimg")) if err != 0 { panic("unable to start vips!") } // Set libvips cac...
go
func Initialize() { if C.VIPS_MAJOR_VERSION <= 7 && C.VIPS_MINOR_VERSION < 40 { panic("unsupported libvips version!") } m.Lock() runtime.LockOSThread() defer m.Unlock() defer runtime.UnlockOSThread() err := C.vips_init(C.CString("bimg")) if err != 0 { panic("unable to start vips!") } // Set libvips cac...
[ "func", "Initialize", "(", ")", "{", "if", "C", ".", "VIPS_MAJOR_VERSION", "<=", "7", "&&", "C", ".", "VIPS_MINOR_VERSION", "<", "40", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "m", ".", "Lock", "(", ")", "\n", "runtime", ".", "LockOST...
// Initialize is used to explicitly start libvips in thread-safe way. // Only call this function if you have previously turned off libvips.
[ "Initialize", "is", "used", "to", "explicitly", "start", "libvips", "in", "thread", "-", "safe", "way", ".", "Only", "call", "this", "function", "if", "you", "have", "previously", "turned", "off", "libvips", "." ]
15cd11560781e3a634d3857b845d4c9c93aa454b
https://github.com/h2non/bimg/blob/15cd11560781e3a634d3857b845d4c9c93aa454b/vips.go#L85-L116