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
24,300
gravitational/teleport
lib/services/resource.go
CheckAndSetDefaults
func (m *Metadata) CheckAndSetDefaults() error { if m.Name == "" { return trace.BadParameter("missing parameter Name") } if m.Namespace == "" { m.Namespace = defaults.Namespace } // adjust expires time to utc if it's set if m.Expires != nil { utils.UTC(m.Expires) } return nil }
go
func (m *Metadata) CheckAndSetDefaults() error { if m.Name == "" { return trace.BadParameter("missing parameter Name") } if m.Namespace == "" { m.Namespace = defaults.Namespace } // adjust expires time to utc if it's set if m.Expires != nil { utils.UTC(m.Expires) } return nil }
[ "func", "(", "m", "*", "Metadata", ")", "CheckAndSetDefaults", "(", ")", "error", "{", "if", "m", ".", "Name", "==", "\"", "\"", "{", "return", "trace", ".", "BadParameter", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "m", ".", "Namespace", "==", ...
// CheckAndSetDefaults checks validity of all parameters and sets defaults
[ "CheckAndSetDefaults", "checks", "validity", "of", "all", "parameters", "and", "sets", "defaults" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/resource.go#L503-L517
24,301
gravitational/teleport
lib/services/resource.go
ParseShortcut
func ParseShortcut(in string) (string, error) { if in == "" { return "", trace.BadParameter("missing resource name") } switch strings.ToLower(in) { case "role", "roles": return KindRole, nil case "namespaces", "ns": return KindNamespace, nil case "auth_servers", "auth": return KindAuthServer, nil case "p...
go
func ParseShortcut(in string) (string, error) { if in == "" { return "", trace.BadParameter("missing resource name") } switch strings.ToLower(in) { case "role", "roles": return KindRole, nil case "namespaces", "ns": return KindNamespace, nil case "auth_servers", "auth": return KindAuthServer, nil case "p...
[ "func", "ParseShortcut", "(", "in", "string", ")", "(", "string", ",", "error", ")", "{", "if", "in", "==", "\"", "\"", "{", "return", "\"", "\"", ",", "trace", ".", "BadParameter", "(", "\"", "\"", ")", "\n", "}", "\n", "switch", "strings", ".", ...
// ParseShortcut parses resource shortcut
[ "ParseShortcut", "parses", "resource", "shortcut" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/resource.go#L520-L557
24,302
gravitational/teleport
lib/utils/parse/parse.go
walk
func walk(node ast.Node) ([]string, error) { var l []string switch n := node.(type) { case *ast.IndexExpr: ret, err := walk(n.X) if err != nil { return nil, err } l = append(l, ret...) ret, err = walk(n.Index) if err != nil { return nil, err } l = append(l, ret...) case *ast.SelectorExpr: ...
go
func walk(node ast.Node) ([]string, error) { var l []string switch n := node.(type) { case *ast.IndexExpr: ret, err := walk(n.X) if err != nil { return nil, err } l = append(l, ret...) ret, err = walk(n.Index) if err != nil { return nil, err } l = append(l, ret...) case *ast.SelectorExpr: ...
[ "func", "walk", "(", "node", "ast", ".", "Node", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "l", "[", "]", "string", "\n\n", "switch", "n", ":=", "node", ".", "(", "type", ")", "{", "case", "*", "ast", ".", "IndexExpr", ":", ...
// walk will walk the ast tree and gather all the variable parts into a slice and return it.
[ "walk", "will", "walk", "the", "ast", "tree", "and", "gather", "all", "the", "variable", "parts", "into", "a", "slice", "and", "return", "it", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/utils/parse/parse.go#L64-L105
24,303
gravitational/teleport
lib/events/auditlog.go
NewAuditLog
func NewAuditLog(cfg AuditLogConfig) (*AuditLog, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } ctx, cancel := context.WithCancel(cfg.Context) al := &AuditLog{ playbackDir: filepath.Join(cfg.DataDir, PlaybackDir, SessionLogsDir, defaults.Namespace), AuditLogConfig:...
go
func NewAuditLog(cfg AuditLogConfig) (*AuditLog, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } ctx, cancel := context.WithCancel(cfg.Context) al := &AuditLog{ playbackDir: filepath.Join(cfg.DataDir, PlaybackDir, SessionLogsDir, defaults.Namespace), AuditLogConfig:...
[ "func", "NewAuditLog", "(", "cfg", "AuditLogConfig", ")", "(", "*", "AuditLog", ",", "error", ")", "{", "if", "err", ":=", "cfg", ".", "CheckAndSetDefaults", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ".", "Wrap", "(", "er...
// Creates and returns a new Audit Log object whish will store its logfiles in // a given directory. Session recording can be disabled by setting // recordSessions to false.
[ "Creates", "and", "returns", "a", "new", "Audit", "Log", "object", "whish", "will", "store", "its", "logfiles", "in", "a", "given", "directory", ".", "Session", "recording", "can", "be", "disabled", "by", "setting", "recordSessions", "to", "false", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/auditlog.go#L235-L300
24,304
gravitational/teleport
lib/events/auditlog.go
CheckAndSetDefaults
func (l *SessionRecording) CheckAndSetDefaults() error { if l.Recording == nil { return trace.BadParameter("missing parameter Recording") } if l.SessionID.IsZero() { return trace.BadParameter("missing parameter session ID") } if l.Namespace == "" { l.Namespace = defaults.Namespace } return nil }
go
func (l *SessionRecording) CheckAndSetDefaults() error { if l.Recording == nil { return trace.BadParameter("missing parameter Recording") } if l.SessionID.IsZero() { return trace.BadParameter("missing parameter session ID") } if l.Namespace == "" { l.Namespace = defaults.Namespace } return nil }
[ "func", "(", "l", "*", "SessionRecording", ")", "CheckAndSetDefaults", "(", ")", "error", "{", "if", "l", ".", "Recording", "==", "nil", "{", "return", "trace", ".", "BadParameter", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "l", ".", "SessionID", ...
// CheckAndSetDefaults checks and sets default parameters
[ "CheckAndSetDefaults", "checks", "and", "sets", "default", "parameters" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/auditlog.go#L317-L328
24,305
gravitational/teleport
lib/events/auditlog.go
chunkFileNames
func (idx *sessionIndex) chunkFileNames() []string { fileNames := make([]string, len(idx.chunks)) for i := 0; i < len(idx.chunks); i++ { fileNames[i] = idx.chunksFileName(i) } return fileNames }
go
func (idx *sessionIndex) chunkFileNames() []string { fileNames := make([]string, len(idx.chunks)) for i := 0; i < len(idx.chunks); i++ { fileNames[i] = idx.chunksFileName(i) } return fileNames }
[ "func", "(", "idx", "*", "sessionIndex", ")", "chunkFileNames", "(", ")", "[", "]", "string", "{", "fileNames", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "idx", ".", "chunks", ")", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", ...
// chunkFileNames returns file names of all session chunk files
[ "chunkFileNames", "returns", "file", "names", "of", "all", "session", "chunk", "files" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/auditlog.go#L469-L475
24,306
gravitational/teleport
lib/events/auditlog.go
createOrGetDownload
func (l *AuditLog) createOrGetDownload(path string) (context.Context, context.CancelFunc) { l.Lock() defer l.Unlock() ctx, ok := l.activeDownloads[path] if ok { return ctx, nil } ctx, cancel := context.WithCancel(context.TODO()) l.activeDownloads[path] = ctx return ctx, func() { cancel() l.Lock() defer ...
go
func (l *AuditLog) createOrGetDownload(path string) (context.Context, context.CancelFunc) { l.Lock() defer l.Unlock() ctx, ok := l.activeDownloads[path] if ok { return ctx, nil } ctx, cancel := context.WithCancel(context.TODO()) l.activeDownloads[path] = ctx return ctx, func() { cancel() l.Lock() defer ...
[ "func", "(", "l", "*", "AuditLog", ")", "createOrGetDownload", "(", "path", "string", ")", "(", "context", ".", "Context", ",", "context", ".", "CancelFunc", ")", "{", "l", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "Unlock", "(", ")", "\n", "...
// createOrGetDownload creates a new download sync entry for a given session, // if there is no active download in progress, or returns an existing one. // if the new context has been created, cancel function is returned as a // second argument. Caller should call this function to signal that download has been // compl...
[ "createOrGetDownload", "creates", "a", "new", "download", "sync", "entry", "for", "a", "given", "session", "if", "there", "is", "no", "active", "download", "in", "progress", "or", "returns", "an", "existing", "one", ".", "if", "the", "new", "context", "has",...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/auditlog.go#L560-L575
24,307
gravitational/teleport
lib/events/auditlog.go
GetSessionChunk
func (l *AuditLog) GetSessionChunk(namespace string, sid session.ID, offsetBytes, maxBytes int) ([]byte, error) { if l.UploadHandler != nil { if err := l.downloadSession(namespace, sid); err != nil { return nil, trace.Wrap(err) } } var data []byte for { out, err := l.getSessionChunk(namespace, sid, offsetB...
go
func (l *AuditLog) GetSessionChunk(namespace string, sid session.ID, offsetBytes, maxBytes int) ([]byte, error) { if l.UploadHandler != nil { if err := l.downloadSession(namespace, sid); err != nil { return nil, trace.Wrap(err) } } var data []byte for { out, err := l.getSessionChunk(namespace, sid, offsetB...
[ "func", "(", "l", "*", "AuditLog", ")", "GetSessionChunk", "(", "namespace", "string", ",", "sid", "session", ".", "ID", ",", "offsetBytes", ",", "maxBytes", "int", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "l", ".", "UploadHandler", ...
// GetSessionChunk returns a reader which console and web clients request // to receive a live stream of a given session. The reader allows access to a // session stream range from offsetBytes to offsetBytes+maxBytes
[ "GetSessionChunk", "returns", "a", "reader", "which", "console", "and", "web", "clients", "request", "to", "receive", "a", "live", "stream", "of", "a", "given", "session", ".", "The", "reader", "allows", "access", "to", "a", "session", "stream", "range", "fr...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/auditlog.go#L646-L668
24,308
gravitational/teleport
lib/events/auditlog.go
EmitAuditEvent
func (l *AuditLog) EmitAuditEvent(event Event, fields EventFields) error { // If an external logger has been set, use it as the emitter, otherwise // fallback to the local disk based emitter. var emitAuditEvent func(event Event, fields EventFields) error if l.ExternalLog != nil { emitAuditEvent = l.ExternalLog.Em...
go
func (l *AuditLog) EmitAuditEvent(event Event, fields EventFields) error { // If an external logger has been set, use it as the emitter, otherwise // fallback to the local disk based emitter. var emitAuditEvent func(event Event, fields EventFields) error if l.ExternalLog != nil { emitAuditEvent = l.ExternalLog.Em...
[ "func", "(", "l", "*", "AuditLog", ")", "EmitAuditEvent", "(", "event", "Event", ",", "fields", "EventFields", ")", "error", "{", "// If an external logger has been set, use it as the emitter, otherwise", "// fallback to the local disk based emitter.", "var", "emitAuditEvent", ...
// EmitAuditEvent adds a new event to the log. If emitting fails, a Prometheus // counter is incremented.
[ "EmitAuditEvent", "adds", "a", "new", "event", "to", "the", "log", ".", "If", "emitting", "fails", "a", "Prometheus", "counter", "is", "incremented", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/auditlog.go#L879-L898
24,309
gravitational/teleport
lib/events/auditlog.go
emitEvent
func (l *AuditLog) emitEvent(e AuditLogEvent) { if l.EventsC == nil { return } select { case l.EventsC <- &e: return default: l.Warningf("Blocked on the events channel.") } }
go
func (l *AuditLog) emitEvent(e AuditLogEvent) { if l.EventsC == nil { return } select { case l.EventsC <- &e: return default: l.Warningf("Blocked on the events channel.") } }
[ "func", "(", "l", "*", "AuditLog", ")", "emitEvent", "(", "e", "AuditLogEvent", ")", "{", "if", "l", ".", "EventsC", "==", "nil", "{", "return", "\n", "}", "\n", "select", "{", "case", "l", ".", "EventsC", "<-", "&", "e", ":", "return", "\n", "de...
// emitEvent emits event for test purposes
[ "emitEvent", "emits", "event", "for", "test", "purposes" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/auditlog.go#L901-L911
24,310
gravitational/teleport
lib/events/auditlog.go
auditDirs
func (l *AuditLog) auditDirs() ([]string, error) { authServers, err := l.getAuthServers() if err != nil { return nil, trace.Wrap(err) } var out []string for _, serverID := range authServers { out = append(out, filepath.Join(l.DataDir, serverID)) } return out, nil }
go
func (l *AuditLog) auditDirs() ([]string, error) { authServers, err := l.getAuthServers() if err != nil { return nil, trace.Wrap(err) } var out []string for _, serverID := range authServers { out = append(out, filepath.Join(l.DataDir, serverID)) } return out, nil }
[ "func", "(", "l", "*", "AuditLog", ")", "auditDirs", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "authServers", ",", "err", ":=", "l", ".", "getAuthServers", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "tra...
// auditDirs returns directories used for audit log storage
[ "auditDirs", "returns", "directories", "used", "for", "audit", "log", "storage" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/auditlog.go#L914-L925
24,311
gravitational/teleport
lib/events/auditlog.go
Close
func (l *AuditLog) Close() error { if l.ExternalLog != nil { if err := l.ExternalLog.Close(); err != nil { log.Warningf("Close failure: %v", err) } } l.cancel() l.Lock() defer l.Unlock() if l.localLog != nil { if err := l.localLog.Close(); err != nil { log.Warningf("Close failure: %v", err) } l.l...
go
func (l *AuditLog) Close() error { if l.ExternalLog != nil { if err := l.ExternalLog.Close(); err != nil { log.Warningf("Close failure: %v", err) } } l.cancel() l.Lock() defer l.Unlock() if l.localLog != nil { if err := l.localLog.Close(); err != nil { log.Warningf("Close failure: %v", err) } l.l...
[ "func", "(", "l", "*", "AuditLog", ")", "Close", "(", ")", "error", "{", "if", "l", ".", "ExternalLog", "!=", "nil", "{", "if", "err", ":=", "l", ".", "ExternalLog", ".", "Close", "(", ")", ";", "err", "!=", "nil", "{", "log", ".", "Warningf", ...
// Closes the audit log, which inluces closing all file handles and releasing // all session loggers
[ "Closes", "the", "audit", "log", "which", "inluces", "closing", "all", "file", "handles", "and", "releasing", "all", "session", "loggers" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/auditlog.go#L955-L972
24,312
gravitational/teleport
lib/events/auditlog.go
periodicSpaceMonitor
func (l *AuditLog) periodicSpaceMonitor() { ticker := time.NewTicker(defaults.DiskAlertInterval) defer ticker.Stop() for { select { case <-ticker.C: // Find out what percentage of disk space is used. If the syscall fails, // emit that to prometheus as well. usedPercent, err := percentUsed(l.DataDir) ...
go
func (l *AuditLog) periodicSpaceMonitor() { ticker := time.NewTicker(defaults.DiskAlertInterval) defer ticker.Stop() for { select { case <-ticker.C: // Find out what percentage of disk space is used. If the syscall fails, // emit that to prometheus as well. usedPercent, err := percentUsed(l.DataDir) ...
[ "func", "(", "l", "*", "AuditLog", ")", "periodicSpaceMonitor", "(", ")", "{", "ticker", ":=", "time", ".", "NewTicker", "(", "defaults", ".", "DiskAlertInterval", ")", "\n", "defer", "ticker", ".", "Stop", "(", ")", "\n\n", "for", "{", "select", "{", ...
// periodicSpaceMonitor run forever monitoring how much disk space has been // used on disk. Values are emitted to a Prometheus gauge.
[ "periodicSpaceMonitor", "run", "forever", "monitoring", "how", "much", "disk", "space", "has", "been", "used", "on", "disk", ".", "Values", "are", "emitted", "to", "a", "Prometheus", "gauge", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/auditlog.go#L992-L1019
24,313
gravitational/teleport
lib/backend/legacy/dir/impl.go
New
func New(params legacy.Params) (*Backend, error) { rootDir := params.GetString("path") if rootDir == "" { rootDir = params.GetString("data_dir") } if rootDir == "" { return nil, trace.BadParameter("filesystem backend: 'path' is not set") } // Ensure that the path to the root directory exists. err := os.Mkdi...
go
func New(params legacy.Params) (*Backend, error) { rootDir := params.GetString("path") if rootDir == "" { rootDir = params.GetString("data_dir") } if rootDir == "" { return nil, trace.BadParameter("filesystem backend: 'path' is not set") } // Ensure that the path to the root directory exists. err := os.Mkdi...
[ "func", "New", "(", "params", "legacy", ".", "Params", ")", "(", "*", "Backend", ",", "error", ")", "{", "rootDir", ":=", "params", ".", "GetString", "(", "\"", "\"", ")", "\n", "if", "rootDir", "==", "\"", "\"", "{", "rootDir", "=", "params", ".",...
// New creates a new instance of a directory based backend that implements // backend.Backend.
[ "New", "creates", "a", "new", "instance", "of", "a", "directory", "based", "backend", "that", "implements", "backend", ".", "Backend", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/dir/impl.go#L77-L111
24,314
gravitational/teleport
lib/backend/legacy/dir/impl.go
GetKeys
func (bk *Backend) GetKeys(bucket []string) ([]string, error) { // Get all the key/value pairs for this bucket. items, err := bk.GetItems(bucket) if err != nil { return nil, trace.Wrap(err) } // Return only the keys, the keys are already sorted by GetItems. keys := make([]string, len(items)) for i, e := range...
go
func (bk *Backend) GetKeys(bucket []string) ([]string, error) { // Get all the key/value pairs for this bucket. items, err := bk.GetItems(bucket) if err != nil { return nil, trace.Wrap(err) } // Return only the keys, the keys are already sorted by GetItems. keys := make([]string, len(items)) for i, e := range...
[ "func", "(", "bk", "*", "Backend", ")", "GetKeys", "(", "bucket", "[", "]", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "// Get all the key/value pairs for this bucket.", "items", ",", "err", ":=", "bk", ".", "GetItems", "(", "bucket", ...
// GetKeys returns a list of keys for a given bucket.
[ "GetKeys", "returns", "a", "list", "of", "keys", "for", "a", "given", "bucket", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/dir/impl.go#L119-L133
24,315
gravitational/teleport
lib/backend/legacy/dir/impl.go
GetVal
func (bk *Backend) GetVal(bucket []string, key string) ([]byte, error) { // Open the bucket to work on the items. b, err := bk.openBucket(bk.flatten(bucket), os.O_RDWR) if err != nil { // GetVal on a bucket needs to return trace.BadParameter. If opening the // bucket failed a partial match up to a bucket may sti...
go
func (bk *Backend) GetVal(bucket []string, key string) ([]byte, error) { // Open the bucket to work on the items. b, err := bk.openBucket(bk.flatten(bucket), os.O_RDWR) if err != nil { // GetVal on a bucket needs to return trace.BadParameter. If opening the // bucket failed a partial match up to a bucket may sti...
[ "func", "(", "bk", "*", "Backend", ")", "GetVal", "(", "bucket", "[", "]", "string", ",", "key", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Open the bucket to work on the items.", "b", ",", "err", ":=", "bk", ".", "openBucket", "...
// GetVal return a value for a given key in the bucket
[ "GetVal", "return", "a", "value", "for", "a", "given", "key", "in", "the", "bucket" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/dir/impl.go#L327-L374
24,316
gravitational/teleport
lib/backend/legacy/dir/impl.go
CompareAndSwapVal
func (bk *Backend) CompareAndSwapVal(bucket []string, key string, val []byte, prevVal []byte, ttl time.Duration) error { // Open the bucket to work on the items. b, err := bk.openBucket(bk.flatten(bucket), os.O_CREATE|os.O_RDWR) if err != nil { er := trace.ConvertSystemError(err) if trace.IsNotFound(er) { ret...
go
func (bk *Backend) CompareAndSwapVal(bucket []string, key string, val []byte, prevVal []byte, ttl time.Duration) error { // Open the bucket to work on the items. b, err := bk.openBucket(bk.flatten(bucket), os.O_CREATE|os.O_RDWR) if err != nil { er := trace.ConvertSystemError(err) if trace.IsNotFound(er) { ret...
[ "func", "(", "bk", "*", "Backend", ")", "CompareAndSwapVal", "(", "bucket", "[", "]", "string", ",", "key", "string", ",", "val", "[", "]", "byte", ",", "prevVal", "[", "]", "byte", ",", "ttl", "time", ".", "Duration", ")", "error", "{", "// Open the...
// CompareAndSwapVal compares and swap values in atomic operation
[ "CompareAndSwapVal", "compares", "and", "swap", "values", "in", "atomic", "operation" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/dir/impl.go#L377-L406
24,317
gravitational/teleport
lib/backend/legacy/dir/impl.go
DeleteKey
func (bk *Backend) DeleteKey(bucket []string, key string) error { // Open the bucket to work on the items. b, err := bk.openBucket(bk.flatten(bucket), os.O_RDWR) if err != nil { return trace.Wrap(err) } defer b.Close() // If the key doesn't exist, return trace.NotFound. _, ok := b.getItem(key) if !ok { ret...
go
func (bk *Backend) DeleteKey(bucket []string, key string) error { // Open the bucket to work on the items. b, err := bk.openBucket(bk.flatten(bucket), os.O_RDWR) if err != nil { return trace.Wrap(err) } defer b.Close() // If the key doesn't exist, return trace.NotFound. _, ok := b.getItem(key) if !ok { ret...
[ "func", "(", "bk", "*", "Backend", ")", "DeleteKey", "(", "bucket", "[", "]", "string", ",", "key", "string", ")", "error", "{", "// Open the bucket to work on the items.", "b", ",", "err", ":=", "bk", ".", "openBucket", "(", "bk", ".", "flatten", "(", "...
// DeleteKey deletes a key in a bucket.
[ "DeleteKey", "deletes", "a", "key", "in", "a", "bucket", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/dir/impl.go#L409-L427
24,318
gravitational/teleport
lib/backend/legacy/dir/impl.go
DeleteBucket
func (bk *Backend) DeleteBucket(parent []string, bucket string) error { fullBucket := append(parent, bucket) err := os.Remove(bk.flatten(fullBucket)) if err != nil { return trace.ConvertSystemError(err) } return nil }
go
func (bk *Backend) DeleteBucket(parent []string, bucket string) error { fullBucket := append(parent, bucket) err := os.Remove(bk.flatten(fullBucket)) if err != nil { return trace.ConvertSystemError(err) } return nil }
[ "func", "(", "bk", "*", "Backend", ")", "DeleteBucket", "(", "parent", "[", "]", "string", ",", "bucket", "string", ")", "error", "{", "fullBucket", ":=", "append", "(", "parent", ",", "bucket", ")", "\n\n", "err", ":=", "os", ".", "Remove", "(", "bk...
// DeleteBucket deletes the bucket by a given path.
[ "DeleteBucket", "deletes", "the", "bucket", "by", "a", "given", "path", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/dir/impl.go#L430-L439
24,319
gravitational/teleport
lib/backend/legacy/dir/impl.go
AcquireLock
func (bk *Backend) AcquireLock(token string, ttl time.Duration) (err error) { bk.log.Debugf("AcquireLock(%s)", token) if err = legacy.ValidateLockTTL(ttl); err != nil { return trace.Wrap(err) } bucket := []string{locksBucket} for { // GetVal will clear TTL on a lock bk.GetVal(bucket, token) // CreateVal...
go
func (bk *Backend) AcquireLock(token string, ttl time.Duration) (err error) { bk.log.Debugf("AcquireLock(%s)", token) if err = legacy.ValidateLockTTL(ttl); err != nil { return trace.Wrap(err) } bucket := []string{locksBucket} for { // GetVal will clear TTL on a lock bk.GetVal(bucket, token) // CreateVal...
[ "func", "(", "bk", "*", "Backend", ")", "AcquireLock", "(", "token", "string", ",", "ttl", "time", ".", "Duration", ")", "(", "err", "error", ")", "{", "bk", ".", "log", ".", "Debugf", "(", "\"", "\"", ",", "token", ")", "\n\n", "if", "err", "=",...
// AcquireLock grabs a lock that will be released automatically in TTL.
[ "AcquireLock", "grabs", "a", "lock", "that", "will", "be", "released", "automatically", "in", "TTL", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/dir/impl.go#L442-L467
24,320
gravitational/teleport
lib/backend/legacy/dir/impl.go
ReleaseLock
func (bk *Backend) ReleaseLock(token string) (err error) { bk.log.Debugf("ReleaseLock(%s)", token) if err = bk.DeleteKey([]string{locksBucket}, token); err != nil { if !os.IsNotExist(err) { return trace.ConvertSystemError(err) } } return nil }
go
func (bk *Backend) ReleaseLock(token string) (err error) { bk.log.Debugf("ReleaseLock(%s)", token) if err = bk.DeleteKey([]string{locksBucket}, token); err != nil { if !os.IsNotExist(err) { return trace.ConvertSystemError(err) } } return nil }
[ "func", "(", "bk", "*", "Backend", ")", "ReleaseLock", "(", "token", "string", ")", "(", "err", "error", ")", "{", "bk", ".", "log", ".", "Debugf", "(", "\"", "\"", ",", "token", ")", "\n\n", "if", "err", "=", "bk", ".", "DeleteKey", "(", "[", ...
// ReleaseLock forces lock release before TTL.
[ "ReleaseLock", "forces", "lock", "release", "before", "TTL", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/dir/impl.go#L470-L479
24,321
gravitational/teleport
lib/backend/legacy/dir/impl.go
pathToBucket
func (bk *Backend) pathToBucket(bucket string) string { return filepath.Join(bk.rootDir, bucket) }
go
func (bk *Backend) pathToBucket(bucket string) string { return filepath.Join(bk.rootDir, bucket) }
[ "func", "(", "bk", "*", "Backend", ")", "pathToBucket", "(", "bucket", "string", ")", "string", "{", "return", "filepath", ".", "Join", "(", "bk", ".", "rootDir", ",", "bucket", ")", "\n", "}" ]
// pathToBucket prepends the root directory to the bucket returning the full // path to the bucket on the filesystem.
[ "pathToBucket", "prepends", "the", "root", "directory", "to", "the", "bucket", "returning", "the", "full", "path", "to", "the", "bucket", "on", "the", "filesystem", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/dir/impl.go#L483-L485
24,322
gravitational/teleport
lib/backend/legacy/dir/impl.go
decodeBucket
func decodeBucket(bucket string) ([]string, error) { decoded, err := url.QueryUnescape(bucket) if err != nil { return nil, trace.Wrap(err) } return filepath.SplitList(decoded), nil }
go
func decodeBucket(bucket string) ([]string, error) { decoded, err := url.QueryUnescape(bucket) if err != nil { return nil, trace.Wrap(err) } return filepath.SplitList(decoded), nil }
[ "func", "decodeBucket", "(", "bucket", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "decoded", ",", "err", ":=", "url", ".", "QueryUnescape", "(", "bucket", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ...
// decodeBucket decodes bucket into parts of path
[ "decodeBucket", "decodes", "bucket", "into", "parts", "of", "path" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/dir/impl.go#L488-L494
24,323
gravitational/teleport
lib/backend/legacy/dir/impl.go
isExpired
func (bk *Backend) isExpired(bv bucketItem) bool { if bv.ExpiryTime.IsZero() { return false } return bk.Clock().Now().After(bv.ExpiryTime) }
go
func (bk *Backend) isExpired(bv bucketItem) bool { if bv.ExpiryTime.IsZero() { return false } return bk.Clock().Now().After(bv.ExpiryTime) }
[ "func", "(", "bk", "*", "Backend", ")", "isExpired", "(", "bv", "bucketItem", ")", "bool", "{", "if", "bv", ".", "ExpiryTime", ".", "IsZero", "(", ")", "{", "return", "false", "\n", "}", "\n", "return", "bk", ".", "Clock", "(", ")", ".", "Now", "...
// isExpired checks if the bucket item is expired or not.
[ "isExpired", "checks", "if", "the", "bucket", "item", "is", "expired", "or", "not", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/dir/impl.go#L509-L514
24,324
gravitational/teleport
lib/backend/legacy/dir/impl.go
openBucket
func (bk *Backend) openBucket(prefix string, openFlag int) (*bucket, error) { // Open bucket with requested flags. file, err := os.OpenFile(prefix, openFlag, defaultFileMode) if err != nil { return nil, trace.ConvertSystemError(err) } // Lock the bucket so no one else can access it. if err := utils.FSWriteLock...
go
func (bk *Backend) openBucket(prefix string, openFlag int) (*bucket, error) { // Open bucket with requested flags. file, err := os.OpenFile(prefix, openFlag, defaultFileMode) if err != nil { return nil, trace.ConvertSystemError(err) } // Lock the bucket so no one else can access it. if err := utils.FSWriteLock...
[ "func", "(", "bk", "*", "Backend", ")", "openBucket", "(", "prefix", "string", ",", "openFlag", "int", ")", "(", "*", "bucket", ",", "error", ")", "{", "// Open bucket with requested flags.", "file", ",", "err", ":=", "os", ".", "OpenFile", "(", "prefix", ...
// openBucket will open a file, lock it, and then read in all the items in // the bucket.
[ "openBucket", "will", "open", "a", "file", "lock", "it", "and", "then", "read", "in", "all", "the", "items", "in", "the", "bucket", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/dir/impl.go#L543-L566
24,325
gravitational/teleport
lib/backend/legacy/dir/impl.go
readBucket
func readBucket(f *os.File) (map[string]bucketItem, error) { // If the file is empty, return an empty bucket. ok, err := isEmpty(f) if err != nil { return nil, trace.Wrap(err) } if ok { return map[string]bucketItem{}, nil } // The file is not empty, read it into a map. var items map[string]bucketItem byte...
go
func readBucket(f *os.File) (map[string]bucketItem, error) { // If the file is empty, return an empty bucket. ok, err := isEmpty(f) if err != nil { return nil, trace.Wrap(err) } if ok { return map[string]bucketItem{}, nil } // The file is not empty, read it into a map. var items map[string]bucketItem byte...
[ "func", "readBucket", "(", "f", "*", "os", ".", "File", ")", "(", "map", "[", "string", "]", "bucketItem", ",", "error", ")", "{", "// If the file is empty, return an empty bucket.", "ok", ",", "err", ":=", "isEmpty", "(", "f", ")", "\n", "if", "err", "!...
// readBucket will read in the bucket and return a map of keys. The second return // value returns true to false to indicate if the file was empty or not.
[ "readBucket", "will", "read", "in", "the", "bucket", "and", "return", "a", "map", "of", "keys", ".", "The", "second", "return", "value", "returns", "true", "to", "false", "to", "indicate", "if", "the", "file", "was", "empty", "or", "not", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/dir/impl.go#L617-L639
24,326
gravitational/teleport
lib/backend/legacy/dir/impl.go
writeBucket
func writeBucket(f *os.File, items map[string]bucketItem) error { // Marshal items to disk format. bytes, err := json.Marshal(items) if err != nil { return trace.Wrap(err) } // Truncate the file. if _, err := f.Seek(0, 0); err != nil { return trace.ConvertSystemError(err) } if err := f.Truncate(0); err != ...
go
func writeBucket(f *os.File, items map[string]bucketItem) error { // Marshal items to disk format. bytes, err := json.Marshal(items) if err != nil { return trace.Wrap(err) } // Truncate the file. if _, err := f.Seek(0, 0); err != nil { return trace.ConvertSystemError(err) } if err := f.Truncate(0); err != ...
[ "func", "writeBucket", "(", "f", "*", "os", ".", "File", ",", "items", "map", "[", "string", "]", "bucketItem", ")", "error", "{", "// Marshal items to disk format.", "bytes", ",", "err", ":=", "json", ".", "Marshal", "(", "items", ")", "\n", "if", "err"...
// writeBucket will truncate the file and write out the items to the file f.
[ "writeBucket", "will", "truncate", "the", "file", "and", "write", "out", "the", "items", "to", "the", "file", "f", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/dir/impl.go#L642-L664
24,327
gravitational/teleport
lib/backend/legacy/dir/impl.go
isEmpty
func isEmpty(f *os.File) (bool, error) { fi, err := f.Stat() if err != nil { return false, trace.Wrap(err) } if fi.Size() > 0 { return false, nil } return true, nil }
go
func isEmpty(f *os.File) (bool, error) { fi, err := f.Stat() if err != nil { return false, trace.Wrap(err) } if fi.Size() > 0 { return false, nil } return true, nil }
[ "func", "isEmpty", "(", "f", "*", "os", ".", "File", ")", "(", "bool", ",", "error", ")", "{", "fi", ",", "err", ":=", "f", ".", "Stat", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "trace", ".", "Wrap", "(", "err", ...
// isEmpty checks if the file is empty or not.
[ "isEmpty", "checks", "if", "the", "file", "is", "empty", "or", "not", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/legacy/dir/impl.go#L667-L678
24,328
gravitational/teleport
lib/backend/memory/item.go
Less
func (i *btreeItem) Less(iother btree.Item) bool { switch other := iother.(type) { case *btreeItem: return bytes.Compare(i.Key, other.Key) < 0 case *prefixItem: return !iother.Less(i) default: return false } }
go
func (i *btreeItem) Less(iother btree.Item) bool { switch other := iother.(type) { case *btreeItem: return bytes.Compare(i.Key, other.Key) < 0 case *prefixItem: return !iother.Less(i) default: return false } }
[ "func", "(", "i", "*", "btreeItem", ")", "Less", "(", "iother", "btree", ".", "Item", ")", "bool", "{", "switch", "other", ":=", "iother", ".", "(", "type", ")", "{", "case", "*", "btreeItem", ":", "return", "bytes", ".", "Compare", "(", "i", ".", ...
// Less is used for Btree operations, // returns true if item is less than the other one
[ "Less", "is", "used", "for", "Btree", "operations", "returns", "true", "if", "item", "is", "less", "than", "the", "other", "one" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/memory/item.go#L37-L46
24,329
gravitational/teleport
lib/backend/memory/item.go
Less
func (p *prefixItem) Less(iother btree.Item) bool { other := iother.(*btreeItem) if bytes.HasPrefix(other.Key, p.prefix) { return false } return true }
go
func (p *prefixItem) Less(iother btree.Item) bool { other := iother.(*btreeItem) if bytes.HasPrefix(other.Key, p.prefix) { return false } return true }
[ "func", "(", "p", "*", "prefixItem", ")", "Less", "(", "iother", "btree", ".", "Item", ")", "bool", "{", "other", ":=", "iother", ".", "(", "*", "btreeItem", ")", "\n", "if", "bytes", ".", "HasPrefix", "(", "other", ".", "Key", ",", "p", ".", "pr...
// Less is used for Btree operations
[ "Less", "is", "used", "for", "Btree", "operations" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/memory/item.go#L55-L61
24,330
gravitational/teleport
lib/services/remotecluster.go
NewRemoteCluster
func NewRemoteCluster(name string) (RemoteCluster, error) { return &RemoteClusterV3{ Kind: KindRemoteCluster, Version: V3, Metadata: Metadata{ Name: name, Namespace: defaults.Namespace, }, }, nil }
go
func NewRemoteCluster(name string) (RemoteCluster, error) { return &RemoteClusterV3{ Kind: KindRemoteCluster, Version: V3, Metadata: Metadata{ Name: name, Namespace: defaults.Namespace, }, }, nil }
[ "func", "NewRemoteCluster", "(", "name", "string", ")", "(", "RemoteCluster", ",", "error", ")", "{", "return", "&", "RemoteClusterV3", "{", "Kind", ":", "KindRemoteCluster", ",", "Version", ":", "V3", ",", "Metadata", ":", "Metadata", "{", "Name", ":", "n...
// NewRemoteCluster is a convenience wa to create a RemoteCluster resource.
[ "NewRemoteCluster", "is", "a", "convenience", "wa", "to", "create", "a", "RemoteCluster", "resource", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/remotecluster.go#L50-L59
24,331
gravitational/teleport
lib/services/remotecluster.go
SetLastHeartbeat
func (c *RemoteClusterV3) SetLastHeartbeat(t time.Time) { c.Status.LastHeartbeat = t }
go
func (c *RemoteClusterV3) SetLastHeartbeat(t time.Time) { c.Status.LastHeartbeat = t }
[ "func", "(", "c", "*", "RemoteClusterV3", ")", "SetLastHeartbeat", "(", "t", "time", ".", "Time", ")", "{", "c", ".", "Status", ".", "LastHeartbeat", "=", "t", "\n", "}" ]
// SetLastHeartbeat sets last heartbeat of the cluster
[ "SetLastHeartbeat", "sets", "last", "heartbeat", "of", "the", "cluster" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/remotecluster.go#L128-L130
24,332
gravitational/teleport
lib/services/remotecluster.go
String
func (r *RemoteClusterV3) String() string { return fmt.Sprintf("RemoteCluster(%v, %v)", r.Metadata.Name, r.Status.Connection) }
go
func (r *RemoteClusterV3) String() string { return fmt.Sprintf("RemoteCluster(%v, %v)", r.Metadata.Name, r.Status.Connection) }
[ "func", "(", "r", "*", "RemoteClusterV3", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "r", ".", "Metadata", ".", "Name", ",", "r", ".", "Status", ".", "Connection", ")", "\n", "}" ]
// String represents a human readable version of remote cluster settings.
[ "String", "represents", "a", "human", "readable", "version", "of", "remote", "cluster", "settings", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/remotecluster.go#L173-L175
24,333
gravitational/teleport
lib/services/remotecluster.go
UnmarshalRemoteCluster
func UnmarshalRemoteCluster(bytes []byte, opts ...MarshalOption) (RemoteCluster, error) { cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } var cluster RemoteClusterV3 if len(bytes) == 0 { return nil, trace.BadParameter("missing resource data") } if cfg.SkipValidation { err ...
go
func UnmarshalRemoteCluster(bytes []byte, opts ...MarshalOption) (RemoteCluster, error) { cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } var cluster RemoteClusterV3 if len(bytes) == 0 { return nil, trace.BadParameter("missing resource data") } if cfg.SkipValidation { err ...
[ "func", "UnmarshalRemoteCluster", "(", "bytes", "[", "]", "byte", ",", "opts", "...", "MarshalOption", ")", "(", "RemoteCluster", ",", "error", ")", "{", "cfg", ",", "err", ":=", "collectOptions", "(", "opts", ")", "\n", "if", "err", "!=", "nil", "{", ...
// UnmarshalRemoteCluster unmarshals remote cluster from JSON or YAML.
[ "UnmarshalRemoteCluster", "unmarshals", "remote", "cluster", "from", "JSON", "or", "YAML", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/remotecluster.go#L207-L237
24,334
gravitational/teleport
lib/services/remotecluster.go
MarshalRemoteCluster
func MarshalRemoteCluster(c RemoteCluster, opts ...MarshalOption) ([]byte, error) { cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } switch resource := c.(type) { case *RemoteClusterV3: if !cfg.PreserveResourceID { // avoid modifying the original object // to prevent unexpec...
go
func MarshalRemoteCluster(c RemoteCluster, opts ...MarshalOption) ([]byte, error) { cfg, err := collectOptions(opts) if err != nil { return nil, trace.Wrap(err) } switch resource := c.(type) { case *RemoteClusterV3: if !cfg.PreserveResourceID { // avoid modifying the original object // to prevent unexpec...
[ "func", "MarshalRemoteCluster", "(", "c", "RemoteCluster", ",", "opts", "...", "MarshalOption", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "cfg", ",", "err", ":=", "collectOptions", "(", "opts", ")", "\n", "if", "err", "!=", "nil", "{", "retur...
// MarshalRemoteCluster marshals remote cluster to JSON.
[ "MarshalRemoteCluster", "marshals", "remote", "cluster", "to", "JSON", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/remotecluster.go#L240-L258
24,335
gravitational/teleport
lib/tlsca/ca.go
New
func New(certPEM, keyPEM []byte) (*CertAuthority, error) { ca := &CertAuthority{} var err error ca.Cert, err = ParseCertificatePEM(certPEM) if err != nil { return nil, trace.Wrap(err) } if len(keyPEM) != 0 { ca.Signer, err = ParsePrivateKeyPEM(keyPEM) if err != nil { return nil, trace.Wrap(err) } } r...
go
func New(certPEM, keyPEM []byte) (*CertAuthority, error) { ca := &CertAuthority{} var err error ca.Cert, err = ParseCertificatePEM(certPEM) if err != nil { return nil, trace.Wrap(err) } if len(keyPEM) != 0 { ca.Signer, err = ParsePrivateKeyPEM(keyPEM) if err != nil { return nil, trace.Wrap(err) } } r...
[ "func", "New", "(", "certPEM", ",", "keyPEM", "[", "]", "byte", ")", "(", "*", "CertAuthority", ",", "error", ")", "{", "ca", ":=", "&", "CertAuthority", "{", "}", "\n", "var", "err", "error", "\n", "ca", ".", "Cert", ",", "err", "=", "ParseCertifi...
// New returns new CA from PEM encoded certificate and private // key. Private Key is optional, if omitted CA won't be able to // issue new certificates, only verify them
[ "New", "returns", "new", "CA", "from", "PEM", "encoded", "certificate", "and", "private", "key", ".", "Private", "Key", "is", "optional", "if", "omitted", "CA", "won", "t", "be", "able", "to", "issue", "new", "certificates", "only", "verify", "them" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/tlsca/ca.go#L43-L57
24,336
gravitational/teleport
lib/tlsca/ca.go
Subject
func (id *Identity) Subject() pkix.Name { subject := pkix.Name{ CommonName: id.Username, } subject.Organization = append([]string{}, id.Groups...) subject.OrganizationalUnit = append([]string{}, id.Usage...) subject.Locality = append([]string{}, id.Principals...) subject.Province = append([]string{}, id.Kuberne...
go
func (id *Identity) Subject() pkix.Name { subject := pkix.Name{ CommonName: id.Username, } subject.Organization = append([]string{}, id.Groups...) subject.OrganizationalUnit = append([]string{}, id.Usage...) subject.Locality = append([]string{}, id.Principals...) subject.Province = append([]string{}, id.Kuberne...
[ "func", "(", "id", "*", "Identity", ")", "Subject", "(", ")", "pkix", ".", "Name", "{", "subject", ":=", "pkix", ".", "Name", "{", "CommonName", ":", "id", ".", "Username", ",", "}", "\n", "subject", ".", "Organization", "=", "append", "(", "[", "]...
// Subject converts identity to X.509 subject name
[ "Subject", "converts", "identity", "to", "X", ".", "509", "subject", "name" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/tlsca/ca.go#L93-L102
24,337
gravitational/teleport
lib/tlsca/ca.go
FromSubject
func FromSubject(subject pkix.Name) (*Identity, error) { i := &Identity{ Username: subject.CommonName, Groups: subject.Organization, Usage: subject.OrganizationalUnit, Principals: subject.Locality, KubernetesGroups: subject.Province, } if err := i.CheckAndSetDefaults(); e...
go
func FromSubject(subject pkix.Name) (*Identity, error) { i := &Identity{ Username: subject.CommonName, Groups: subject.Organization, Usage: subject.OrganizationalUnit, Principals: subject.Locality, KubernetesGroups: subject.Province, } if err := i.CheckAndSetDefaults(); e...
[ "func", "FromSubject", "(", "subject", "pkix", ".", "Name", ")", "(", "*", "Identity", ",", "error", ")", "{", "i", ":=", "&", "Identity", "{", "Username", ":", "subject", ".", "CommonName", ",", "Groups", ":", "subject", ".", "Organization", ",", "Usa...
// FromSubject returns identity from subject name
[ "FromSubject", "returns", "identity", "from", "subject", "name" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/tlsca/ca.go#L105-L117
24,338
gravitational/teleport
lib/tlsca/ca.go
GenerateCertificate
func (ca *CertAuthority) GenerateCertificate(req CertificateRequest) ([]byte, error) { if err := req.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) if err != nil { return n...
go
func (ca *CertAuthority) GenerateCertificate(req CertificateRequest) ([]byte, error) { if err := req.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) if err != nil { return n...
[ "func", "(", "ca", "*", "CertAuthority", ")", "GenerateCertificate", "(", "req", "CertificateRequest", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "err", ":=", "req", ".", "CheckAndSetDefaults", "(", ")", ";", "err", "!=", "nil", "{", "re...
// GenerateCertificate generates certificate from request
[ "GenerateCertificate", "generates", "certificate", "from", "request" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/tlsca/ca.go#L152-L200
24,339
gravitational/teleport
lib/srv/termhandlers.go
HandleExec
func (t *TermHandlers) HandleExec(ch ssh.Channel, req *ssh.Request, ctx *ServerContext) error { execRequest, err := parseExecRequest(req, ctx) if err != nil { return trace.Wrap(err) } // a terminal has been previously allocate for this command. // run this inside an interactive session if ctx.GetTerm() != nil ...
go
func (t *TermHandlers) HandleExec(ch ssh.Channel, req *ssh.Request, ctx *ServerContext) error { execRequest, err := parseExecRequest(req, ctx) if err != nil { return trace.Wrap(err) } // a terminal has been previously allocate for this command. // run this inside an interactive session if ctx.GetTerm() != nil ...
[ "func", "(", "t", "*", "TermHandlers", ")", "HandleExec", "(", "ch", "ssh", ".", "Channel", ",", "req", "*", "ssh", ".", "Request", ",", "ctx", "*", "ServerContext", ")", "error", "{", "execRequest", ",", "err", ":=", "parseExecRequest", "(", "req", ",...
// HandleExec handles requests of type "exec" which can execute with or // without a TTY. Result of execution is propagated back on the ExecResult // channel of the context.
[ "HandleExec", "handles", "requests", "of", "type", "exec", "which", "can", "execute", "with", "or", "without", "a", "TTY", ".", "Result", "of", "execution", "is", "propagated", "back", "on", "the", "ExecResult", "channel", "of", "the", "context", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/termhandlers.go#L39-L119
24,340
gravitational/teleport
lib/srv/termhandlers.go
HandlePTYReq
func (t *TermHandlers) HandlePTYReq(ch ssh.Channel, req *ssh.Request, ctx *ServerContext) error { // parse and extract the requested window size of the pty ptyRequest, err := parsePTYReq(req) if err != nil { return trace.Wrap(err) } termModes, err := ptyRequest.TerminalModes() if err != nil { return trace.Wr...
go
func (t *TermHandlers) HandlePTYReq(ch ssh.Channel, req *ssh.Request, ctx *ServerContext) error { // parse and extract the requested window size of the pty ptyRequest, err := parsePTYReq(req) if err != nil { return trace.Wrap(err) } termModes, err := ptyRequest.TerminalModes() if err != nil { return trace.Wr...
[ "func", "(", "t", "*", "TermHandlers", ")", "HandlePTYReq", "(", "ch", "ssh", ".", "Channel", ",", "req", "*", "ssh", ".", "Request", ",", "ctx", "*", "ServerContext", ")", "error", "{", "// parse and extract the requested window size of the pty", "ptyRequest", ...
// HandlePTYReq handles requests of type "pty-req" which allocate a TTY for // "exec" or "shell" requests. The "pty-req" includes the size of the TTY as // well as the terminal type requested.
[ "HandlePTYReq", "handles", "requests", "of", "type", "pty", "-", "req", "which", "allocate", "a", "TTY", "for", "exec", "or", "shell", "requests", ".", "The", "pty", "-", "req", "includes", "the", "size", "of", "the", "TTY", "as", "well", "as", "the", ...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/termhandlers.go#L124-L162
24,341
gravitational/teleport
lib/srv/termhandlers.go
HandleShell
func (t *TermHandlers) HandleShell(ch ssh.Channel, req *ssh.Request, ctx *ServerContext) error { var err error // creating an empty exec request implies a interactive shell was requested ctx.ExecRequest, err = NewExecRequest(ctx, "") if err != nil { return trace.Wrap(err) } if err := t.SessionRegistry.OpenSes...
go
func (t *TermHandlers) HandleShell(ch ssh.Channel, req *ssh.Request, ctx *ServerContext) error { var err error // creating an empty exec request implies a interactive shell was requested ctx.ExecRequest, err = NewExecRequest(ctx, "") if err != nil { return trace.Wrap(err) } if err := t.SessionRegistry.OpenSes...
[ "func", "(", "t", "*", "TermHandlers", ")", "HandleShell", "(", "ch", "ssh", ".", "Channel", ",", "req", "*", "ssh", ".", "Request", ",", "ctx", "*", "ServerContext", ")", "error", "{", "var", "err", "error", "\n\n", "// creating an empty exec request implie...
// HandleShell handles requests of type "shell" which request a interactive // shell be created within a TTY.
[ "HandleShell", "handles", "requests", "of", "type", "shell", "which", "request", "a", "interactive", "shell", "be", "created", "within", "a", "TTY", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/termhandlers.go#L166-L180
24,342
gravitational/teleport
lib/srv/termhandlers.go
HandleWinChange
func (t *TermHandlers) HandleWinChange(ch ssh.Channel, req *ssh.Request, ctx *ServerContext) error { params, err := parseWinChange(req) if err != nil { return trace.Wrap(err) } // Update any other members in the party that the window size has changed // and to update their terminal windows accordingly. err = t...
go
func (t *TermHandlers) HandleWinChange(ch ssh.Channel, req *ssh.Request, ctx *ServerContext) error { params, err := parseWinChange(req) if err != nil { return trace.Wrap(err) } // Update any other members in the party that the window size has changed // and to update their terminal windows accordingly. err = t...
[ "func", "(", "t", "*", "TermHandlers", ")", "HandleWinChange", "(", "ch", "ssh", ".", "Channel", ",", "req", "*", "ssh", ".", "Request", ",", "ctx", "*", "ServerContext", ")", "error", "{", "params", ",", "err", ":=", "parseWinChange", "(", "req", ")",...
// HandleWinChange handles requests of type "window-change" which update the // size of the PTY running on the server and update any other members in the // party.
[ "HandleWinChange", "handles", "requests", "of", "type", "window", "-", "change", "which", "update", "the", "size", "of", "the", "PTY", "running", "on", "the", "server", "and", "update", "any", "other", "members", "in", "the", "party", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/srv/termhandlers.go#L185-L199
24,343
gravitational/teleport
lib/reversetunnel/srv.go
NewServer
func NewServer(cfg Config) (Server, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } ctx, cancel := context.WithCancel(cfg.Context) srv := &server{ Config: cfg, localSites: []*localSite{}, remoteSites: []*remoteSite{}, localAuthClient: cfg.Loca...
go
func NewServer(cfg Config) (Server, error) { if err := cfg.CheckAndSetDefaults(); err != nil { return nil, trace.Wrap(err) } ctx, cancel := context.WithCancel(cfg.Context) srv := &server{ Config: cfg, localSites: []*localSite{}, remoteSites: []*remoteSite{}, localAuthClient: cfg.Loca...
[ "func", "NewServer", "(", "cfg", "Config", ")", "(", "Server", ",", "error", ")", "{", "if", "err", ":=", "cfg", ".", "CheckAndSetDefaults", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "trace", ".", "Wrap", "(", "err", ")", "\n", ...
// NewServer creates and returns a reverse tunnel server which is fully // initialized but hasn't been started yet
[ "NewServer", "creates", "and", "returns", "a", "reverse", "tunnel", "server", "which", "is", "fully", "initialized", "but", "hasn", "t", "been", "started", "yet" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/srv.go#L216-L268
24,344
gravitational/teleport
lib/reversetunnel/srv.go
disconnectClusters
func (s *server) disconnectClusters() error { connectedRemoteClusters := s.getRemoteClusters() if len(connectedRemoteClusters) == 0 { return nil } remoteClusters, err := s.localAuthClient.GetRemoteClusters() if err != nil { return trace.Wrap(err) } remoteMap := remoteClustersMap(remoteClusters) for _, clust...
go
func (s *server) disconnectClusters() error { connectedRemoteClusters := s.getRemoteClusters() if len(connectedRemoteClusters) == 0 { return nil } remoteClusters, err := s.localAuthClient.GetRemoteClusters() if err != nil { return trace.Wrap(err) } remoteMap := remoteClustersMap(remoteClusters) for _, clust...
[ "func", "(", "s", "*", "server", ")", "disconnectClusters", "(", ")", "error", "{", "connectedRemoteClusters", ":=", "s", ".", "getRemoteClusters", "(", ")", "\n", "if", "len", "(", "connectedRemoteClusters", ")", "==", "0", "{", "return", "nil", "\n", "}"...
// disconnectClusters disconnects reverse tunnel connections from remote clusters // that were deleted from the the local cluster side and cleans up in memory objects. // In this case all local trust has been deleted, so all the tunnel connections have to be dropped.
[ "disconnectClusters", "disconnects", "reverse", "tunnel", "connections", "from", "remote", "clusters", "that", "were", "deleted", "from", "the", "the", "local", "cluster", "side", "and", "cleans", "up", "in", "memory", "objects", ".", "In", "this", "case", "all"...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/srv.go#L281-L302
24,345
gravitational/teleport
lib/reversetunnel/srv.go
isHostAuthority
func (s *server) isHostAuthority(auth ssh.PublicKey, address string) bool { keys, err := s.getTrustedCAKeys(services.HostCA) if err != nil { s.Errorf("failed to retrieve trusted keys, err: %v", err) return false } for _, k := range keys { if sshutils.KeysEqual(k, auth) { return true } } return false }
go
func (s *server) isHostAuthority(auth ssh.PublicKey, address string) bool { keys, err := s.getTrustedCAKeys(services.HostCA) if err != nil { s.Errorf("failed to retrieve trusted keys, err: %v", err) return false } for _, k := range keys { if sshutils.KeysEqual(k, auth) { return true } } return false }
[ "func", "(", "s", "*", "server", ")", "isHostAuthority", "(", "auth", "ssh", ".", "PublicKey", ",", "address", "string", ")", "bool", "{", "keys", ",", "err", ":=", "s", ".", "getTrustedCAKeys", "(", "services", ".", "HostCA", ")", "\n", "if", "err", ...
// isHostAuthority is called during checking the client key, to see if the signing // key is the real host CA authority key.
[ "isHostAuthority", "is", "called", "during", "checking", "the", "client", "key", "to", "see", "if", "the", "signing", "key", "is", "the", "real", "host", "CA", "authority", "key", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/srv.go#L618-L630
24,346
gravitational/teleport
lib/reversetunnel/srv.go
isUserAuthority
func (s *server) isUserAuthority(auth ssh.PublicKey) bool { keys, err := s.getTrustedCAKeys(services.UserCA) if err != nil { s.Errorf("failed to retrieve trusted keys, err: %v", err) return false } for _, k := range keys { if sshutils.KeysEqual(k, auth) { return true } } return false }
go
func (s *server) isUserAuthority(auth ssh.PublicKey) bool { keys, err := s.getTrustedCAKeys(services.UserCA) if err != nil { s.Errorf("failed to retrieve trusted keys, err: %v", err) return false } for _, k := range keys { if sshutils.KeysEqual(k, auth) { return true } } return false }
[ "func", "(", "s", "*", "server", ")", "isUserAuthority", "(", "auth", "ssh", ".", "PublicKey", ")", "bool", "{", "keys", ",", "err", ":=", "s", ".", "getTrustedCAKeys", "(", "services", ".", "UserCA", ")", "\n", "if", "err", "!=", "nil", "{", "s", ...
// isUserAuthority is called during checking the client key, to see if the signing // key is the real user CA authority key.
[ "isUserAuthority", "is", "called", "during", "checking", "the", "client", "key", "to", "see", "if", "the", "signing", "key", "is", "the", "real", "user", "CA", "authority", "key", "." ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/srv.go#L634-L646
24,347
gravitational/teleport
lib/reversetunnel/srv.go
checkHostCert
func (s *server) checkHostCert(logger *log.Entry, user string, clusterName string, cert *ssh.Certificate) error { if cert.CertType != ssh.HostCert { return trace.BadParameter("expected host cert, got wrong cert type: %d", cert.CertType) } // fetch keys of the certificate authority to check // if there is a match...
go
func (s *server) checkHostCert(logger *log.Entry, user string, clusterName string, cert *ssh.Certificate) error { if cert.CertType != ssh.HostCert { return trace.BadParameter("expected host cert, got wrong cert type: %d", cert.CertType) } // fetch keys of the certificate authority to check // if there is a match...
[ "func", "(", "s", "*", "server", ")", "checkHostCert", "(", "logger", "*", "log", ".", "Entry", ",", "user", "string", ",", "clusterName", "string", ",", "cert", "*", "ssh", ".", "Certificate", ")", "error", "{", "if", "cert", ".", "CertType", "!=", ...
// checkHostCert verifies that host certificate is signed // by the recognized certificate authority
[ "checkHostCert", "verifies", "that", "host", "certificate", "is", "signed", "by", "the", "recognized", "certificate", "authority" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/srv.go#L718-L751
24,348
gravitational/teleport
lib/reversetunnel/srv.go
GetSite
func (s *server) GetSite(name string) (RemoteSite, error) { s.RLock() defer s.RUnlock() for i := range s.remoteSites { if s.remoteSites[i].GetName() == name { return s.remoteSites[i], nil } } for i := range s.localSites { if s.localSites[i].GetName() == name { return s.localSites[i], nil } } for i ...
go
func (s *server) GetSite(name string) (RemoteSite, error) { s.RLock() defer s.RUnlock() for i := range s.remoteSites { if s.remoteSites[i].GetName() == name { return s.remoteSites[i], nil } } for i := range s.localSites { if s.localSites[i].GetName() == name { return s.localSites[i], nil } } for i ...
[ "func", "(", "s", "*", "server", ")", "GetSite", "(", "name", "string", ")", "(", "RemoteSite", ",", "error", ")", "{", "s", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "RUnlock", "(", ")", "\n", "for", "i", ":=", "range", "s", ".", "remot...
// GetSite returns a RemoteSite. The first attempt is to find and return a // remote site and that is what is returned if a remote remote agent has // connected to this proxy. Next we loop over local sites and try and try and // return a local site. If that fails, we return a cluster peer. This happens // when you hit ...
[ "GetSite", "returns", "a", "RemoteSite", ".", "The", "first", "attempt", "is", "to", "find", "and", "return", "a", "remote", "site", "and", "that", "is", "what", "is", "returned", "if", "a", "remote", "remote", "agent", "has", "connected", "to", "this", ...
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/srv.go#L855-L874
24,349
gravitational/teleport
lib/reversetunnel/srv.go
newRemoteSite
func newRemoteSite(srv *server, domainName string) (*remoteSite, error) { connInfo, err := services.NewTunnelConnection( fmt.Sprintf("%v-%v", srv.ID, domainName), services.TunnelConnectionSpecV2{ ClusterName: domainName, ProxyName: srv.ID, LastHeartbeat: time.Now().UTC(), }, ) if err != nil { ...
go
func newRemoteSite(srv *server, domainName string) (*remoteSite, error) { connInfo, err := services.NewTunnelConnection( fmt.Sprintf("%v-%v", srv.ID, domainName), services.TunnelConnectionSpecV2{ ClusterName: domainName, ProxyName: srv.ID, LastHeartbeat: time.Now().UTC(), }, ) if err != nil { ...
[ "func", "newRemoteSite", "(", "srv", "*", "server", ",", "domainName", "string", ")", "(", "*", "remoteSite", ",", "error", ")", "{", "connInfo", ",", "err", ":=", "services", ".", "NewTunnelConnection", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", ...
// newRemoteSite helper creates and initializes 'remoteSite' instance
[ "newRemoteSite", "helper", "creates", "and", "initializes", "remoteSite", "instance" ]
d5243dbe8d36bba44bf640c08f1c49185ed2c8a4
https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/srv.go#L895-L956
24,350
tealeg/xlsx
xmlWorksheet.go
getExtent
func (mc *xlsxMergeCells) getExtent(cellRef string) (int, int, error) { if mc == nil { return 0, 0, nil } for _, cell := range mc.Cells { if strings.HasPrefix(cell.Ref, cellRef+cellRangeChar) { parts := strings.Split(cell.Ref, cellRangeChar) startx, starty, err := GetCoordsFromCellIDString(parts[0]) if ...
go
func (mc *xlsxMergeCells) getExtent(cellRef string) (int, int, error) { if mc == nil { return 0, 0, nil } for _, cell := range mc.Cells { if strings.HasPrefix(cell.Ref, cellRef+cellRangeChar) { parts := strings.Split(cell.Ref, cellRangeChar) startx, starty, err := GetCoordsFromCellIDString(parts[0]) if ...
[ "func", "(", "mc", "*", "xlsxMergeCells", ")", "getExtent", "(", "cellRef", "string", ")", "(", "int", ",", "int", ",", "error", ")", "{", "if", "mc", "==", "nil", "{", "return", "0", ",", "0", ",", "nil", "\n", "}", "\n", "for", "_", ",", "cel...
// Return the cartesian extent of a merged cell range from its origin // cell (the closest merged cell to the to left of the sheet.
[ "Return", "the", "cartesian", "extent", "of", "a", "merged", "cell", "range", "from", "its", "origin", "cell", "(", "the", "closest", "merged", "cell", "to", "the", "to", "left", "of", "the", "sheet", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/xmlWorksheet.go#L312-L331
24,351
tealeg/xlsx
col.go
SetType
func (c *Col) SetType(cellType CellType) { switch cellType { case CellTypeString: c.numFmt = builtInNumFmt[builtInNumFmtIndex_STRING] case CellTypeNumeric: c.numFmt = builtInNumFmt[builtInNumFmtIndex_INT] case CellTypeBool: c.numFmt = builtInNumFmt[builtInNumFmtIndex_GENERAL] //TEMP case CellTypeInline: c....
go
func (c *Col) SetType(cellType CellType) { switch cellType { case CellTypeString: c.numFmt = builtInNumFmt[builtInNumFmtIndex_STRING] case CellTypeNumeric: c.numFmt = builtInNumFmt[builtInNumFmtIndex_INT] case CellTypeBool: c.numFmt = builtInNumFmt[builtInNumFmtIndex_GENERAL] //TEMP case CellTypeInline: c....
[ "func", "(", "c", "*", "Col", ")", "SetType", "(", "cellType", "CellType", ")", "{", "switch", "cellType", "{", "case", "CellTypeString", ":", "c", ".", "numFmt", "=", "builtInNumFmt", "[", "builtInNumFmtIndex_STRING", "]", "\n", "case", "CellTypeNumeric", "...
// SetType will set the format string of a column based on the type that you want to set it to. // This function does not really make a lot of sense.
[ "SetType", "will", "set", "the", "format", "string", "of", "a", "column", "based", "on", "the", "type", "that", "you", "want", "to", "set", "it", "to", ".", "This", "function", "does", "not", "really", "make", "a", "lot", "of", "sense", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/col.go#L23-L42
24,352
tealeg/xlsx
col.go
SetDataValidation
func (c *Col) SetDataValidation(dd *xlsxCellDataValidation, start, end int) { if end < 0 { end = Excel2006MaxRowIndex } dd.minRow = start dd.maxRow = end tmpDD := make([]*xlsxCellDataValidation, 0) for _, item := range c.DataValidation { if item.maxRow < dd.minRow { tmpDD = append(tmpDD, item) //No inter...
go
func (c *Col) SetDataValidation(dd *xlsxCellDataValidation, start, end int) { if end < 0 { end = Excel2006MaxRowIndex } dd.minRow = start dd.maxRow = end tmpDD := make([]*xlsxCellDataValidation, 0) for _, item := range c.DataValidation { if item.maxRow < dd.minRow { tmpDD = append(tmpDD, item) //No inter...
[ "func", "(", "c", "*", "Col", ")", "SetDataValidation", "(", "dd", "*", "xlsxCellDataValidation", ",", "start", ",", "end", "int", ")", "{", "if", "end", "<", "0", "{", "end", "=", "Excel2006MaxRowIndex", "\n", "}", "\n\n", "dd", ".", "minRow", "=", ...
// SetDataValidation set data validation with zero based start and end. // Set end to -1 for all rows.
[ "SetDataValidation", "set", "data", "validation", "with", "zero", "based", "start", "and", "end", ".", "Set", "end", "to", "-", "1", "for", "all", "rows", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/col.go#L56-L93
24,353
tealeg/xlsx
col.go
SetDataValidationWithStart
func (c *Col) SetDataValidationWithStart(dd *xlsxCellDataValidation, start int) { c.SetDataValidation(dd, start, -1) }
go
func (c *Col) SetDataValidationWithStart(dd *xlsxCellDataValidation, start int) { c.SetDataValidation(dd, start, -1) }
[ "func", "(", "c", "*", "Col", ")", "SetDataValidationWithStart", "(", "dd", "*", "xlsxCellDataValidation", ",", "start", "int", ")", "{", "c", ".", "SetDataValidation", "(", "dd", ",", "start", ",", "-", "1", ")", "\n", "}" ]
// SetDataValidationWithStart set data validation with a zero basd start row. // This will apply to the rest of the rest of the column.
[ "SetDataValidationWithStart", "set", "data", "validation", "with", "a", "zero", "basd", "start", "row", ".", "This", "will", "apply", "to", "the", "rest", "of", "the", "rest", "of", "the", "column", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/col.go#L97-L99
24,354
tealeg/xlsx
stream_file_builder.go
NewStreamFileBuilder
func NewStreamFileBuilder(writer io.Writer) *StreamFileBuilder { return &StreamFileBuilder{ zipWriter: zip.NewWriter(writer), xlsxFile: NewFile(), cellTypeToStyleIds: make(map[CellType]int), maxStyleId: initMaxStyleId, } }
go
func NewStreamFileBuilder(writer io.Writer) *StreamFileBuilder { return &StreamFileBuilder{ zipWriter: zip.NewWriter(writer), xlsxFile: NewFile(), cellTypeToStyleIds: make(map[CellType]int), maxStyleId: initMaxStyleId, } }
[ "func", "NewStreamFileBuilder", "(", "writer", "io", ".", "Writer", ")", "*", "StreamFileBuilder", "{", "return", "&", "StreamFileBuilder", "{", "zipWriter", ":", "zip", ".", "NewWriter", "(", "writer", ")", ",", "xlsxFile", ":", "NewFile", "(", ")", ",", ...
// NewStreamFileBuilder creates an StreamFileBuilder that will write to the the provided io.writer
[ "NewStreamFileBuilder", "creates", "an", "StreamFileBuilder", "that", "will", "write", "to", "the", "the", "provided", "io", ".", "writer" ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/stream_file_builder.go#L58-L65
24,355
tealeg/xlsx
stream_file_builder.go
NewStreamFileBuilderForPath
func NewStreamFileBuilderForPath(path string) (*StreamFileBuilder, error) { file, err := os.Create(path) if err != nil { return nil, err } return NewStreamFileBuilder(file), nil }
go
func NewStreamFileBuilderForPath(path string) (*StreamFileBuilder, error) { file, err := os.Create(path) if err != nil { return nil, err } return NewStreamFileBuilder(file), nil }
[ "func", "NewStreamFileBuilderForPath", "(", "path", "string", ")", "(", "*", "StreamFileBuilder", ",", "error", ")", "{", "file", ",", "err", ":=", "os", ".", "Create", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err",...
// NewStreamFileBuilderForPath takes the name of an XLSX file and returns a builder for it. // The file will be created if it does not exist, or truncated if it does.
[ "NewStreamFileBuilderForPath", "takes", "the", "name", "of", "an", "XLSX", "file", "and", "returns", "a", "builder", "for", "it", ".", "The", "file", "will", "be", "created", "if", "it", "does", "not", "exist", "or", "truncated", "if", "it", "does", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/stream_file_builder.go#L69-L75
24,356
tealeg/xlsx
stream_file_builder.go
AddSheet
func (sb *StreamFileBuilder) AddSheet(name string, headers []string, cellTypes []*CellType) error { if sb.built { return BuiltStreamFileBuilderError } if len(cellTypes) > len(headers) { return errors.New("cellTypes is longer than headers") } sheet, err := sb.xlsxFile.AddSheet(name) if err != nil { // Set bu...
go
func (sb *StreamFileBuilder) AddSheet(name string, headers []string, cellTypes []*CellType) error { if sb.built { return BuiltStreamFileBuilderError } if len(cellTypes) > len(headers) { return errors.New("cellTypes is longer than headers") } sheet, err := sb.xlsxFile.AddSheet(name) if err != nil { // Set bu...
[ "func", "(", "sb", "*", "StreamFileBuilder", ")", "AddSheet", "(", "name", "string", ",", "headers", "[", "]", "string", ",", "cellTypes", "[", "]", "*", "CellType", ")", "error", "{", "if", "sb", ".", "built", "{", "return", "BuiltStreamFileBuilderError",...
// AddSheet will add sheets with the given name with the provided headers. The headers cannot be edited later, and all // rows written to the sheet must contain the same number of cells as the header. Sheet names must be unique, or an // error will be thrown.
[ "AddSheet", "will", "add", "sheets", "with", "the", "given", "name", "with", "the", "provided", "headers", ".", "The", "headers", "cannot", "be", "edited", "later", "and", "all", "rows", "written", "to", "the", "sheet", "must", "contain", "the", "same", "n...
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/stream_file_builder.go#L80-L120
24,357
tealeg/xlsx
stream_file_builder.go
AddValidation
func (sb *StreamFileBuilder) AddValidation(sheetIndex, colIndex, rowStartIndex int, validation *xlsxCellDataValidation) { sheet := sb.xlsxFile.Sheets[sheetIndex] column := sheet.Col(colIndex) column.SetDataValidationWithStart(validation, rowStartIndex) }
go
func (sb *StreamFileBuilder) AddValidation(sheetIndex, colIndex, rowStartIndex int, validation *xlsxCellDataValidation) { sheet := sb.xlsxFile.Sheets[sheetIndex] column := sheet.Col(colIndex) column.SetDataValidationWithStart(validation, rowStartIndex) }
[ "func", "(", "sb", "*", "StreamFileBuilder", ")", "AddValidation", "(", "sheetIndex", ",", "colIndex", ",", "rowStartIndex", "int", ",", "validation", "*", "xlsxCellDataValidation", ")", "{", "sheet", ":=", "sb", ".", "xlsxFile", ".", "Sheets", "[", "sheetInde...
// AddValidation will add a validation to a specific column.
[ "AddValidation", "will", "add", "a", "validation", "to", "a", "specific", "column", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/stream_file_builder.go#L123-L127
24,358
tealeg/xlsx
stream_file_builder.go
Build
func (sb *StreamFileBuilder) Build() (*StreamFile, error) { if sb.built { return nil, BuiltStreamFileBuilderError } sb.built = true parts, err := sb.xlsxFile.MarshallParts() if err != nil { return nil, err } es := &StreamFile{ zipWriter: sb.zipWriter, xlsxFile: sb.xlsxFile, sheetXmlPrefix: m...
go
func (sb *StreamFileBuilder) Build() (*StreamFile, error) { if sb.built { return nil, BuiltStreamFileBuilderError } sb.built = true parts, err := sb.xlsxFile.MarshallParts() if err != nil { return nil, err } es := &StreamFile{ zipWriter: sb.zipWriter, xlsxFile: sb.xlsxFile, sheetXmlPrefix: m...
[ "func", "(", "sb", "*", "StreamFileBuilder", ")", "Build", "(", ")", "(", "*", "StreamFile", ",", "error", ")", "{", "if", "sb", ".", "built", "{", "return", "nil", ",", "BuiltStreamFileBuilderError", "\n", "}", "\n", "sb", ".", "built", "=", "true", ...
// Build begins streaming the XLSX file to the io, by writing all the XLSX metadata. It creates a StreamFile struct // that can be used to write the rows to the sheets.
[ "Build", "begins", "streaming", "the", "XLSX", "file", "to", "the", "io", "by", "writing", "all", "the", "XLSX", "metadata", ".", "It", "creates", "a", "StreamFile", "struct", "that", "can", "be", "used", "to", "write", "the", "rows", "to", "the", "sheet...
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/stream_file_builder.go#L131-L170
24,359
tealeg/xlsx
stream_file_builder.go
processEmptySheetXML
func (sb *StreamFileBuilder) processEmptySheetXML(sf *StreamFile, path, data string) error { // Get the sheet index from the path sheetIndex, err := getSheetIndex(sf, path) if err != nil { return err } // Remove the Dimension tag. Since more rows are going to be written to the sheet, it will be wrong. // It is...
go
func (sb *StreamFileBuilder) processEmptySheetXML(sf *StreamFile, path, data string) error { // Get the sheet index from the path sheetIndex, err := getSheetIndex(sf, path) if err != nil { return err } // Remove the Dimension tag. Since more rows are going to be written to the sheet, it will be wrong. // It is...
[ "func", "(", "sb", "*", "StreamFileBuilder", ")", "processEmptySheetXML", "(", "sf", "*", "StreamFile", ",", "path", ",", "data", "string", ")", "error", "{", "// Get the sheet index from the path", "sheetIndex", ",", "err", ":=", "getSheetIndex", "(", "sf", ","...
// processEmptySheetXML will take in the path and XML data of an empty sheet, and will save the beginning and end of the // XML file so that these can be written at the right time.
[ "processEmptySheetXML", "will", "take", "in", "the", "path", "and", "XML", "data", "of", "an", "empty", "sheet", "and", "will", "save", "the", "beginning", "and", "end", "of", "the", "XML", "file", "so", "that", "these", "can", "be", "written", "at", "th...
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/stream_file_builder.go#L174-L196
24,360
tealeg/xlsx
stream_file_builder.go
removeDimensionTag
func removeDimensionTag(data string, sheet *Sheet) (string, error) { x := len(sheet.Cols) - 1 y := len(sheet.Rows) - 1 if x < 0 { x = 0 } if y < 0 { y = 0 } var dimensionRef string if x == 0 && y == 0 { dimensionRef = "A1" } else { endCoordinate := GetCellIDStringFromCoords(x, y) dimensionRef = "A1:"...
go
func removeDimensionTag(data string, sheet *Sheet) (string, error) { x := len(sheet.Cols) - 1 y := len(sheet.Rows) - 1 if x < 0 { x = 0 } if y < 0 { y = 0 } var dimensionRef string if x == 0 && y == 0 { dimensionRef = "A1" } else { endCoordinate := GetCellIDStringFromCoords(x, y) dimensionRef = "A1:"...
[ "func", "removeDimensionTag", "(", "data", "string", ",", "sheet", "*", "Sheet", ")", "(", "string", ",", "error", ")", "{", "x", ":=", "len", "(", "sheet", ".", "Cols", ")", "-", "1", "\n", "y", ":=", "len", "(", "sheet", ".", "Rows", ")", "-", ...
// removeDimensionTag will return the passed in XLSX Spreadsheet XML with the dimension tag removed. // data is the XML data for the sheet // sheet is the Sheet struct that the XML was created from. // Can return an error if the XML's dimension tag does not match was is expected based on the provided Sheet
[ "removeDimensionTag", "will", "return", "the", "passed", "in", "XLSX", "Spreadsheet", "XML", "with", "the", "dimension", "tag", "removed", ".", "data", "is", "the", "XML", "data", "for", "the", "sheet", "sheet", "is", "the", "Sheet", "struct", "that", "the",...
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/stream_file_builder.go#L220-L241
24,361
tealeg/xlsx
stream_file_builder.go
splitSheetIntoPrefixAndSuffix
func splitSheetIntoPrefixAndSuffix(data string) (string, string, error) { // Split the sheet at the end of its SheetData tag so that more rows can be added inside. sheetParts := strings.Split(data, endSheetDataTag) if len(sheetParts) != 2 { return "", "", errors.New("unexpected Sheet XML: SheetData close tag not f...
go
func splitSheetIntoPrefixAndSuffix(data string) (string, string, error) { // Split the sheet at the end of its SheetData tag so that more rows can be added inside. sheetParts := strings.Split(data, endSheetDataTag) if len(sheetParts) != 2 { return "", "", errors.New("unexpected Sheet XML: SheetData close tag not f...
[ "func", "splitSheetIntoPrefixAndSuffix", "(", "data", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "// Split the sheet at the end of its SheetData tag so that more rows can be added inside.", "sheetParts", ":=", "strings", ".", "Split", "(", "data", ...
// splitSheetIntoPrefixAndSuffix will split the provided XML sheet into a prefix and a suffix so that // more spreadsheet rows can be inserted in between.
[ "splitSheetIntoPrefixAndSuffix", "will", "split", "the", "provided", "XML", "sheet", "into", "a", "prefix", "and", "a", "suffix", "so", "that", "more", "spreadsheet", "rows", "can", "be", "inserted", "in", "between", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/stream_file_builder.go#L245-L252
24,362
tealeg/xlsx
stream_file.go
Write
func (sf *StreamFile) Write(cells []string) error { if sf.err != nil { return sf.err } err := sf.write(cells) if err != nil { sf.err = err return err } return sf.zipWriter.Flush() }
go
func (sf *StreamFile) Write(cells []string) error { if sf.err != nil { return sf.err } err := sf.write(cells) if err != nil { sf.err = err return err } return sf.zipWriter.Flush() }
[ "func", "(", "sf", "*", "StreamFile", ")", "Write", "(", "cells", "[", "]", "string", ")", "error", "{", "if", "sf", ".", "err", "!=", "nil", "{", "return", "sf", ".", "err", "\n", "}", "\n", "err", ":=", "sf", ".", "write", "(", "cells", ")", ...
// Write will write a row of cells to the current sheet. Every call to Write on the same sheet must contain the // same number of cells as the header provided when the sheet was created or an error will be returned. This function // will always trigger a flush on success. Currently the only supported data type is strin...
[ "Write", "will", "write", "a", "row", "of", "cells", "to", "the", "current", "sheet", ".", "Every", "call", "to", "Write", "on", "the", "same", "sheet", "must", "contain", "the", "same", "number", "of", "cells", "as", "the", "header", "provided", "when",...
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/stream_file.go#L42-L52
24,363
tealeg/xlsx
stream_file.go
NextSheet
func (sf *StreamFile) NextSheet() error { if sf.err != nil { return sf.err } var sheetIndex int if sf.currentSheet != nil { if sf.currentSheet.index >= len(sf.xlsxFile.Sheets) { sf.err = AlreadyOnLastSheetError return AlreadyOnLastSheetError } if err := sf.writeSheetEnd(); err != nil { sf.currentSh...
go
func (sf *StreamFile) NextSheet() error { if sf.err != nil { return sf.err } var sheetIndex int if sf.currentSheet != nil { if sf.currentSheet.index >= len(sf.xlsxFile.Sheets) { sf.err = AlreadyOnLastSheetError return AlreadyOnLastSheetError } if err := sf.writeSheetEnd(); err != nil { sf.currentSh...
[ "func", "(", "sf", "*", "StreamFile", ")", "NextSheet", "(", ")", "error", "{", "if", "sf", ".", "err", "!=", "nil", "{", "return", "sf", ".", "err", "\n", "}", "\n", "var", "sheetIndex", "int", "\n", "if", "sf", ".", "currentSheet", "!=", "nil", ...
// NextSheet will switch to the next sheet. Sheets are selected in the same order they were added. // Once you leave a sheet, you cannot return to it.
[ "NextSheet", "will", "switch", "to", "the", "next", "sheet", ".", "Sheets", "are", "selected", "in", "the", "same", "order", "they", "were", "added", ".", "Once", "you", "leave", "a", "sheet", "you", "cannot", "return", "to", "it", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/stream_file.go#L128-L165
24,364
tealeg/xlsx
stream_file.go
Close
func (sf *StreamFile) Close() error { if sf.err != nil { return sf.err } // If there are sheets that have not been written yet, call NextSheet() which will add files to the zip for them. // XLSX readers may error if the sheets registered in the metadata are not present in the file. if sf.currentSheet != nil { ...
go
func (sf *StreamFile) Close() error { if sf.err != nil { return sf.err } // If there are sheets that have not been written yet, call NextSheet() which will add files to the zip for them. // XLSX readers may error if the sheets registered in the metadata are not present in the file. if sf.currentSheet != nil { ...
[ "func", "(", "sf", "*", "StreamFile", ")", "Close", "(", ")", "error", "{", "if", "sf", ".", "err", "!=", "nil", "{", "return", "sf", ".", "err", "\n", "}", "\n", "// If there are sheets that have not been written yet, call NextSheet() which will add files to the zi...
// Close closes the Stream File. // Any sheets that have not yet been written to will have an empty sheet created for them.
[ "Close", "closes", "the", "Stream", "File", ".", "Any", "sheets", "that", "have", "not", "yet", "been", "written", "to", "will", "have", "an", "empty", "sheet", "created", "for", "them", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/stream_file.go#L169-L193
24,365
tealeg/xlsx
stream_file.go
writeSheetStart
func (sf *StreamFile) writeSheetStart() error { if sf.currentSheet == nil { return NoCurrentSheetError } return sf.currentSheet.write(sf.sheetXmlPrefix[sf.currentSheet.index-1]) }
go
func (sf *StreamFile) writeSheetStart() error { if sf.currentSheet == nil { return NoCurrentSheetError } return sf.currentSheet.write(sf.sheetXmlPrefix[sf.currentSheet.index-1]) }
[ "func", "(", "sf", "*", "StreamFile", ")", "writeSheetStart", "(", ")", "error", "{", "if", "sf", ".", "currentSheet", "==", "nil", "{", "return", "NoCurrentSheetError", "\n", "}", "\n", "return", "sf", ".", "currentSheet", ".", "write", "(", "sf", ".", ...
// writeSheetStart will write the start of the Sheet's XML
[ "writeSheetStart", "will", "write", "the", "start", "of", "the", "Sheet", "s", "XML" ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/stream_file.go#L196-L201
24,366
tealeg/xlsx
stream_file.go
writeSheetEnd
func (sf *StreamFile) writeSheetEnd() error { if sf.currentSheet == nil { return NoCurrentSheetError } if err := sf.currentSheet.write(endSheetDataTag); err != nil { return err } return sf.currentSheet.write(sf.sheetXmlSuffix[sf.currentSheet.index-1]) }
go
func (sf *StreamFile) writeSheetEnd() error { if sf.currentSheet == nil { return NoCurrentSheetError } if err := sf.currentSheet.write(endSheetDataTag); err != nil { return err } return sf.currentSheet.write(sf.sheetXmlSuffix[sf.currentSheet.index-1]) }
[ "func", "(", "sf", "*", "StreamFile", ")", "writeSheetEnd", "(", ")", "error", "{", "if", "sf", ".", "currentSheet", "==", "nil", "{", "return", "NoCurrentSheetError", "\n", "}", "\n", "if", "err", ":=", "sf", ".", "currentSheet", ".", "write", "(", "e...
// writeSheetEnd will write the end of the Sheet's XML
[ "writeSheetEnd", "will", "write", "the", "end", "of", "the", "Sheet", "s", "XML" ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/stream_file.go#L204-L212
24,367
tealeg/xlsx
format_code.go
compareFormatString
func compareFormatString(fmt1, fmt2 string) bool { if fmt1 == fmt2 { return true } if fmt1 == "" || strings.EqualFold(fmt1, "general") { fmt1 = "general" } if fmt2 == "" || strings.EqualFold(fmt2, "general") { fmt2 = "general" } return fmt1 == fmt2 }
go
func compareFormatString(fmt1, fmt2 string) bool { if fmt1 == fmt2 { return true } if fmt1 == "" || strings.EqualFold(fmt1, "general") { fmt1 = "general" } if fmt2 == "" || strings.EqualFold(fmt2, "general") { fmt2 = "general" } return fmt1 == fmt2 }
[ "func", "compareFormatString", "(", "fmt1", ",", "fmt2", "string", ")", "bool", "{", "if", "fmt1", "==", "fmt2", "{", "return", "true", "\n", "}", "\n", "if", "fmt1", "==", "\"", "\"", "||", "strings", ".", "EqualFold", "(", "fmt1", ",", "\"", "\"", ...
// Format strings are a little strange to compare because empty string needs to be taken as general, and general needs // to be compared case insensitively.
[ "Format", "strings", "are", "a", "little", "strange", "to", "compare", "because", "empty", "string", "needs", "to", "be", "taken", "as", "general", "and", "general", "needs", "to", "be", "compared", "case", "insensitively", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/format_code.go#L224-L235
24,368
tealeg/xlsx
format_code.go
splitFormatOnSemicolon
func splitFormatOnSemicolon(format string) ([]string, error) { var formats []string prevIndex := 0 for i := 0; i < len(format); i++ { if format[i] == ';' { formats = append(formats, format[prevIndex:i]) prevIndex = i + 1 } else if format[i] == '\\' { i++ } else if format[i] == '"' { endQuoteIndex :...
go
func splitFormatOnSemicolon(format string) ([]string, error) { var formats []string prevIndex := 0 for i := 0; i < len(format); i++ { if format[i] == ';' { formats = append(formats, format[prevIndex:i]) prevIndex = i + 1 } else if format[i] == '\\' { i++ } else if format[i] == '"' { endQuoteIndex :...
[ "func", "splitFormatOnSemicolon", "(", "format", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "formats", "[", "]", "string", "\n", "prevIndex", ":=", "0", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "format", "...
// splitFormatOnSemicolon will split the format string into the format sections // This logic to split the different formats on semicolon is fully correct, and will skip all literal semicolons, // and will catch all breaking semicolons.
[ "splitFormatOnSemicolon", "will", "split", "the", "format", "string", "into", "the", "format", "sections", "This", "logic", "to", "split", "the", "different", "formats", "on", "semicolon", "is", "fully", "correct", "and", "will", "skip", "all", "literal", "semic...
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/format_code.go#L315-L334
24,369
tealeg/xlsx
data_validation.go
SetError
func (dd *xlsxCellDataValidation) SetError(style DataValidationErrorStyle, title, msg *string) { dd.ShowErrorMessage = true dd.Error = msg dd.ErrorTitle = title strStyle := styleStop switch style { case StyleStop: strStyle = styleStop case StyleWarning: strStyle = styleWarning case StyleInformation: strSt...
go
func (dd *xlsxCellDataValidation) SetError(style DataValidationErrorStyle, title, msg *string) { dd.ShowErrorMessage = true dd.Error = msg dd.ErrorTitle = title strStyle := styleStop switch style { case StyleStop: strStyle = styleStop case StyleWarning: strStyle = styleWarning case StyleInformation: strSt...
[ "func", "(", "dd", "*", "xlsxCellDataValidation", ")", "SetError", "(", "style", "DataValidationErrorStyle", ",", "title", ",", "msg", "*", "string", ")", "{", "dd", ".", "ShowErrorMessage", "=", "true", "\n", "dd", ".", "Error", "=", "msg", "\n", "dd", ...
// SetError set error notice
[ "SetError", "set", "error", "notice" ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/data_validation.go#L72-L87
24,370
tealeg/xlsx
data_validation.go
SetRange
func (dd *xlsxCellDataValidation) SetRange(f1, f2 int, t DataValidationType, o DataValidationOperator) error { formula1 := fmt.Sprintf("%d", f1) formula2 := fmt.Sprintf("%d", f2) switch o { case DataValidationOperatorBetween: if f1 > f2 { tmp := formula1 formula1 = formula2 formula2 = tmp } case Data...
go
func (dd *xlsxCellDataValidation) SetRange(f1, f2 int, t DataValidationType, o DataValidationOperator) error { formula1 := fmt.Sprintf("%d", f1) formula2 := fmt.Sprintf("%d", f2) switch o { case DataValidationOperatorBetween: if f1 > f2 { tmp := formula1 formula1 = formula2 formula2 = tmp } case Data...
[ "func", "(", "dd", "*", "xlsxCellDataValidation", ")", "SetRange", "(", "f1", ",", "f2", "int", ",", "t", "DataValidationType", ",", "o", "DataValidationOperator", ")", "error", "{", "formula1", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "f1", ")...
// SetDropList data validation range
[ "SetDropList", "data", "validation", "range" ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/data_validation.go#L131-L155
24,371
tealeg/xlsx
style.go
NewStyle
func NewStyle() *Style { return &Style{ Alignment: *DefaultAlignment(), Border: *DefaultBorder(), Fill: *DefaultFill(), Font: *DefaultFont(), } }
go
func NewStyle() *Style { return &Style{ Alignment: *DefaultAlignment(), Border: *DefaultBorder(), Fill: *DefaultFill(), Font: *DefaultFont(), } }
[ "func", "NewStyle", "(", ")", "*", "Style", "{", "return", "&", "Style", "{", "Alignment", ":", "*", "DefaultAlignment", "(", ")", ",", "Border", ":", "*", "DefaultBorder", "(", ")", ",", "Fill", ":", "*", "DefaultFill", "(", ")", ",", "Font", ":", ...
// Return a new Style structure initialised with the default values.
[ "Return", "a", "new", "Style", "structure", "initialised", "with", "the", "default", "values", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/style.go#L20-L27
24,372
tealeg/xlsx
style.go
makeXLSXStyleElements
func (style *Style) makeXLSXStyleElements() (xFont xlsxFont, xFill xlsxFill, xBorder xlsxBorder, xCellXf xlsxXf) { xFont = xlsxFont{} xFill = xlsxFill{} xBorder = xlsxBorder{} xCellXf = xlsxXf{} xFont.Sz.Val = strconv.Itoa(style.Font.Size) xFont.Name.Val = style.Font.Name xFont.Family.Val = strconv.Itoa(style.Fo...
go
func (style *Style) makeXLSXStyleElements() (xFont xlsxFont, xFill xlsxFill, xBorder xlsxBorder, xCellXf xlsxXf) { xFont = xlsxFont{} xFill = xlsxFill{} xBorder = xlsxBorder{} xCellXf = xlsxXf{} xFont.Sz.Val = strconv.Itoa(style.Font.Size) xFont.Name.Val = style.Font.Name xFont.Family.Val = strconv.Itoa(style.Fo...
[ "func", "(", "style", "*", "Style", ")", "makeXLSXStyleElements", "(", ")", "(", "xFont", "xlsxFont", ",", "xFill", "xlsxFill", ",", "xBorder", "xlsxBorder", ",", "xCellXf", "xlsxXf", ")", "{", "xFont", "=", "xlsxFont", "{", "}", "\n", "xFill", "=", "xls...
// Generate the underlying XLSX style elements that correspond to the Style.
[ "Generate", "the", "underlying", "XLSX", "style", "elements", "that", "correspond", "to", "the", "Style", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/style.go#L30-L85
24,373
tealeg/xlsx
lib.go
ColIndexToLetters
func ColIndexToLetters(colRef int) string { parts := intToBase26(colRef) return formatColumnName(smooshBase26Slice(parts)) }
go
func ColIndexToLetters(colRef int) string { parts := intToBase26(colRef) return formatColumnName(smooshBase26Slice(parts)) }
[ "func", "ColIndexToLetters", "(", "colRef", "int", ")", "string", "{", "parts", ":=", "intToBase26", "(", "colRef", ")", "\n", "return", "formatColumnName", "(", "smooshBase26Slice", "(", "parts", ")", ")", "\n", "}" ]
// ColIndexToLetters is used to convert a zero based, numeric column // indentifier into a character code.
[ "ColIndexToLetters", "is", "used", "to", "convert", "a", "zero", "based", "numeric", "column", "indentifier", "into", "a", "character", "code", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/lib.go#L147-L150
24,374
tealeg/xlsx
lib.go
GetCellIDStringFromCoords
func GetCellIDStringFromCoords(x, y int) string { return GetCellIDStringFromCoordsWithFixed(x, y, false, false) }
go
func GetCellIDStringFromCoords(x, y int) string { return GetCellIDStringFromCoordsWithFixed(x, y, false, false) }
[ "func", "GetCellIDStringFromCoords", "(", "x", ",", "y", "int", ")", "string", "{", "return", "GetCellIDStringFromCoordsWithFixed", "(", "x", ",", "y", ",", "false", ",", "false", ")", "\n", "}" ]
// GetCellIDStringFromCoords returns the Excel format cell name that // represents a pair of zero based cartesian coordinates.
[ "GetCellIDStringFromCoords", "returns", "the", "Excel", "format", "cell", "name", "that", "represents", "a", "pair", "of", "zero", "based", "cartesian", "coordinates", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/lib.go#L195-L197
24,375
tealeg/xlsx
lib.go
GetCellIDStringFromCoordsWithFixed
func GetCellIDStringFromCoordsWithFixed(x, y int, xFixed, yFixed bool) string { xStr := ColIndexToLetters(x) if xFixed { xStr = fixedCellRefChar + xStr } yStr := RowIndexToString(y) if yFixed { yStr = fixedCellRefChar + yStr } return xStr + yStr }
go
func GetCellIDStringFromCoordsWithFixed(x, y int, xFixed, yFixed bool) string { xStr := ColIndexToLetters(x) if xFixed { xStr = fixedCellRefChar + xStr } yStr := RowIndexToString(y) if yFixed { yStr = fixedCellRefChar + yStr } return xStr + yStr }
[ "func", "GetCellIDStringFromCoordsWithFixed", "(", "x", ",", "y", "int", ",", "xFixed", ",", "yFixed", "bool", ")", "string", "{", "xStr", ":=", "ColIndexToLetters", "(", "x", ")", "\n", "if", "xFixed", "{", "xStr", "=", "fixedCellRefChar", "+", "xStr", "\...
// GetCellIDStringFromCoordsWithFixed returns the Excel format cell name that // represents a pair of zero based cartesian coordinates. // It can specify either value as fixed.
[ "GetCellIDStringFromCoordsWithFixed", "returns", "the", "Excel", "format", "cell", "name", "that", "represents", "a", "pair", "of", "zero", "based", "cartesian", "coordinates", ".", "It", "can", "specify", "either", "value", "as", "fixed", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/lib.go#L202-L212
24,376
tealeg/xlsx
lib.go
calculateMaxMinFromWorksheet
func calculateMaxMinFromWorksheet(worksheet *xlsxWorksheet) (minx, miny, maxx, maxy int, err error) { // Note, this method could be very slow for large spreadsheets. var x, y int var maxVal int maxVal = int(^uint(0) >> 1) minx = maxVal miny = maxVal maxy = 0 maxx = 0 for _, row := range worksheet.SheetData.Row...
go
func calculateMaxMinFromWorksheet(worksheet *xlsxWorksheet) (minx, miny, maxx, maxy int, err error) { // Note, this method could be very slow for large spreadsheets. var x, y int var maxVal int maxVal = int(^uint(0) >> 1) minx = maxVal miny = maxVal maxy = 0 maxx = 0 for _, row := range worksheet.SheetData.Row...
[ "func", "calculateMaxMinFromWorksheet", "(", "worksheet", "*", "xlsxWorksheet", ")", "(", "minx", ",", "miny", ",", "maxx", ",", "maxy", "int", ",", "err", "error", ")", "{", "// Note, this method could be very slow for large spreadsheets.", "var", "x", ",", "y", ...
// calculateMaxMinFromWorkSheet works out the dimensions of a spreadsheet // that doesn't have a DimensionRef set. The only case currently // known where this is true is with XLSX exported from Google Docs. // This is also true for XLSX files created through the streaming APIs.
[ "calculateMaxMinFromWorkSheet", "works", "out", "the", "dimensions", "of", "a", "spreadsheet", "that", "doesn", "t", "have", "a", "DimensionRef", "set", ".", "The", "only", "case", "currently", "known", "where", "this", "is", "true", "is", "with", "XLSX", "exp...
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/lib.go#L236-L272
24,377
tealeg/xlsx
lib.go
makeRowFromRaw
func makeRowFromRaw(rawrow xlsxRow, sheet *Sheet) *Row { var upper int var row *Row var cell *Cell row = new(Row) row.Sheet = sheet upper = -1 for _, rawcell := range rawrow.C { if rawcell.R != "" { x, _, error := GetCoordsFromCellIDString(rawcell.R) if error != nil { panic(fmt.Sprintf("Invalid Cel...
go
func makeRowFromRaw(rawrow xlsxRow, sheet *Sheet) *Row { var upper int var row *Row var cell *Cell row = new(Row) row.Sheet = sheet upper = -1 for _, rawcell := range rawrow.C { if rawcell.R != "" { x, _, error := GetCoordsFromCellIDString(rawcell.R) if error != nil { panic(fmt.Sprintf("Invalid Cel...
[ "func", "makeRowFromRaw", "(", "rawrow", "xlsxRow", ",", "sheet", "*", "Sheet", ")", "*", "Row", "{", "var", "upper", "int", "\n", "var", "row", "*", "Row", "\n", "var", "cell", "*", "Cell", "\n\n", "row", "=", "new", "(", "Row", ")", "\n", "row", ...
// makeRowFromRaw returns the Row representation of the xlsxRow.
[ "makeRowFromRaw", "returns", "the", "Row", "representation", "of", "the", "xlsxRow", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/lib.go#L301-L334
24,378
tealeg/xlsx
lib.go
fillCellDataFromInlineString
func fillCellDataFromInlineString(rawcell xlsxC, cell *Cell) { cell.Value = "" if rawcell.Is != nil { if rawcell.Is.T != "" { cell.Value = strings.Trim(rawcell.Is.T, " \t\n\r") } else { for _, r := range rawcell.Is.R { cell.Value += r.T } } } }
go
func fillCellDataFromInlineString(rawcell xlsxC, cell *Cell) { cell.Value = "" if rawcell.Is != nil { if rawcell.Is.T != "" { cell.Value = strings.Trim(rawcell.Is.T, " \t\n\r") } else { for _, r := range rawcell.Is.R { cell.Value += r.T } } } }
[ "func", "fillCellDataFromInlineString", "(", "rawcell", "xlsxC", ",", "cell", "*", "Cell", ")", "{", "cell", ".", "Value", "=", "\"", "\"", "\n", "if", "rawcell", ".", "Is", "!=", "nil", "{", "if", "rawcell", ".", "Is", ".", "T", "!=", "\"", "\"", ...
// fillCellDataFromInlineString attempts to get inline string data and put it into a Cell.
[ "fillCellDataFromInlineString", "attempts", "to", "get", "inline", "string", "data", "and", "put", "it", "into", "a", "Cell", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/lib.go#L509-L520
24,379
tealeg/xlsx
lib.go
readSheetsFromZipFile
func readSheetsFromZipFile(f *zip.File, file *File, sheetXMLMap map[string]string, rowLimit int) (map[string]*Sheet, []*Sheet, error) { var workbook *xlsxWorkbook var err error var rc io.ReadCloser var decoder *xml.Decoder var sheetCount int workbook = new(xlsxWorkbook) rc, err = f.Open() if err != nil { retu...
go
func readSheetsFromZipFile(f *zip.File, file *File, sheetXMLMap map[string]string, rowLimit int) (map[string]*Sheet, []*Sheet, error) { var workbook *xlsxWorkbook var err error var rc io.ReadCloser var decoder *xml.Decoder var sheetCount int workbook = new(xlsxWorkbook) rc, err = f.Open() if err != nil { retu...
[ "func", "readSheetsFromZipFile", "(", "f", "*", "zip", ".", "File", ",", "file", "*", "File", ",", "sheetXMLMap", "map", "[", "string", "]", "string", ",", "rowLimit", "int", ")", "(", "map", "[", "string", "]", "*", "Sheet", ",", "[", "]", "*", "S...
// readSheetsFromZipFile is an internal helper function that loops // over the Worksheets defined in the XSLXWorkbook and loads them into // Sheet objects stored in the Sheets slice of a xlsx.File struct.
[ "readSheetsFromZipFile", "is", "an", "internal", "helper", "function", "that", "loops", "over", "the", "Worksheets", "defined", "in", "the", "XSLXWorkbook", "and", "loads", "them", "into", "Sheet", "objects", "stored", "in", "the", "Sheets", "slice", "of", "a", ...
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/lib.go#L777-L833
24,380
tealeg/xlsx
lib.go
truncateSheetXML
func truncateSheetXML(r io.Reader, rowLimit int) (io.Reader, error) { var rowCount int var token xml.Token var readErr error output := new(bytes.Buffer) r = io.TeeReader(r, output) decoder := xml.NewDecoder(r) for { token, readErr = decoder.Token() if readErr == io.EOF { break } else if readErr != nil...
go
func truncateSheetXML(r io.Reader, rowLimit int) (io.Reader, error) { var rowCount int var token xml.Token var readErr error output := new(bytes.Buffer) r = io.TeeReader(r, output) decoder := xml.NewDecoder(r) for { token, readErr = decoder.Token() if readErr == io.EOF { break } else if readErr != nil...
[ "func", "truncateSheetXML", "(", "r", "io", ".", "Reader", ",", "rowLimit", "int", ")", "(", "io", ".", "Reader", ",", "error", ")", "{", "var", "rowCount", "int", "\n", "var", "token", "xml", ".", "Token", "\n", "var", "readErr", "error", "\n\n", "o...
// truncateSheetXML will take in a reader to an XML sheet file and will return a reader that will read an equivalent // XML sheet file with only the number of rows specified. This greatly speeds up XML unmarshalling when only // a few rows need to be read from a large sheet. // When sheets are truncated, all formatting...
[ "truncateSheetXML", "will", "take", "in", "a", "reader", "to", "an", "XML", "sheet", "file", "and", "will", "return", "a", "reader", "that", "will", "read", "an", "equivalent", "XML", "sheet", "file", "with", "only", "the", "number", "of", "rows", "specifi...
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/lib.go#L1096-L1131
24,381
tealeg/xlsx
file.go
FileToSliceUnmerged
func FileToSliceUnmerged(path string) ([][][]string, error) { f, err := OpenFile(path) if err != nil { return nil, err } return f.ToSliceUnmerged() }
go
func FileToSliceUnmerged(path string) ([][][]string, error) { f, err := OpenFile(path) if err != nil { return nil, err } return f.ToSliceUnmerged() }
[ "func", "FileToSliceUnmerged", "(", "path", "string", ")", "(", "[", "]", "[", "]", "[", "]", "string", ",", "error", ")", "{", "f", ",", "err", ":=", "OpenFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err",...
// FileToSliceUnmerged is a wrapper around File.ToSliceUnmerged. // It returns the raw data contained in an Excel XLSX file as three // dimensional slice. Merged cells will be unmerged. Covered cells become the // values of theirs origins.
[ "FileToSliceUnmerged", "is", "a", "wrapper", "around", "File", ".", "ToSliceUnmerged", ".", "It", "returns", "the", "raw", "data", "contained", "in", "an", "Excel", "XLSX", "file", "as", "three", "dimensional", "slice", ".", "Merged", "cells", "will", "be", ...
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/file.go#L112-L118
24,382
tealeg/xlsx
sheet.go
AddRowAtIndex
func (s *Sheet) AddRowAtIndex(index int) (*Row, error) { if index < 0 || index > len(s.Rows) { return nil, errors.New("AddRowAtIndex: index out of bounds") } row := &Row{Sheet: s} s.Rows = append(s.Rows, nil) if index < len(s.Rows) { copy(s.Rows[index+1:], s.Rows[index:]) } s.Rows[index] = row if len(s.Row...
go
func (s *Sheet) AddRowAtIndex(index int) (*Row, error) { if index < 0 || index > len(s.Rows) { return nil, errors.New("AddRowAtIndex: index out of bounds") } row := &Row{Sheet: s} s.Rows = append(s.Rows, nil) if index < len(s.Rows) { copy(s.Rows[index+1:], s.Rows[index:]) } s.Rows[index] = row if len(s.Row...
[ "func", "(", "s", "*", "Sheet", ")", "AddRowAtIndex", "(", "index", "int", ")", "(", "*", "Row", ",", "error", ")", "{", "if", "index", "<", "0", "||", "index", ">", "len", "(", "s", ".", "Rows", ")", "{", "return", "nil", ",", "errors", ".", ...
// Add a new Row to a Sheet at a specific index
[ "Add", "a", "new", "Row", "to", "a", "Sheet", "at", "a", "specific", "index" ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/sheet.go#L60-L75
24,383
tealeg/xlsx
sheet.go
RemoveRowAtIndex
func (s *Sheet) RemoveRowAtIndex(index int) error { if index < 0 || index >= len(s.Rows) { return errors.New("RemoveRowAtIndex: index out of bounds") } s.Rows = append(s.Rows[:index], s.Rows[index+1:]...) return nil }
go
func (s *Sheet) RemoveRowAtIndex(index int) error { if index < 0 || index >= len(s.Rows) { return errors.New("RemoveRowAtIndex: index out of bounds") } s.Rows = append(s.Rows[:index], s.Rows[index+1:]...) return nil }
[ "func", "(", "s", "*", "Sheet", ")", "RemoveRowAtIndex", "(", "index", "int", ")", "error", "{", "if", "index", "<", "0", "||", "index", ">=", "len", "(", "s", ".", "Rows", ")", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "...
// Removes a row at a specific index
[ "Removes", "a", "row", "at", "a", "specific", "index" ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/sheet.go#L78-L84
24,384
tealeg/xlsx
sheet.go
handleMerged
func (s *Sheet) handleMerged() { merged := make(map[string]*Cell) for r, row := range s.Rows { for c, cell := range row.Cells { if cell.HMerge > 0 || cell.VMerge > 0 { coord := GetCellIDStringFromCoords(c, r) merged[coord] = cell } } } // This loop iterates over all cells that should be merged a...
go
func (s *Sheet) handleMerged() { merged := make(map[string]*Cell) for r, row := range s.Rows { for c, cell := range row.Cells { if cell.HMerge > 0 || cell.VMerge > 0 { coord := GetCellIDStringFromCoords(c, r) merged[coord] = cell } } } // This loop iterates over all cells that should be merged a...
[ "func", "(", "s", "*", "Sheet", ")", "handleMerged", "(", ")", "{", "merged", ":=", "make", "(", "map", "[", "string", "]", "*", "Cell", ")", "\n\n", "for", "r", ",", "row", ":=", "range", "s", ".", "Rows", "{", "for", "c", ",", "cell", ":=", ...
// When merging cells, the cell may be the 'original' or the 'covered'. // First, figure out which cells are merge starting points. Then create // the necessary cells underlying the merge area. // Then go through all the underlying cells and apply the appropriate // border, based on the original cell.
[ "When", "merging", "cells", "the", "cell", "may", "be", "the", "original", "or", "the", "covered", ".", "First", "figure", "out", "which", "cells", "are", "merge", "starting", "points", ".", "Then", "create", "the", "necessary", "cells", "underlying", "the",...
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/sheet.go#L175-L201
24,385
tealeg/xlsx
cell.go
GetTime
func (c *Cell) GetTime(date1904 bool) (t time.Time, err error) { f, err := c.Float() if err != nil { return t, err } return TimeFromExcelTime(f, date1904), nil }
go
func (c *Cell) GetTime(date1904 bool) (t time.Time, err error) { f, err := c.Float() if err != nil { return t, err } return TimeFromExcelTime(f, date1904), nil }
[ "func", "(", "c", "*", "Cell", ")", "GetTime", "(", "date1904", "bool", ")", "(", "t", "time", ".", "Time", ",", "err", "error", ")", "{", "f", ",", "err", ":=", "c", ".", "Float", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "t",...
//GetTime returns the value of a Cell as a time.Time
[ "GetTime", "returns", "the", "value", "of", "a", "Cell", "as", "a", "time", ".", "Time" ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/cell.go#L111-L117
24,386
tealeg/xlsx
cell.go
SetDateWithOptions
func (c *Cell) SetDateWithOptions(t time.Time, options DateTimeOptions) { _, offset := t.In(options.Location).Zone() t = time.Unix(t.Unix()+int64(offset), 0) c.SetDateTimeWithFormat(TimeToExcelTime(t.In(timeLocationUTC), c.date1904), options.ExcelTimeFormat) }
go
func (c *Cell) SetDateWithOptions(t time.Time, options DateTimeOptions) { _, offset := t.In(options.Location).Zone() t = time.Unix(t.Unix()+int64(offset), 0) c.SetDateTimeWithFormat(TimeToExcelTime(t.In(timeLocationUTC), c.date1904), options.ExcelTimeFormat) }
[ "func", "(", "c", "*", "Cell", ")", "SetDateWithOptions", "(", "t", "time", ".", "Time", ",", "options", "DateTimeOptions", ")", "{", "_", ",", "offset", ":=", "t", ".", "In", "(", "options", ".", "Location", ")", ".", "Zone", "(", ")", "\n", "t", ...
// SetDateWithOptions allows for more granular control when exporting dates and times
[ "SetDateWithOptions", "allows", "for", "more", "granular", "control", "when", "exporting", "dates", "and", "times" ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/cell.go#L177-L181
24,387
tealeg/xlsx
cell.go
setNumeric
func (c *Cell) setNumeric(s string) { c.Value = s c.NumFmt = builtInNumFmt[builtInNumFmtIndex_GENERAL] c.formula = "" c.cellType = CellTypeNumeric }
go
func (c *Cell) setNumeric(s string) { c.Value = s c.NumFmt = builtInNumFmt[builtInNumFmtIndex_GENERAL] c.formula = "" c.cellType = CellTypeNumeric }
[ "func", "(", "c", "*", "Cell", ")", "setNumeric", "(", "s", "string", ")", "{", "c", ".", "Value", "=", "s", "\n", "c", ".", "NumFmt", "=", "builtInNumFmt", "[", "builtInNumFmtIndex_GENERAL", "]", "\n", "c", ".", "formula", "=", "\"", "\"", "\n", "...
// setNumeric sets a cell's value to a number
[ "setNumeric", "sets", "a", "cell", "s", "value", "to", "a", "number" ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/cell.go#L261-L266
24,388
tealeg/xlsx
cell.go
getNumberFormat
func (c *Cell) getNumberFormat() *parsedNumberFormat { if c.parsedNumFmt == nil || c.parsedNumFmt.numFmt != c.NumFmt { c.parsedNumFmt = parseFullNumberFormatString(c.NumFmt) } return c.parsedNumFmt }
go
func (c *Cell) getNumberFormat() *parsedNumberFormat { if c.parsedNumFmt == nil || c.parsedNumFmt.numFmt != c.NumFmt { c.parsedNumFmt = parseFullNumberFormatString(c.NumFmt) } return c.parsedNumFmt }
[ "func", "(", "c", "*", "Cell", ")", "getNumberFormat", "(", ")", "*", "parsedNumberFormat", "{", "if", "c", ".", "parsedNumFmt", "==", "nil", "||", "c", ".", "parsedNumFmt", ".", "numFmt", "!=", "c", ".", "NumFmt", "{", "c", ".", "parsedNumFmt", "=", ...
// getNumberFormat will update the parsedNumFmt struct if it has become out of date, since a cell's NumFmt string is a // public field that could be edited by clients.
[ "getNumberFormat", "will", "update", "the", "parsedNumFmt", "struct", "if", "it", "has", "become", "out", "of", "date", "since", "a", "cell", "s", "NumFmt", "string", "is", "a", "public", "field", "that", "could", "be", "edited", "by", "clients", "." ]
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/cell.go#L357-L362
24,389
tealeg/xlsx
cell.go
FormattedValue
func (c *Cell) FormattedValue() (string, error) { fullFormat := c.getNumberFormat() returnVal, err := fullFormat.FormatValue(c) if fullFormat.parseEncounteredError != nil { return returnVal, *fullFormat.parseEncounteredError } return returnVal, err }
go
func (c *Cell) FormattedValue() (string, error) { fullFormat := c.getNumberFormat() returnVal, err := fullFormat.FormatValue(c) if fullFormat.parseEncounteredError != nil { return returnVal, *fullFormat.parseEncounteredError } return returnVal, err }
[ "func", "(", "c", "*", "Cell", ")", "FormattedValue", "(", ")", "(", "string", ",", "error", ")", "{", "fullFormat", ":=", "c", ".", "getNumberFormat", "(", ")", "\n", "returnVal", ",", "err", ":=", "fullFormat", ".", "FormatValue", "(", "c", ")", "\...
// FormattedValue returns a value, and possibly an error condition // from a Cell. If it is possible to apply a format to the cell // value, it will do so, if not then an error will be returned, along // with the raw value of the Cell.
[ "FormattedValue", "returns", "a", "value", "and", "possibly", "an", "error", "condition", "from", "a", "Cell", ".", "If", "it", "is", "possible", "to", "apply", "a", "format", "to", "the", "cell", "value", "it", "will", "do", "so", "if", "not", "then", ...
b7005b5d48cbd240baa323f68fb644fe072ef088
https://github.com/tealeg/xlsx/blob/b7005b5d48cbd240baa323f68fb644fe072ef088/cell.go#L368-L375
24,390
eclipse/paho.mqtt.golang
packets/connect.go
Validate
func (c *ConnectPacket) Validate() byte { if c.PasswordFlag && !c.UsernameFlag { return ErrRefusedBadUsernameOrPassword } if c.ReservedBit != 0 { //Bad reserved bit return ErrProtocolViolation } if (c.ProtocolName == "MQIsdp" && c.ProtocolVersion != 3) || (c.ProtocolName == "MQTT" && c.ProtocolVersion != 4) ...
go
func (c *ConnectPacket) Validate() byte { if c.PasswordFlag && !c.UsernameFlag { return ErrRefusedBadUsernameOrPassword } if c.ReservedBit != 0 { //Bad reserved bit return ErrProtocolViolation } if (c.ProtocolName == "MQIsdp" && c.ProtocolVersion != 3) || (c.ProtocolName == "MQTT" && c.ProtocolVersion != 4) ...
[ "func", "(", "c", "*", "ConnectPacket", ")", "Validate", "(", ")", "byte", "{", "if", "c", ".", "PasswordFlag", "&&", "!", "c", ".", "UsernameFlag", "{", "return", "ErrRefusedBadUsernameOrPassword", "\n", "}", "\n", "if", "c", ".", "ReservedBit", "!=", "...
//Validate performs validation of the fields of a Connect packet
[ "Validate", "performs", "validation", "of", "the", "fields", "of", "a", "Connect", "packet" ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/packets/connect.go#L123-L148
24,391
eclipse/paho.mqtt.golang
store.go
persistInbound
func persistInbound(s Store, m packets.ControlPacket) { switch m.Details().Qos { case 0: switch m.(type) { case *packets.PubackPacket, *packets.SubackPacket, *packets.UnsubackPacket, *packets.PubcompPacket: // Received a puback. delete matching publish // from obound s.Del(outboundKeyFromMID(m.Details()....
go
func persistInbound(s Store, m packets.ControlPacket) { switch m.Details().Qos { case 0: switch m.(type) { case *packets.PubackPacket, *packets.SubackPacket, *packets.UnsubackPacket, *packets.PubcompPacket: // Received a puback. delete matching publish // from obound s.Del(outboundKeyFromMID(m.Details()....
[ "func", "persistInbound", "(", "s", "Store", ",", "m", "packets", ".", "ControlPacket", ")", "{", "switch", "m", ".", "Details", "(", ")", ".", "Qos", "{", "case", "0", ":", "switch", "m", ".", "(", "type", ")", "{", "case", "*", "packets", ".", ...
// govern which incoming messages are persisted
[ "govern", "which", "incoming", "messages", "are", "persisted" ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/store.go#L105-L136
24,392
eclipse/paho.mqtt.golang
options.go
SetClientID
func (o *ClientOptions) SetClientID(id string) *ClientOptions { o.ClientID = id return o }
go
func (o *ClientOptions) SetClientID(id string) *ClientOptions { o.ClientID = id return o }
[ "func", "(", "o", "*", "ClientOptions", ")", "SetClientID", "(", "id", "string", ")", "*", "ClientOptions", "{", "o", ".", "ClientID", "=", "id", "\n", "return", "o", "\n", "}" ]
// SetClientID will set the client id to be used by this client when // connecting to the MQTT broker. According to the MQTT v3.1 specification, // a client id mus be no longer than 23 characters.
[ "SetClientID", "will", "set", "the", "client", "id", "to", "be", "used", "by", "this", "client", "when", "connecting", "to", "the", "MQTT", "broker", ".", "According", "to", "the", "MQTT", "v3", ".", "1", "specification", "a", "client", "id", "mus", "be"...
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/options.go#L153-L156
24,393
eclipse/paho.mqtt.golang
options.go
SetCleanSession
func (o *ClientOptions) SetCleanSession(clean bool) *ClientOptions { o.CleanSession = clean return o }
go
func (o *ClientOptions) SetCleanSession(clean bool) *ClientOptions { o.CleanSession = clean return o }
[ "func", "(", "o", "*", "ClientOptions", ")", "SetCleanSession", "(", "clean", "bool", ")", "*", "ClientOptions", "{", "o", ".", "CleanSession", "=", "clean", "\n", "return", "o", "\n", "}" ]
// SetCleanSession will set the "clean session" flag in the connect message // when this client connects to an MQTT broker. By setting this flag, you are // indicating that no messages saved by the broker for this client should be // delivered. Any messages that were going to be sent by this client before // diconnecti...
[ "SetCleanSession", "will", "set", "the", "clean", "session", "flag", "in", "the", "connect", "message", "when", "this", "client", "connects", "to", "an", "MQTT", "broker", ".", "By", "setting", "this", "flag", "you", "are", "indicating", "that", "no", "messa...
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/options.go#L189-L192
24,394
eclipse/paho.mqtt.golang
options.go
SetOrderMatters
func (o *ClientOptions) SetOrderMatters(order bool) *ClientOptions { o.Order = order return o }
go
func (o *ClientOptions) SetOrderMatters(order bool) *ClientOptions { o.Order = order return o }
[ "func", "(", "o", "*", "ClientOptions", ")", "SetOrderMatters", "(", "order", "bool", ")", "*", "ClientOptions", "{", "o", ".", "Order", "=", "order", "\n", "return", "o", "\n", "}" ]
// SetOrderMatters will set the message routing to guarantee order within // each QoS level. By default, this value is true. If set to false, // this flag indicates that messages can be delivered asynchronously // from the client to the application and possibly arrive out of order.
[ "SetOrderMatters", "will", "set", "the", "message", "routing", "to", "guarantee", "order", "within", "each", "QoS", "level", ".", "By", "default", "this", "value", "is", "true", ".", "If", "set", "to", "false", "this", "flag", "indicates", "that", "messages"...
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/options.go#L198-L201
24,395
eclipse/paho.mqtt.golang
options.go
SetStore
func (o *ClientOptions) SetStore(s Store) *ClientOptions { o.Store = s return o }
go
func (o *ClientOptions) SetStore(s Store) *ClientOptions { o.Store = s return o }
[ "func", "(", "o", "*", "ClientOptions", ")", "SetStore", "(", "s", "Store", ")", "*", "ClientOptions", "{", "o", ".", "Store", "=", "s", "\n", "return", "o", "\n", "}" ]
// SetStore will set the implementation of the Store interface // used to provide message persistence in cases where QoS levels // QoS_ONE or QoS_TWO are used. If no store is provided, then the // client will use MemoryStore by default.
[ "SetStore", "will", "set", "the", "implementation", "of", "the", "Store", "interface", "used", "to", "provide", "message", "persistence", "in", "cases", "where", "QoS", "levels", "QoS_ONE", "or", "QoS_TWO", "are", "used", ".", "If", "no", "store", "is", "pro...
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/options.go#L215-L218
24,396
eclipse/paho.mqtt.golang
options.go
SetProtocolVersion
func (o *ClientOptions) SetProtocolVersion(pv uint) *ClientOptions { if (pv >= 3 && pv <= 4) || (pv > 0x80) { o.ProtocolVersion = pv o.protocolVersionExplicit = true } return o }
go
func (o *ClientOptions) SetProtocolVersion(pv uint) *ClientOptions { if (pv >= 3 && pv <= 4) || (pv > 0x80) { o.ProtocolVersion = pv o.protocolVersionExplicit = true } return o }
[ "func", "(", "o", "*", "ClientOptions", ")", "SetProtocolVersion", "(", "pv", "uint", ")", "*", "ClientOptions", "{", "if", "(", "pv", ">=", "3", "&&", "pv", "<=", "4", ")", "||", "(", "pv", ">", "0x80", ")", "{", "o", ".", "ProtocolVersion", "=", ...
// SetProtocolVersion sets the MQTT version to be used to connect to the // broker. Legitimate values are currently 3 - MQTT 3.1 or 4 - MQTT 3.1.1
[ "SetProtocolVersion", "sets", "the", "MQTT", "version", "to", "be", "used", "to", "connect", "to", "the", "broker", ".", "Legitimate", "values", "are", "currently", "3", "-", "MQTT", "3", ".", "1", "or", "4", "-", "MQTT", "3", ".", "1", ".", "1" ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/options.go#L239-L245
24,397
eclipse/paho.mqtt.golang
options.go
SetOnConnectHandler
func (o *ClientOptions) SetOnConnectHandler(onConn OnConnectHandler) *ClientOptions { o.OnConnect = onConn return o }
go
func (o *ClientOptions) SetOnConnectHandler(onConn OnConnectHandler) *ClientOptions { o.OnConnect = onConn return o }
[ "func", "(", "o", "*", "ClientOptions", ")", "SetOnConnectHandler", "(", "onConn", "OnConnectHandler", ")", "*", "ClientOptions", "{", "o", ".", "OnConnect", "=", "onConn", "\n", "return", "o", "\n", "}" ]
// SetOnConnectHandler sets the function to be called when the client is connected. Both // at initial connection time and upon automatic reconnect.
[ "SetOnConnectHandler", "sets", "the", "function", "to", "be", "called", "when", "the", "client", "is", "connected", ".", "Both", "at", "initial", "connection", "time", "and", "upon", "automatic", "reconnect", "." ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/options.go#L284-L287
24,398
eclipse/paho.mqtt.golang
options.go
SetConnectionLostHandler
func (o *ClientOptions) SetConnectionLostHandler(onLost ConnectionLostHandler) *ClientOptions { o.OnConnectionLost = onLost return o }
go
func (o *ClientOptions) SetConnectionLostHandler(onLost ConnectionLostHandler) *ClientOptions { o.OnConnectionLost = onLost return o }
[ "func", "(", "o", "*", "ClientOptions", ")", "SetConnectionLostHandler", "(", "onLost", "ConnectionLostHandler", ")", "*", "ClientOptions", "{", "o", ".", "OnConnectionLost", "=", "onLost", "\n", "return", "o", "\n", "}" ]
// SetConnectionLostHandler will set the OnConnectionLost callback to be executed // in the case where the client unexpectedly loses connection with the MQTT broker.
[ "SetConnectionLostHandler", "will", "set", "the", "OnConnectionLost", "callback", "to", "be", "executed", "in", "the", "case", "where", "the", "client", "unexpectedly", "loses", "connection", "with", "the", "MQTT", "broker", "." ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/options.go#L291-L294
24,399
eclipse/paho.mqtt.golang
options.go
SetWriteTimeout
func (o *ClientOptions) SetWriteTimeout(t time.Duration) *ClientOptions { o.WriteTimeout = t return o }
go
func (o *ClientOptions) SetWriteTimeout(t time.Duration) *ClientOptions { o.WriteTimeout = t return o }
[ "func", "(", "o", "*", "ClientOptions", ")", "SetWriteTimeout", "(", "t", "time", ".", "Duration", ")", "*", "ClientOptions", "{", "o", ".", "WriteTimeout", "=", "t", "\n", "return", "o", "\n", "}" ]
// SetWriteTimeout puts a limit on how long a mqtt publish should block until it unblocks with a // timeout error. A duration of 0 never times out. Default 30 seconds
[ "SetWriteTimeout", "puts", "a", "limit", "on", "how", "long", "a", "mqtt", "publish", "should", "block", "until", "it", "unblocks", "with", "a", "timeout", "error", ".", "A", "duration", "of", "0", "never", "times", "out", ".", "Default", "30", "seconds" ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/options.go#L298-L301