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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
17,900 | hhkbp2/go-logging | logger.go | NewManager | func NewManager(logger Logger) *Manager {
return &Manager{
root: logger,
loggers: make(map[string]Node),
loggerMaker: defaultLoggerMaker,
}
} | go | func NewManager(logger Logger) *Manager {
return &Manager{
root: logger,
loggers: make(map[string]Node),
loggerMaker: defaultLoggerMaker,
}
} | [
"func",
"NewManager",
"(",
"logger",
"Logger",
")",
"*",
"Manager",
"{",
"return",
"&",
"Manager",
"{",
"root",
":",
"logger",
",",
"loggers",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"Node",
")",
",",
"loggerMaker",
":",
"defaultLoggerMaker",
",",
... | // Initialize the manager with the root node of the logger hierarchy. | [
"Initialize",
"the",
"manager",
"with",
"the",
"root",
"node",
"of",
"the",
"logger",
"hierarchy",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/logger.go#L552-L558 |
17,901 | hhkbp2/go-logging | logger.go | SetLoggerMaker | func (self *Manager) SetLoggerMaker(maker LoggerMaker) {
self.lock.Lock()
defer self.lock.Unlock()
self.loggerMaker = maker
} | go | func (self *Manager) SetLoggerMaker(maker LoggerMaker) {
self.lock.Lock()
defer self.lock.Unlock()
self.loggerMaker = maker
} | [
"func",
"(",
"self",
"*",
"Manager",
")",
"SetLoggerMaker",
"(",
"maker",
"LoggerMaker",
")",
"{",
"self",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"self",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"self",
".",
"loggerMaker",
"=",
"maker"... | // Set the logger maker to be used when instantiating
// a logger with this manager. | [
"Set",
"the",
"logger",
"maker",
"to",
"be",
"used",
"when",
"instantiating",
"a",
"logger",
"with",
"this",
"manager",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/logger.go#L562-L566 |
17,902 | hhkbp2/go-logging | logger.go | fixupParents | func (self *Manager) fixupParents(logger Logger) {
name := logger.GetName()
index := strings.LastIndex(name, ".")
var parent Logger
for (index > 0) && (parent == nil) {
parentStr := name[:index]
node, ok := self.loggers[parentStr]
if !ok {
self.loggers[parentStr] = NewPlaceHolder(logger)
} else {
swit... | go | func (self *Manager) fixupParents(logger Logger) {
name := logger.GetName()
index := strings.LastIndex(name, ".")
var parent Logger
for (index > 0) && (parent == nil) {
parentStr := name[:index]
node, ok := self.loggers[parentStr]
if !ok {
self.loggers[parentStr] = NewPlaceHolder(logger)
} else {
swit... | [
"func",
"(",
"self",
"*",
"Manager",
")",
"fixupParents",
"(",
"logger",
"Logger",
")",
"{",
"name",
":=",
"logger",
".",
"GetName",
"(",
")",
"\n",
"index",
":=",
"strings",
".",
"LastIndex",
"(",
"name",
",",
"\"",
"\"",
")",
"\n",
"var",
"parent",... | // Ensure that there are either loggers or placeholders all the way from
// the specified logger to the root of the logger hierarchy. | [
"Ensure",
"that",
"there",
"are",
"either",
"loggers",
"or",
"placeholders",
"all",
"the",
"way",
"from",
"the",
"specified",
"logger",
"to",
"the",
"root",
"of",
"the",
"logger",
"hierarchy",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/logger.go#L606-L632 |
17,903 | hhkbp2/go-logging | logger.go | fixupChildren | func (self *Manager) fixupChildren(placeHolder *PlaceHolder, logger Logger) {
name := logger.GetName()
for e := placeHolder.Loggers.Front(); e != nil; e = e.Next() {
l, _ := e.Value.(Logger)
parent := l.GetParent()
if !strings.HasPrefix(parent.GetName(), name) {
logger.SetParent(parent)
l.SetParent(logger... | go | func (self *Manager) fixupChildren(placeHolder *PlaceHolder, logger Logger) {
name := logger.GetName()
for e := placeHolder.Loggers.Front(); e != nil; e = e.Next() {
l, _ := e.Value.(Logger)
parent := l.GetParent()
if !strings.HasPrefix(parent.GetName(), name) {
logger.SetParent(parent)
l.SetParent(logger... | [
"func",
"(",
"self",
"*",
"Manager",
")",
"fixupChildren",
"(",
"placeHolder",
"*",
"PlaceHolder",
",",
"logger",
"Logger",
")",
"{",
"name",
":=",
"logger",
".",
"GetName",
"(",
")",
"\n",
"for",
"e",
":=",
"placeHolder",
".",
"Loggers",
".",
"Front",
... | // Ensure that children of the PlaceHolder placeHolder are connected to the
// specified logger. | [
"Ensure",
"that",
"children",
"of",
"the",
"PlaceHolder",
"placeHolder",
"are",
"connected",
"to",
"the",
"specified",
"logger",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/logger.go#L636-L646 |
17,904 | hhkbp2/go-logging | record.go | NewLogRecord | func NewLogRecord(
name string,
level LogLevelType,
pathName string,
fileName string,
lineNo uint32,
funcName string,
format string,
useFormat bool,
args []interface{}) *LogRecord {
return &LogRecord{
CreatedTime: time.Now(),
Name: name,
Level: level,
PathName: pathName,
FileName: ... | go | func NewLogRecord(
name string,
level LogLevelType,
pathName string,
fileName string,
lineNo uint32,
funcName string,
format string,
useFormat bool,
args []interface{}) *LogRecord {
return &LogRecord{
CreatedTime: time.Now(),
Name: name,
Level: level,
PathName: pathName,
FileName: ... | [
"func",
"NewLogRecord",
"(",
"name",
"string",
",",
"level",
"LogLevelType",
",",
"pathName",
"string",
",",
"fileName",
"string",
",",
"lineNo",
"uint32",
",",
"funcName",
"string",
",",
"format",
"string",
",",
"useFormat",
"bool",
",",
"args",
"[",
"]",
... | // Initialize a logging record with interesting information. | [
"Initialize",
"a",
"logging",
"record",
"with",
"interesting",
"information",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/record.go#L32-L56 |
17,905 | hhkbp2/go-logging | record.go | String | func (self *LogRecord) String() string {
return fmt.Sprintf("<LogRecord: %s, %s, %s, %d, \"%s\">",
self.Name, self.Level, self.PathName, self.LineNo, self.Message)
} | go | func (self *LogRecord) String() string {
return fmt.Sprintf("<LogRecord: %s, %s, %s, %d, \"%s\">",
self.Name, self.Level, self.PathName, self.LineNo, self.Message)
} | [
"func",
"(",
"self",
"*",
"LogRecord",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"self",
".",
"Name",
",",
"self",
".",
"Level",
",",
"self",
".",
"PathName",
",",
"self",
".",
... | // Return the string representation for this LogRecord. | [
"Return",
"the",
"string",
"representation",
"for",
"this",
"LogRecord",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/record.go#L59-L62 |
17,906 | hhkbp2/go-logging | record.go | GetMessage | func (self *LogRecord) GetMessage() string {
if len(self.Message) == 0 {
if self.UseFormat {
self.Message = fmt.Sprintf(self.Format, self.Args...)
} else {
self.Message = fmt.Sprint(self.Args...)
}
}
return self.Message
} | go | func (self *LogRecord) GetMessage() string {
if len(self.Message) == 0 {
if self.UseFormat {
self.Message = fmt.Sprintf(self.Format, self.Args...)
} else {
self.Message = fmt.Sprint(self.Args...)
}
}
return self.Message
} | [
"func",
"(",
"self",
"*",
"LogRecord",
")",
"GetMessage",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"self",
".",
"Message",
")",
"==",
"0",
"{",
"if",
"self",
".",
"UseFormat",
"{",
"self",
".",
"Message",
"=",
"fmt",
".",
"Sprintf",
"(",
"self",
... | // Return the message for this LogRecord.
// The message is composed of the Message and any user-supplied arguments. | [
"Return",
"the",
"message",
"for",
"this",
"LogRecord",
".",
"The",
"message",
"is",
"composed",
"of",
"the",
"Message",
"and",
"any",
"user",
"-",
"supplied",
"arguments",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/record.go#L66-L75 |
17,907 | hhkbp2/go-logging | handler_stream.go | NewStreamHandler | func NewStreamHandler(
name string, level LogLevelType, stream Stream) *StreamHandler {
object := &StreamHandler{
BaseHandler: NewBaseHandler(name, level),
stream: stream,
}
Closer.AddHandler(object)
return object
} | go | func NewStreamHandler(
name string, level LogLevelType, stream Stream) *StreamHandler {
object := &StreamHandler{
BaseHandler: NewBaseHandler(name, level),
stream: stream,
}
Closer.AddHandler(object)
return object
} | [
"func",
"NewStreamHandler",
"(",
"name",
"string",
",",
"level",
"LogLevelType",
",",
"stream",
"Stream",
")",
"*",
"StreamHandler",
"{",
"object",
":=",
"&",
"StreamHandler",
"{",
"BaseHandler",
":",
"NewBaseHandler",
"(",
"name",
",",
"level",
")",
",",
"s... | // Initialize a stream handler with name, logging level and underlying stream. | [
"Initialize",
"a",
"stream",
"handler",
"with",
"name",
"logging",
"level",
"and",
"underlying",
"stream",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_stream.go#L24-L33 |
17,908 | hhkbp2/go-logging | handler_stream.go | Emit2 | func (self *StreamHandler) Emit2(
handler Handler, record *LogRecord) error {
message := handler.Format(record)
if err := self.stream.Write(message); err != nil {
return err
}
return nil
} | go | func (self *StreamHandler) Emit2(
handler Handler, record *LogRecord) error {
message := handler.Format(record)
if err := self.stream.Write(message); err != nil {
return err
}
return nil
} | [
"func",
"(",
"self",
"*",
"StreamHandler",
")",
"Emit2",
"(",
"handler",
"Handler",
",",
"record",
"*",
"LogRecord",
")",
"error",
"{",
"message",
":=",
"handler",
".",
"Format",
"(",
"record",
")",
"\n",
"if",
"err",
":=",
"self",
".",
"stream",
".",
... | // A helper function to emit a record.
// If a formatter is specified, it is used to format the record.
// The record is then written to the stream with a trailing newline. | [
"A",
"helper",
"function",
"to",
"emit",
"a",
"record",
".",
"If",
"a",
"formatter",
"is",
"specified",
"it",
"is",
"used",
"to",
"format",
"the",
"record",
".",
"The",
"record",
"is",
"then",
"written",
"to",
"the",
"stream",
"with",
"a",
"trailing",
... | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_stream.go#L53-L61 |
17,909 | hhkbp2/go-logging | handler_null.go | NewNullHandler | func NewNullHandler() *NullHandler {
object := &NullHandler{
BaseHandler: NewBaseHandler("", LevelNotset),
}
Closer.AddHandler(object)
return object
} | go | func NewNullHandler() *NullHandler {
object := &NullHandler{
BaseHandler: NewBaseHandler("", LevelNotset),
}
Closer.AddHandler(object)
return object
} | [
"func",
"NewNullHandler",
"(",
")",
"*",
"NullHandler",
"{",
"object",
":=",
"&",
"NullHandler",
"{",
"BaseHandler",
":",
"NewBaseHandler",
"(",
"\"",
"\"",
",",
"LevelNotset",
")",
",",
"}",
"\n",
"Closer",
".",
"AddHandler",
"(",
"object",
")",
"\n",
"... | // Initialize a NullHandler. | [
"Initialize",
"a",
"NullHandler",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/handler_null.go#L15-L21 |
17,910 | hhkbp2/go-logging | formatter.go | initFormatRegexp | func initFormatRegexp() *regexp.Regexp {
var buf bytes.Buffer
buf.WriteString("(%(?:%")
for attr, _ := range attrToFunc {
buf.WriteString("|")
buf.WriteString(regexp.QuoteMeta(attr[1:]))
}
buf.WriteString("))")
re := buf.String()
return regexp.MustCompile(re)
} | go | func initFormatRegexp() *regexp.Regexp {
var buf bytes.Buffer
buf.WriteString("(%(?:%")
for attr, _ := range attrToFunc {
buf.WriteString("|")
buf.WriteString(regexp.QuoteMeta(attr[1:]))
}
buf.WriteString("))")
re := buf.String()
return regexp.MustCompile(re)
} | [
"func",
"initFormatRegexp",
"(",
")",
"*",
"regexp",
".",
"Regexp",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"buf",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"for",
"attr",
",",
"_",
":=",
"range",
"attrToFunc",
"{",
"buf",
".",
"WriteS... | // Initialize global regexp for attribute matching. | [
"Initialize",
"global",
"regexp",
"for",
"attribute",
"matching",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/formatter.go#L57-L67 |
17,911 | hhkbp2/go-logging | formatter.go | NewStandardFormatter | func NewStandardFormatter(format string, dateFormat string) *StandardFormatter {
toFormatTime := false
size := 0
f1 := func(match string) string {
if match == "%%" {
return "%"
}
if match == "%(asctime)s" {
toFormatTime = true
}
size++
return "%s"
}
strFormat := formatRe.ReplaceAllStringFunc(form... | go | func NewStandardFormatter(format string, dateFormat string) *StandardFormatter {
toFormatTime := false
size := 0
f1 := func(match string) string {
if match == "%%" {
return "%"
}
if match == "%(asctime)s" {
toFormatTime = true
}
size++
return "%s"
}
strFormat := formatRe.ReplaceAllStringFunc(form... | [
"func",
"NewStandardFormatter",
"(",
"format",
"string",
",",
"dateFormat",
"string",
")",
"*",
"StandardFormatter",
"{",
"toFormatTime",
":=",
"false",
"\n",
"size",
":=",
"0",
"\n",
"f1",
":=",
"func",
"(",
"match",
"string",
")",
"string",
"{",
"if",
"m... | // Initialize the formatter with specified format strings.
// Allow for specialized date formatting with the dateFormat arguement. | [
"Initialize",
"the",
"formatter",
"with",
"specified",
"format",
"strings",
".",
"Allow",
"for",
"specialized",
"date",
"formatting",
"with",
"the",
"dateFormat",
"arguement",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/formatter.go#L112-L154 |
17,912 | hhkbp2/go-logging | formatter.go | FormatAll | func (self *StandardFormatter) FormatAll(record *LogRecord) string {
return fmt.Sprintf(self.strFormat, self.getFormatArgsFunc(record)...)
} | go | func (self *StandardFormatter) FormatAll(record *LogRecord) string {
return fmt.Sprintf(self.strFormat, self.getFormatArgsFunc(record)...)
} | [
"func",
"(",
"self",
"*",
"StandardFormatter",
")",
"FormatAll",
"(",
"record",
"*",
"LogRecord",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"self",
".",
"strFormat",
",",
"self",
".",
"getFormatArgsFunc",
"(",
"record",
")",
"...",
")",
"... | // Helper function using regexp to replace every valid format attribute string
// to the record's specific value. | [
"Helper",
"function",
"using",
"regexp",
"to",
"replace",
"every",
"valid",
"format",
"attribute",
"string",
"to",
"the",
"record",
"s",
"specific",
"value",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/formatter.go#L183-L185 |
17,913 | hhkbp2/go-logging | formatter.go | Format | func (self *BufferingFormatter) Format(records []*LogRecord) string {
var buf bytes.Buffer
if len(records) > 0 {
buf.WriteString(self.FormatHeader(records))
for _, record := range records {
buf.WriteString(self.lineFormatter.Format(record))
}
buf.WriteString(self.FormatFooter(records))
}
return buf.Strin... | go | func (self *BufferingFormatter) Format(records []*LogRecord) string {
var buf bytes.Buffer
if len(records) > 0 {
buf.WriteString(self.FormatHeader(records))
for _, record := range records {
buf.WriteString(self.lineFormatter.Format(record))
}
buf.WriteString(self.FormatFooter(records))
}
return buf.Strin... | [
"func",
"(",
"self",
"*",
"BufferingFormatter",
")",
"Format",
"(",
"records",
"[",
"]",
"*",
"LogRecord",
")",
"string",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"if",
"len",
"(",
"records",
")",
">",
"0",
"{",
"buf",
".",
"WriteString",
"("... | // Format the specified records and return the result as a a string. | [
"Format",
"the",
"specified",
"records",
"and",
"return",
"the",
"result",
"as",
"a",
"a",
"string",
"."
] | 65fcbf8cf388a708c9c36def03633ec62056d3f5 | https://github.com/hhkbp2/go-logging/blob/65fcbf8cf388a708c9c36def03633ec62056d3f5/formatter.go#L210-L220 |
17,914 | cgrates/fsock | fsock.go | NewFSock | func NewFSock(fsaddr, fspaswd string, reconnects int, eventHandlers map[string][]func(string, string), eventFilters map[string][]string, l *syslog.Writer, connId string) (fsock *FSock, err error) {
fsock = &FSock{
fsMutex: new(sync.RWMutex),
connId: connId,
fsaddress: fsaddr,
fspaswd: ... | go | func NewFSock(fsaddr, fspaswd string, reconnects int, eventHandlers map[string][]func(string, string), eventFilters map[string][]string, l *syslog.Writer, connId string) (fsock *FSock, err error) {
fsock = &FSock{
fsMutex: new(sync.RWMutex),
connId: connId,
fsaddress: fsaddr,
fspaswd: ... | [
"func",
"NewFSock",
"(",
"fsaddr",
",",
"fspaswd",
"string",
",",
"reconnects",
"int",
",",
"eventHandlers",
"map",
"[",
"string",
"]",
"[",
"]",
"func",
"(",
"string",
",",
"string",
")",
",",
"eventFilters",
"map",
"[",
"string",
"]",
"[",
"]",
"stri... | // Connects to FS and starts buffering input | [
"Connects",
"to",
"FS",
"and",
"starts",
"buffering",
"input"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/fsock.go#L37-L55 |
17,915 | cgrates/fsock | fsock.go | Connected | func (self *FSock) Connected() (ok bool) {
self.fsMutex.RLock()
ok = (self.conn != nil)
self.fsMutex.RUnlock()
return
} | go | func (self *FSock) Connected() (ok bool) {
self.fsMutex.RLock()
ok = (self.conn != nil)
self.fsMutex.RUnlock()
return
} | [
"func",
"(",
"self",
"*",
"FSock",
")",
"Connected",
"(",
")",
"(",
"ok",
"bool",
")",
"{",
"self",
".",
"fsMutex",
".",
"RLock",
"(",
")",
"\n",
"ok",
"=",
"(",
"self",
".",
"conn",
"!=",
"nil",
")",
"\n",
"self",
".",
"fsMutex",
".",
"RUnlock... | // Connected checks if socket connected. Can be extended with pings | [
"Connected",
"checks",
"if",
"socket",
"connected",
".",
"Can",
"be",
"extended",
"with",
"pings"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/fsock.go#L129-L134 |
17,916 | cgrates/fsock | fsock.go | auth | func (self *FSock) auth() error {
self.send(fmt.Sprintf("auth %s\n\n", self.fspaswd))
if rply, err := self.readHeaders(); err != nil {
return err
} else if !strings.Contains(rply, "Reply-Text: +OK accepted") {
return fmt.Errorf("Unexpected auth reply received: <%s>", rply)
}
return nil
} | go | func (self *FSock) auth() error {
self.send(fmt.Sprintf("auth %s\n\n", self.fspaswd))
if rply, err := self.readHeaders(); err != nil {
return err
} else if !strings.Contains(rply, "Reply-Text: +OK accepted") {
return fmt.Errorf("Unexpected auth reply received: <%s>", rply)
}
return nil
} | [
"func",
"(",
"self",
"*",
"FSock",
")",
"auth",
"(",
")",
"error",
"{",
"self",
".",
"send",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\n",
"\\n",
"\"",
",",
"self",
".",
"fspaswd",
")",
")",
"\n",
"if",
"rply",
",",
"err",
":=",
"self",
".",
... | // Auth to FS | [
"Auth",
"to",
"FS"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/fsock.go#L188-L196 |
17,917 | cgrates/fsock | fsock.go | SendCmd | func (self *FSock) SendCmd(cmdStr string) (string, error) {
return self.sendCmd(cmdStr + "\n")
} | go | func (self *FSock) SendCmd(cmdStr string) (string, error) {
return self.sendCmd(cmdStr + "\n")
} | [
"func",
"(",
"self",
"*",
"FSock",
")",
"SendCmd",
"(",
"cmdStr",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"self",
".",
"sendCmd",
"(",
"cmdStr",
"+",
"\"",
"\\n",
"\"",
")",
"\n",
"}"
] | // Generic proxy for commands | [
"Generic",
"proxy",
"for",
"commands"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/fsock.go#L212-L214 |
17,918 | cgrates/fsock | fsock.go | SendApiCmd | func (self *FSock) SendApiCmd(cmdStr string) (string, error) {
return self.sendCmd("api " + cmdStr + "\n")
} | go | func (self *FSock) SendApiCmd(cmdStr string) (string, error) {
return self.sendCmd("api " + cmdStr + "\n")
} | [
"func",
"(",
"self",
"*",
"FSock",
")",
"SendApiCmd",
"(",
"cmdStr",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"self",
".",
"sendCmd",
"(",
"\"",
"\"",
"+",
"cmdStr",
"+",
"\"",
"\\n",
"\"",
")",
"\n",
"}"
] | // Send API command | [
"Send",
"API",
"command"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/fsock.go#L227-L229 |
17,919 | cgrates/fsock | fsock.go | SendBgapiCmd | func (self *FSock) SendBgapiCmd(cmdStr string) (out chan string, err error) {
jobUuid := genUUID()
out = make(chan string)
self.fsMutex.Lock()
self.backgroundChans[jobUuid] = out
self.fsMutex.Unlock()
_, err = self.sendCmd(fmt.Sprintf("bgapi %s\nJob-UUID:%s\n", cmdStr, jobUuid))
if err != nil {
return nil, e... | go | func (self *FSock) SendBgapiCmd(cmdStr string) (out chan string, err error) {
jobUuid := genUUID()
out = make(chan string)
self.fsMutex.Lock()
self.backgroundChans[jobUuid] = out
self.fsMutex.Unlock()
_, err = self.sendCmd(fmt.Sprintf("bgapi %s\nJob-UUID:%s\n", cmdStr, jobUuid))
if err != nil {
return nil, e... | [
"func",
"(",
"self",
"*",
"FSock",
")",
"SendBgapiCmd",
"(",
"cmdStr",
"string",
")",
"(",
"out",
"chan",
"string",
",",
"err",
"error",
")",
"{",
"jobUuid",
":=",
"genUUID",
"(",
")",
"\n",
"out",
"=",
"make",
"(",
"chan",
"string",
")",
"\n\n",
"... | // Send BGAPI command | [
"Send",
"BGAPI",
"command"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/fsock.go#L232-L245 |
17,920 | cgrates/fsock | fsock.go | ReadEvents | func (self *FSock) ReadEvents() (err error) {
var opened bool
for {
if err, opened = <-self.errReadEvents; !opened {
return nil
} else if err == io.EOF { // Disconnected, try reconnect
if err = self.ReconnectIfNeeded(); err != nil {
break
}
}
}
return err
} | go | func (self *FSock) ReadEvents() (err error) {
var opened bool
for {
if err, opened = <-self.errReadEvents; !opened {
return nil
} else if err == io.EOF { // Disconnected, try reconnect
if err = self.ReconnectIfNeeded(); err != nil {
break
}
}
}
return err
} | [
"func",
"(",
"self",
"*",
"FSock",
")",
"ReadEvents",
"(",
")",
"(",
"err",
"error",
")",
"{",
"var",
"opened",
"bool",
"\n",
"for",
"{",
"if",
"err",
",",
"opened",
"=",
"<-",
"self",
".",
"errReadEvents",
";",
"!",
"opened",
"{",
"return",
"nil",... | // ReadEvents reads events from socket, attempt reconnect if disconnected | [
"ReadEvents",
"reads",
"events",
"from",
"socket",
"attempt",
"reconnect",
"if",
"disconnected"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/fsock.go#L275-L287 |
17,921 | cgrates/fsock | fsock.go | readHeaders | func (self *FSock) readHeaders() (header string, err error) {
bytesRead := make([]byte, 0)
var readLine []byte
for {
readLine, err = self.buffer.ReadBytes('\n')
if err != nil {
if self.logger != nil {
self.logger.Err(fmt.Sprintf("<FSock> Error reading headers: <%s>", err.Error()))
}
self.Disconnect... | go | func (self *FSock) readHeaders() (header string, err error) {
bytesRead := make([]byte, 0)
var readLine []byte
for {
readLine, err = self.buffer.ReadBytes('\n')
if err != nil {
if self.logger != nil {
self.logger.Err(fmt.Sprintf("<FSock> Error reading headers: <%s>", err.Error()))
}
self.Disconnect... | [
"func",
"(",
"self",
"*",
"FSock",
")",
"readHeaders",
"(",
")",
"(",
"header",
"string",
",",
"err",
"error",
")",
"{",
"bytesRead",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"0",
")",
"\n",
"var",
"readLine",
"[",
"]",
"byte",
"\n\n",
"for",
"{... | // Reads headers until delimiter reached | [
"Reads",
"headers",
"until",
"delimiter",
"reached"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/fsock.go#L297-L317 |
17,922 | cgrates/fsock | fsock.go | readBody | func (self *FSock) readBody(noBytes int) (body string, err error) {
bytesRead := make([]byte, noBytes)
var readByte byte
for i := 0; i < noBytes; i++ {
if readByte, err = self.buffer.ReadByte(); err != nil {
if self.logger != nil {
self.logger.Err(fmt.Sprintf("<FSock> Error reading message body: <%s>", err... | go | func (self *FSock) readBody(noBytes int) (body string, err error) {
bytesRead := make([]byte, noBytes)
var readByte byte
for i := 0; i < noBytes; i++ {
if readByte, err = self.buffer.ReadByte(); err != nil {
if self.logger != nil {
self.logger.Err(fmt.Sprintf("<FSock> Error reading message body: <%s>", err... | [
"func",
"(",
"self",
"*",
"FSock",
")",
"readBody",
"(",
"noBytes",
"int",
")",
"(",
"body",
"string",
",",
"err",
"error",
")",
"{",
"bytesRead",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"noBytes",
")",
"\n",
"var",
"readByte",
"byte",
"\n\n",
"f... | // Reads the body from buffer, ln is given by content-length of headers | [
"Reads",
"the",
"body",
"from",
"buffer",
"ln",
"is",
"given",
"by",
"content",
"-",
"length",
"of",
"headers"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/fsock.go#L320-L336 |
17,923 | cgrates/fsock | fsock.go | readEvents | func (self *FSock) readEvents() {
for {
select {
case <-self.stopReadEvents:
return
default: // Unlock waiting here
}
hdr, body, err := self.readEvent()
if err != nil {
self.errReadEvents <- err
return
}
if strings.Contains(hdr, "api/response") {
self.cmdChan <- body
} else if strings.Con... | go | func (self *FSock) readEvents() {
for {
select {
case <-self.stopReadEvents:
return
default: // Unlock waiting here
}
hdr, body, err := self.readEvent()
if err != nil {
self.errReadEvents <- err
return
}
if strings.Contains(hdr, "api/response") {
self.cmdChan <- body
} else if strings.Con... | [
"func",
"(",
"self",
"*",
"FSock",
")",
"readEvents",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"self",
".",
"stopReadEvents",
":",
"return",
"\n",
"default",
":",
"// Unlock waiting here",
"}",
"\n",
"hdr",
",",
"body",
",",
"err",
":=",... | // Read events from network buffer, stop when exitChan is closed, report on errReadEvents on error and exit
// Receive exitChan and errReadEvents as parameters so we avoid concurrency on using self. | [
"Read",
"events",
"from",
"network",
"buffer",
"stop",
"when",
"exitChan",
"is",
"closed",
"report",
"on",
"errReadEvents",
"on",
"error",
"and",
"exit",
"Receive",
"exitChan",
"and",
"errReadEvents",
"as",
"parameters",
"so",
"we",
"avoid",
"concurrency",
"on",... | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/fsock.go#L359-L379 |
17,924 | cgrates/fsock | fsock.go | eventsPlain | func (self *FSock) eventsPlain(events []string) error {
// if len(events) == 0 {
// return nil
// }
eventsCmd := "event plain"
customEvents := ""
for _, ev := range events {
if ev == "ALL" {
eventsCmd = "event plain all"
break
}
if strings.HasPrefix(ev, "CUSTOM") {
customEvents += ev[6:] // will c... | go | func (self *FSock) eventsPlain(events []string) error {
// if len(events) == 0 {
// return nil
// }
eventsCmd := "event plain"
customEvents := ""
for _, ev := range events {
if ev == "ALL" {
eventsCmd = "event plain all"
break
}
if strings.HasPrefix(ev, "CUSTOM") {
customEvents += ev[6:] // will c... | [
"func",
"(",
"self",
"*",
"FSock",
")",
"eventsPlain",
"(",
"events",
"[",
"]",
"string",
")",
"error",
"{",
"// if len(events) == 0 {",
"// \treturn nil",
"// }",
"eventsCmd",
":=",
"\"",
"\"",
"\n",
"customEvents",
":=",
"\"",
"\"",
"\n",
"for",
"_",
","... | // Subscribe to events | [
"Subscribe",
"to",
"events"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/fsock.go#L382-L414 |
17,925 | cgrates/fsock | fsock.go | dispatchEvent | func (self *FSock) dispatchEvent(event string) {
eventName := headerVal(event, "Event-Name")
if eventName == "BACKGROUND_JOB" { // for bgapi BACKGROUND_JOB
go self.doBackgroudJob(event)
return
}
if eventName == "CUSTOM" {
eventSubclass := headerVal(event, "Event-Subclass")
if len(eventSubclass) != 0 {
e... | go | func (self *FSock) dispatchEvent(event string) {
eventName := headerVal(event, "Event-Name")
if eventName == "BACKGROUND_JOB" { // for bgapi BACKGROUND_JOB
go self.doBackgroudJob(event)
return
}
if eventName == "CUSTOM" {
eventSubclass := headerVal(event, "Event-Subclass")
if len(eventSubclass) != 0 {
e... | [
"func",
"(",
"self",
"*",
"FSock",
")",
"dispatchEvent",
"(",
"event",
"string",
")",
"{",
"eventName",
":=",
"headerVal",
"(",
"event",
",",
"\"",
"\"",
")",
"\n",
"if",
"eventName",
"==",
"\"",
"\"",
"{",
"// for bgapi BACKGROUND_JOB",
"go",
"self",
".... | // Dispatch events to handlers in async mode | [
"Dispatch",
"events",
"to",
"handlers",
"in",
"async",
"mode"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/fsock.go#L437-L464 |
17,926 | cgrates/fsock | fsock.go | doBackgroudJob | func (self *FSock) doBackgroudJob(event string) { // add mutex protection
evMap := EventToMap(event)
jobUuid, has := evMap["Job-UUID"]
if !has {
self.logger.Err("<FSock> BACKGROUND_JOB with no Job-UUID")
return
}
var out chan string
self.fsMutex.RLock()
out, has = self.backgroundChans[jobUuid]
self.fsMutex... | go | func (self *FSock) doBackgroudJob(event string) { // add mutex protection
evMap := EventToMap(event)
jobUuid, has := evMap["Job-UUID"]
if !has {
self.logger.Err("<FSock> BACKGROUND_JOB with no Job-UUID")
return
}
var out chan string
self.fsMutex.RLock()
out, has = self.backgroundChans[jobUuid]
self.fsMutex... | [
"func",
"(",
"self",
"*",
"FSock",
")",
"doBackgroudJob",
"(",
"event",
"string",
")",
"{",
"// add mutex protection",
"evMap",
":=",
"EventToMap",
"(",
"event",
")",
"\n",
"jobUuid",
",",
"has",
":=",
"evMap",
"[",
"\"",
"\"",
"]",
"\n",
"if",
"!",
"h... | // bgapi event lisen fuction | [
"bgapi",
"event",
"lisen",
"fuction"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/fsock.go#L467-L489 |
17,927 | cgrates/fsock | fsock.go | NewFSockPool | func NewFSockPool(maxFSocks int, fsaddr, fspasswd string, reconnects int, maxWaitConn time.Duration,
eventHandlers map[string][]func(string, string), eventFilters map[string][]string, l *syslog.Writer, connId string) (*FSockPool, error) {
pool := &FSockPool{
connId: connId,
fsAddr: fsaddr,
fsPassw... | go | func NewFSockPool(maxFSocks int, fsaddr, fspasswd string, reconnects int, maxWaitConn time.Duration,
eventHandlers map[string][]func(string, string), eventFilters map[string][]string, l *syslog.Writer, connId string) (*FSockPool, error) {
pool := &FSockPool{
connId: connId,
fsAddr: fsaddr,
fsPassw... | [
"func",
"NewFSockPool",
"(",
"maxFSocks",
"int",
",",
"fsaddr",
",",
"fspasswd",
"string",
",",
"reconnects",
"int",
",",
"maxWaitConn",
"time",
".",
"Duration",
",",
"eventHandlers",
"map",
"[",
"string",
"]",
"[",
"]",
"func",
"(",
"string",
",",
"string... | // Instantiates a new FSockPool | [
"Instantiates",
"a",
"new",
"FSockPool"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/fsock.go#L492-L510 |
17,928 | cgrates/fsock | utils.go | FSEventStrToMap | func FSEventStrToMap(fsevstr string, headers []string) map[string]string {
fsevent := make(map[string]string)
filtered := (len(headers) != 0)
for _, strLn := range strings.Split(fsevstr, "\n") {
if hdrVal := strings.SplitN(strLn, ": ", 2); len(hdrVal) == 2 {
if filtered && isSliceMember(headers, hdrVal[0]) {
... | go | func FSEventStrToMap(fsevstr string, headers []string) map[string]string {
fsevent := make(map[string]string)
filtered := (len(headers) != 0)
for _, strLn := range strings.Split(fsevstr, "\n") {
if hdrVal := strings.SplitN(strLn, ": ", 2); len(hdrVal) == 2 {
if filtered && isSliceMember(headers, hdrVal[0]) {
... | [
"func",
"FSEventStrToMap",
"(",
"fsevstr",
"string",
",",
"headers",
"[",
"]",
"string",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"fsevent",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"filtered",
":=",
"(",
"len",
"(",
"... | // Convert fseventStr into fseventMap | [
"Convert",
"fseventStr",
"into",
"fseventMap"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/utils.go#L25-L37 |
17,929 | cgrates/fsock | utils.go | MapChanData | func MapChanData(chanInfoStr string) (chansInfoMap []map[string]string) {
chansInfoMap = make([]map[string]string, 0)
spltChanInfo := strings.Split(chanInfoStr, "\n")
if len(spltChanInfo) <= 4 {
return
}
hdrs := strings.Split(spltChanInfo[0], ",")
for _, chanInfoLn := range spltChanInfo[1 : len(spltChanInfo)-3]... | go | func MapChanData(chanInfoStr string) (chansInfoMap []map[string]string) {
chansInfoMap = make([]map[string]string, 0)
spltChanInfo := strings.Split(chanInfoStr, "\n")
if len(spltChanInfo) <= 4 {
return
}
hdrs := strings.Split(spltChanInfo[0], ",")
for _, chanInfoLn := range spltChanInfo[1 : len(spltChanInfo)-3]... | [
"func",
"MapChanData",
"(",
"chanInfoStr",
"string",
")",
"(",
"chansInfoMap",
"[",
"]",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"chansInfoMap",
"=",
"make",
"(",
"[",
"]",
"map",
"[",
"string",
"]",
"string",
",",
"0",
")",
"\n",
"spltChanInfo"... | // Converts string received from fsock into a list of channel info, each represented in a map | [
"Converts",
"string",
"received",
"from",
"fsock",
"into",
"a",
"list",
"of",
"channel",
"info",
"each",
"represented",
"in",
"a",
"map"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/utils.go#L40-L59 |
17,930 | cgrates/fsock | utils.go | genUUID | func genUUID() string {
b := make([]byte, 16)
_, err := io.ReadFull(rand.Reader, b)
if err != nil {
log.Fatal(err)
}
b[6] = (b[6] & 0x0F) | 0x40
b[8] = (b[8] &^ 0x40) | 0x80
return fmt.Sprintf("%x-%x-%x-%x-%x", b[:4], b[4:6], b[6:8], b[8:10],
b[10:])
} | go | func genUUID() string {
b := make([]byte, 16)
_, err := io.ReadFull(rand.Reader, b)
if err != nil {
log.Fatal(err)
}
b[6] = (b[6] & 0x0F) | 0x40
b[8] = (b[8] &^ 0x40) | 0x80
return fmt.Sprintf("%x-%x-%x-%x-%x", b[:4], b[4:6], b[6:8], b[8:10],
b[10:])
} | [
"func",
"genUUID",
"(",
")",
"string",
"{",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"16",
")",
"\n",
"_",
",",
"err",
":=",
"io",
".",
"ReadFull",
"(",
"rand",
".",
"Reader",
",",
"b",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
... | // helper function for uuid generation | [
"helper",
"function",
"for",
"uuid",
"generation"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/utils.go#L82-L92 |
17,931 | cgrates/fsock | utils.go | headerVal | func headerVal(hdrs, hdr string) string {
var hdrSIdx, hdrEIdx int
if hdrSIdx = strings.Index(hdrs, hdr); hdrSIdx == -1 {
return ""
} else if hdrEIdx = strings.Index(hdrs[hdrSIdx:], "\n"); hdrEIdx == -1 {
hdrEIdx = len(hdrs[hdrSIdx:])
}
splt := strings.SplitN(hdrs[hdrSIdx:hdrSIdx+hdrEIdx], ": ", 2)
if len(spl... | go | func headerVal(hdrs, hdr string) string {
var hdrSIdx, hdrEIdx int
if hdrSIdx = strings.Index(hdrs, hdr); hdrSIdx == -1 {
return ""
} else if hdrEIdx = strings.Index(hdrs[hdrSIdx:], "\n"); hdrEIdx == -1 {
hdrEIdx = len(hdrs[hdrSIdx:])
}
splt := strings.SplitN(hdrs[hdrSIdx:hdrSIdx+hdrEIdx], ": ", 2)
if len(spl... | [
"func",
"headerVal",
"(",
"hdrs",
",",
"hdr",
"string",
")",
"string",
"{",
"var",
"hdrSIdx",
",",
"hdrEIdx",
"int",
"\n",
"if",
"hdrSIdx",
"=",
"strings",
".",
"Index",
"(",
"hdrs",
",",
"hdr",
")",
";",
"hdrSIdx",
"==",
"-",
"1",
"{",
"return",
"... | // Extracts value of a header from anywhere in content string | [
"Extracts",
"value",
"of",
"a",
"header",
"from",
"anywhere",
"in",
"content",
"string"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/utils.go#L189-L201 |
17,932 | cgrates/fsock | utils.go | urlDecode | func urlDecode(hdrVal string) string {
if valUnescaped, errUnescaping := url.QueryUnescape(hdrVal); errUnescaping == nil {
hdrVal = valUnescaped
}
return hdrVal
} | go | func urlDecode(hdrVal string) string {
if valUnescaped, errUnescaping := url.QueryUnescape(hdrVal); errUnescaping == nil {
hdrVal = valUnescaped
}
return hdrVal
} | [
"func",
"urlDecode",
"(",
"hdrVal",
"string",
")",
"string",
"{",
"if",
"valUnescaped",
",",
"errUnescaping",
":=",
"url",
".",
"QueryUnescape",
"(",
"hdrVal",
")",
";",
"errUnescaping",
"==",
"nil",
"{",
"hdrVal",
"=",
"valUnescaped",
"\n",
"}",
"\n",
"re... | // FS event header values are urlencoded. Use this to decode them. On error, use original value | [
"FS",
"event",
"header",
"values",
"are",
"urlencoded",
".",
"Use",
"this",
"to",
"decode",
"them",
".",
"On",
"error",
"use",
"original",
"value"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/utils.go#L204-L209 |
17,933 | cgrates/fsock | utils.go | isSliceMember | func isSliceMember(ss []string, s string) bool {
sort.Strings(ss)
i := sort.SearchStrings(ss, s)
return (i < len(ss) && ss[i] == s)
} | go | func isSliceMember(ss []string, s string) bool {
sort.Strings(ss)
i := sort.SearchStrings(ss, s)
return (i < len(ss) && ss[i] == s)
} | [
"func",
"isSliceMember",
"(",
"ss",
"[",
"]",
"string",
",",
"s",
"string",
")",
"bool",
"{",
"sort",
".",
"Strings",
"(",
"ss",
")",
"\n",
"i",
":=",
"sort",
".",
"SearchStrings",
"(",
"ss",
",",
"s",
")",
"\n",
"return",
"(",
"i",
"<",
"len",
... | // Binary string search in slice | [
"Binary",
"string",
"search",
"in",
"slice"
] | 880b6b2d10e6fcd66b0148471255438b82fb78b0 | https://github.com/cgrates/fsock/blob/880b6b2d10e6fcd66b0148471255438b82fb78b0/utils.go#L222-L226 |
17,934 | rylio/queue | queue.go | NewQueue | func NewQueue(handler Handler, concurrencyLimit int) *Queue {
q := &Queue{
&queue{
Handler: handler,
ConcurrencyLimit: concurrencyLimit,
push: make(chan interface{}),
pop: make(chan struct{}),
suspend: make(chan bool),
stop: make(chan struct{}... | go | func NewQueue(handler Handler, concurrencyLimit int) *Queue {
q := &Queue{
&queue{
Handler: handler,
ConcurrencyLimit: concurrencyLimit,
push: make(chan interface{}),
pop: make(chan struct{}),
suspend: make(chan bool),
stop: make(chan struct{}... | [
"func",
"NewQueue",
"(",
"handler",
"Handler",
",",
"concurrencyLimit",
"int",
")",
"*",
"Queue",
"{",
"q",
":=",
"&",
"Queue",
"{",
"&",
"queue",
"{",
"Handler",
":",
"handler",
",",
"ConcurrencyLimit",
":",
"concurrencyLimit",
",",
"push",
":",
"make",
... | // NewQueue must be called to initialize a new queue.
// The first argument is a Handler
// The second argument is an int which specifies how many operation can run in parallel in the queue, zero means unlimited. | [
"NewQueue",
"must",
"be",
"called",
"to",
"initialize",
"a",
"new",
"queue",
".",
"The",
"first",
"argument",
"is",
"a",
"Handler",
"The",
"second",
"argument",
"is",
"an",
"int",
"which",
"specifies",
"how",
"many",
"operation",
"can",
"run",
"in",
"paral... | 9aab6b722ecdf21660568142d77b62182161e9ce | https://github.com/rylio/queue/blob/9aab6b722ecdf21660568142d77b62182161e9ce/queue.go#L35-L51 |
17,935 | rylio/queue | queue.go | Len | func (q *Queue) Len() (_, _ int) {
return q.count, len(q.buffer)
} | go | func (q *Queue) Len() (_, _ int) {
return q.count, len(q.buffer)
} | [
"func",
"(",
"q",
"*",
"Queue",
")",
"Len",
"(",
")",
"(",
"_",
",",
"_",
"int",
")",
"{",
"return",
"q",
".",
"count",
",",
"len",
"(",
"q",
".",
"buffer",
")",
"\n",
"}"
] | // Count returns the number of currently executing tasks and the number of tasks waiting to be executed | [
"Count",
"returns",
"the",
"number",
"of",
"currently",
"executing",
"tasks",
"and",
"the",
"number",
"of",
"tasks",
"waiting",
"to",
"be",
"executed"
] | 9aab6b722ecdf21660568142d77b62182161e9ce | https://github.com/rylio/queue/blob/9aab6b722ecdf21660568142d77b62182161e9ce/queue.go#L73-L76 |
17,936 | docker/engine-api | client/plugin_inspect.go | PluginInspectWithRaw | func (cli *Client) PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error) {
resp, err := cli.get(ctx, "/plugins/"+name, nil, nil)
if err != nil {
return nil, nil, err
}
defer ensureReaderClosed(resp)
body, err := ioutil.ReadAll(resp.body)
if err != nil {
return nil, nil, err
}... | go | func (cli *Client) PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error) {
resp, err := cli.get(ctx, "/plugins/"+name, nil, nil)
if err != nil {
return nil, nil, err
}
defer ensureReaderClosed(resp)
body, err := ioutil.ReadAll(resp.body)
if err != nil {
return nil, nil, err
}... | [
"func",
"(",
"cli",
"*",
"Client",
")",
"PluginInspectWithRaw",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"*",
"types",
".",
"Plugin",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"cli",
"."... | // PluginInspectWithRaw inspects an existing plugin | [
"PluginInspectWithRaw",
"inspects",
"an",
"existing",
"plugin"
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/client/plugin_inspect.go#L15-L30 |
17,937 | docker/engine-api | client/service_update.go | ServiceUpdate | func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) error {
var (
headers map[string][]string
query = url.Values{}
)
if options.EncodedRegistryAuth != "" {
headers = map[string][]string{
"X-Registry-... | go | func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) error {
var (
headers map[string][]string
query = url.Values{}
)
if options.EncodedRegistryAuth != "" {
headers = map[string][]string{
"X-Registry-... | [
"func",
"(",
"cli",
"*",
"Client",
")",
"ServiceUpdate",
"(",
"ctx",
"context",
".",
"Context",
",",
"serviceID",
"string",
",",
"version",
"swarm",
".",
"Version",
",",
"service",
"swarm",
".",
"ServiceSpec",
",",
"options",
"types",
".",
"ServiceUpdateOpti... | // ServiceUpdate updates a Service. | [
"ServiceUpdate",
"updates",
"a",
"Service",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/client/service_update.go#L13-L30 |
17,938 | docker/engine-api | client/client.go | NewEnvClient | func NewEnvClient() (*Client, error) {
var client *http.Client
if dockerCertPath := os.Getenv("DOCKER_CERT_PATH"); dockerCertPath != "" {
options := tlsconfig.Options{
CAFile: filepath.Join(dockerCertPath, "ca.pem"),
CertFile: filepath.Join(dockerCertPath, "cert.pem"),
KeyFile: ... | go | func NewEnvClient() (*Client, error) {
var client *http.Client
if dockerCertPath := os.Getenv("DOCKER_CERT_PATH"); dockerCertPath != "" {
options := tlsconfig.Options{
CAFile: filepath.Join(dockerCertPath, "ca.pem"),
CertFile: filepath.Join(dockerCertPath, "cert.pem"),
KeyFile: ... | [
"func",
"NewEnvClient",
"(",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"var",
"client",
"*",
"http",
".",
"Client",
"\n",
"if",
"dockerCertPath",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
";",
"dockerCertPath",
"!=",
"\"",
"\"",
"{",
... | // NewEnvClient initializes a new API client based on environment variables.
// Use DOCKER_HOST to set the url to the docker server.
// Use DOCKER_API_VERSION to set the version of the API to reach, leave empty for latest.
// Use DOCKER_CERT_PATH to load the tls certificates from.
// Use DOCKER_TLS_VERIFY to enable or ... | [
"NewEnvClient",
"initializes",
"a",
"new",
"API",
"client",
"based",
"on",
"environment",
"variables",
".",
"Use",
"DOCKER_HOST",
"to",
"set",
"the",
"url",
"to",
"the",
"docker",
"server",
".",
"Use",
"DOCKER_API_VERSION",
"to",
"set",
"the",
"version",
"of",... | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/client/client.go#L42-L74 |
17,939 | docker/engine-api | client/client.go | NewClient | func NewClient(host string, version string, client *http.Client, httpHeaders map[string]string) (*Client, error) {
proto, addr, basePath, err := ParseHost(host)
if err != nil {
return nil, err
}
transport, err := transport.NewTransportWithHTTP(proto, addr, client)
if err != nil {
return nil, err
}
return &... | go | func NewClient(host string, version string, client *http.Client, httpHeaders map[string]string) (*Client, error) {
proto, addr, basePath, err := ParseHost(host)
if err != nil {
return nil, err
}
transport, err := transport.NewTransportWithHTTP(proto, addr, client)
if err != nil {
return nil, err
}
return &... | [
"func",
"NewClient",
"(",
"host",
"string",
",",
"version",
"string",
",",
"client",
"*",
"http",
".",
"Client",
",",
"httpHeaders",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"proto",
",",
"addr",
",",
"bas... | // NewClient initializes a new API client for the given host and API version.
// It uses the given http client as transport.
// It also initializes the custom http headers to add to each request.
//
// It won't send any version information if the version number is empty. It is
// highly recommended that you set a versi... | [
"NewClient",
"initializes",
"a",
"new",
"API",
"client",
"for",
"the",
"given",
"host",
"and",
"API",
"version",
".",
"It",
"uses",
"the",
"given",
"http",
"client",
"as",
"transport",
".",
"It",
"also",
"initializes",
"the",
"custom",
"http",
"headers",
"... | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/client/client.go#L83-L103 |
17,940 | docker/engine-api | client/task_list.go | TaskList | func (cli *Client) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
query := url.Values{}
if options.Filter.Len() > 0 {
filterJSON, err := filters.ToParam(options.Filter)
if err != nil {
return nil, err
}
query.Set("filters", filterJSON)
}
resp, err := cli.get(ctx, ... | go | func (cli *Client) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
query := url.Values{}
if options.Filter.Len() > 0 {
filterJSON, err := filters.ToParam(options.Filter)
if err != nil {
return nil, err
}
query.Set("filters", filterJSON)
}
resp, err := cli.get(ctx, ... | [
"func",
"(",
"cli",
"*",
"Client",
")",
"TaskList",
"(",
"ctx",
"context",
".",
"Context",
",",
"options",
"types",
".",
"TaskListOptions",
")",
"(",
"[",
"]",
"swarm",
".",
"Task",
",",
"error",
")",
"{",
"query",
":=",
"url",
".",
"Values",
"{",
... | // TaskList returns the list of tasks. | [
"TaskList",
"returns",
"the",
"list",
"of",
"tasks",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/client/task_list.go#L14-L35 |
17,941 | docker/engine-api | client/network_inspect.go | NetworkInspect | func (cli *Client) NetworkInspect(ctx context.Context, networkID string) (types.NetworkResource, error) {
networkResource, _, err := cli.NetworkInspectWithRaw(ctx, networkID)
return networkResource, err
} | go | func (cli *Client) NetworkInspect(ctx context.Context, networkID string) (types.NetworkResource, error) {
networkResource, _, err := cli.NetworkInspectWithRaw(ctx, networkID)
return networkResource, err
} | [
"func",
"(",
"cli",
"*",
"Client",
")",
"NetworkInspect",
"(",
"ctx",
"context",
".",
"Context",
",",
"networkID",
"string",
")",
"(",
"types",
".",
"NetworkResource",
",",
"error",
")",
"{",
"networkResource",
",",
"_",
",",
"err",
":=",
"cli",
".",
"... | // NetworkInspect returns the information for a specific network configured in the docker host. | [
"NetworkInspect",
"returns",
"the",
"information",
"for",
"a",
"specific",
"network",
"configured",
"in",
"the",
"docker",
"host",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/client/network_inspect.go#L14-L17 |
17,942 | docker/engine-api | types/filters/parse.go | ToParam | func ToParam(a Args) (string, error) {
// this way we don't URL encode {}, just empty space
if a.Len() == 0 {
return "", nil
}
buf, err := json.Marshal(a.fields)
if err != nil {
return "", err
}
return string(buf), nil
} | go | func ToParam(a Args) (string, error) {
// this way we don't URL encode {}, just empty space
if a.Len() == 0 {
return "", nil
}
buf, err := json.Marshal(a.fields)
if err != nil {
return "", err
}
return string(buf), nil
} | [
"func",
"ToParam",
"(",
"a",
"Args",
")",
"(",
"string",
",",
"error",
")",
"{",
"// this way we don't URL encode {}, just empty space",
"if",
"a",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
",",
"nil",
"\n",
"}",
"\n\n",
"buf",
",",
"... | // ToParam packs the Args into a string for easy transport from client to server. | [
"ToParam",
"packs",
"the",
"Args",
"into",
"a",
"string",
"for",
"easy",
"transport",
"from",
"client",
"to",
"server",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/types/filters/parse.go#L60-L71 |
17,943 | docker/engine-api | types/filters/parse.go | FromParam | func FromParam(p string) (Args, error) {
if len(p) == 0 {
return NewArgs(), nil
}
r := strings.NewReader(p)
d := json.NewDecoder(r)
m := map[string]map[string]bool{}
if err := d.Decode(&m); err != nil {
r.Seek(0, 0)
// Allow parsing old arguments in slice format.
// Because other libraries might be sen... | go | func FromParam(p string) (Args, error) {
if len(p) == 0 {
return NewArgs(), nil
}
r := strings.NewReader(p)
d := json.NewDecoder(r)
m := map[string]map[string]bool{}
if err := d.Decode(&m); err != nil {
r.Seek(0, 0)
// Allow parsing old arguments in slice format.
// Because other libraries might be sen... | [
"func",
"FromParam",
"(",
"p",
"string",
")",
"(",
"Args",
",",
"error",
")",
"{",
"if",
"len",
"(",
"p",
")",
"==",
"0",
"{",
"return",
"NewArgs",
"(",
")",
",",
"nil",
"\n",
"}",
"\n\n",
"r",
":=",
"strings",
".",
"NewReader",
"(",
"p",
")",
... | // FromParam unpacks the filter Args. | [
"FromParam",
"unpacks",
"the",
"filter",
"Args",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/types/filters/parse.go#L96-L118 |
17,944 | docker/engine-api | types/filters/parse.go | Get | func (filters Args) Get(field string) []string {
values := filters.fields[field]
if values == nil {
return make([]string, 0)
}
slice := make([]string, 0, len(values))
for key := range values {
slice = append(slice, key)
}
return slice
} | go | func (filters Args) Get(field string) []string {
values := filters.fields[field]
if values == nil {
return make([]string, 0)
}
slice := make([]string, 0, len(values))
for key := range values {
slice = append(slice, key)
}
return slice
} | [
"func",
"(",
"filters",
"Args",
")",
"Get",
"(",
"field",
"string",
")",
"[",
"]",
"string",
"{",
"values",
":=",
"filters",
".",
"fields",
"[",
"field",
"]",
"\n",
"if",
"values",
"==",
"nil",
"{",
"return",
"make",
"(",
"[",
"]",
"string",
",",
... | // Get returns the list of values associates with a field.
// It returns a slice of strings to keep backwards compatibility with old code. | [
"Get",
"returns",
"the",
"list",
"of",
"values",
"associates",
"with",
"a",
"field",
".",
"It",
"returns",
"a",
"slice",
"of",
"strings",
"to",
"keep",
"backwards",
"compatibility",
"with",
"old",
"code",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/types/filters/parse.go#L122-L132 |
17,945 | docker/engine-api | types/filters/parse.go | Add | func (filters Args) Add(name, value string) {
if _, ok := filters.fields[name]; ok {
filters.fields[name][value] = true
} else {
filters.fields[name] = map[string]bool{value: true}
}
} | go | func (filters Args) Add(name, value string) {
if _, ok := filters.fields[name]; ok {
filters.fields[name][value] = true
} else {
filters.fields[name] = map[string]bool{value: true}
}
} | [
"func",
"(",
"filters",
"Args",
")",
"Add",
"(",
"name",
",",
"value",
"string",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"filters",
".",
"fields",
"[",
"name",
"]",
";",
"ok",
"{",
"filters",
".",
"fields",
"[",
"name",
"]",
"[",
"value",
"]",
"=... | // Add adds a new value to a filter field. | [
"Add",
"adds",
"a",
"new",
"value",
"to",
"a",
"filter",
"field",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/types/filters/parse.go#L135-L141 |
17,946 | docker/engine-api | types/filters/parse.go | Del | func (filters Args) Del(name, value string) {
if _, ok := filters.fields[name]; ok {
delete(filters.fields[name], value)
}
} | go | func (filters Args) Del(name, value string) {
if _, ok := filters.fields[name]; ok {
delete(filters.fields[name], value)
}
} | [
"func",
"(",
"filters",
"Args",
")",
"Del",
"(",
"name",
",",
"value",
"string",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"filters",
".",
"fields",
"[",
"name",
"]",
";",
"ok",
"{",
"delete",
"(",
"filters",
".",
"fields",
"[",
"name",
"]",
",",
"... | // Del removes a value from a filter field. | [
"Del",
"removes",
"a",
"value",
"from",
"a",
"filter",
"field",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/types/filters/parse.go#L144-L148 |
17,947 | docker/engine-api | types/filters/parse.go | ExactMatch | func (filters Args) ExactMatch(field, source string) bool {
fieldValues, ok := filters.fields[field]
//do not filter if there is no filter set or cannot determine filter
if !ok || len(fieldValues) == 0 {
return true
}
// try to match full name value to avoid O(N) regular expression matching
return fieldValues[... | go | func (filters Args) ExactMatch(field, source string) bool {
fieldValues, ok := filters.fields[field]
//do not filter if there is no filter set or cannot determine filter
if !ok || len(fieldValues) == 0 {
return true
}
// try to match full name value to avoid O(N) regular expression matching
return fieldValues[... | [
"func",
"(",
"filters",
"Args",
")",
"ExactMatch",
"(",
"field",
",",
"source",
"string",
")",
"bool",
"{",
"fieldValues",
",",
"ok",
":=",
"filters",
".",
"fields",
"[",
"field",
"]",
"\n",
"//do not filter if there is no filter set or cannot determine filter",
"... | // ExactMatch returns true if the source matches exactly one of the filters. | [
"ExactMatch",
"returns",
"true",
"if",
"the",
"source",
"matches",
"exactly",
"one",
"of",
"the",
"filters",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/types/filters/parse.go#L210-L219 |
17,948 | docker/engine-api | types/filters/parse.go | UniqueExactMatch | func (filters Args) UniqueExactMatch(field, source string) bool {
fieldValues := filters.fields[field]
//do not filter if there is no filter set or cannot determine filter
if len(fieldValues) == 0 {
return true
}
if len(filters.fields[field]) != 1 {
return false
}
// try to match full name value to avoid O(... | go | func (filters Args) UniqueExactMatch(field, source string) bool {
fieldValues := filters.fields[field]
//do not filter if there is no filter set or cannot determine filter
if len(fieldValues) == 0 {
return true
}
if len(filters.fields[field]) != 1 {
return false
}
// try to match full name value to avoid O(... | [
"func",
"(",
"filters",
"Args",
")",
"UniqueExactMatch",
"(",
"field",
",",
"source",
"string",
")",
"bool",
"{",
"fieldValues",
":=",
"filters",
".",
"fields",
"[",
"field",
"]",
"\n",
"//do not filter if there is no filter set or cannot determine filter",
"if",
"l... | // UniqueExactMatch returns true if there is only one filter and the source matches exactly this one. | [
"UniqueExactMatch",
"returns",
"true",
"if",
"there",
"is",
"only",
"one",
"filter",
"and",
"the",
"source",
"matches",
"exactly",
"this",
"one",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/types/filters/parse.go#L222-L234 |
17,949 | docker/engine-api | types/filters/parse.go | FuzzyMatch | func (filters Args) FuzzyMatch(field, source string) bool {
if filters.ExactMatch(field, source) {
return true
}
fieldValues := filters.fields[field]
for prefix := range fieldValues {
if strings.HasPrefix(source, prefix) {
return true
}
}
return false
} | go | func (filters Args) FuzzyMatch(field, source string) bool {
if filters.ExactMatch(field, source) {
return true
}
fieldValues := filters.fields[field]
for prefix := range fieldValues {
if strings.HasPrefix(source, prefix) {
return true
}
}
return false
} | [
"func",
"(",
"filters",
"Args",
")",
"FuzzyMatch",
"(",
"field",
",",
"source",
"string",
")",
"bool",
"{",
"if",
"filters",
".",
"ExactMatch",
"(",
"field",
",",
"source",
")",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"fieldValues",
":=",
"filters",
... | // FuzzyMatch returns true if the source matches exactly one of the filters,
// or the source has one of the filters as a prefix. | [
"FuzzyMatch",
"returns",
"true",
"if",
"the",
"source",
"matches",
"exactly",
"one",
"of",
"the",
"filters",
"or",
"the",
"source",
"has",
"one",
"of",
"the",
"filters",
"as",
"a",
"prefix",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/types/filters/parse.go#L238-L250 |
17,950 | docker/engine-api | types/filters/parse.go | Include | func (filters Args) Include(field string) bool {
_, ok := filters.fields[field]
return ok
} | go | func (filters Args) Include(field string) bool {
_, ok := filters.fields[field]
return ok
} | [
"func",
"(",
"filters",
"Args",
")",
"Include",
"(",
"field",
"string",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"filters",
".",
"fields",
"[",
"field",
"]",
"\n",
"return",
"ok",
"\n",
"}"
] | // Include returns true if the name of the field to filter is in the filters. | [
"Include",
"returns",
"true",
"if",
"the",
"name",
"of",
"the",
"field",
"to",
"filter",
"is",
"in",
"the",
"filters",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/types/filters/parse.go#L253-L256 |
17,951 | docker/engine-api | types/filters/parse.go | Validate | func (filters Args) Validate(accepted map[string]bool) error {
for name := range filters.fields {
if !accepted[name] {
return fmt.Errorf("Invalid filter '%s'", name)
}
}
return nil
} | go | func (filters Args) Validate(accepted map[string]bool) error {
for name := range filters.fields {
if !accepted[name] {
return fmt.Errorf("Invalid filter '%s'", name)
}
}
return nil
} | [
"func",
"(",
"filters",
"Args",
")",
"Validate",
"(",
"accepted",
"map",
"[",
"string",
"]",
"bool",
")",
"error",
"{",
"for",
"name",
":=",
"range",
"filters",
".",
"fields",
"{",
"if",
"!",
"accepted",
"[",
"name",
"]",
"{",
"return",
"fmt",
".",
... | // Validate ensures that all the fields in the filter are valid.
// It returns an error as soon as it finds an invalid field. | [
"Validate",
"ensures",
"that",
"all",
"the",
"fields",
"in",
"the",
"filter",
"are",
"valid",
".",
"It",
"returns",
"an",
"error",
"as",
"soon",
"as",
"it",
"finds",
"an",
"invalid",
"field",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/types/filters/parse.go#L260-L267 |
17,952 | docker/engine-api | client/login.go | RegistryLogin | func (cli *Client) RegistryLogin(ctx context.Context, auth types.AuthConfig) (types.AuthResponse, error) {
resp, err := cli.post(ctx, "/auth", url.Values{}, auth, nil)
if resp.statusCode == http.StatusUnauthorized {
return types.AuthResponse{}, unauthorizedError{err}
}
if err != nil {
return types.AuthResponse... | go | func (cli *Client) RegistryLogin(ctx context.Context, auth types.AuthConfig) (types.AuthResponse, error) {
resp, err := cli.post(ctx, "/auth", url.Values{}, auth, nil)
if resp.statusCode == http.StatusUnauthorized {
return types.AuthResponse{}, unauthorizedError{err}
}
if err != nil {
return types.AuthResponse... | [
"func",
"(",
"cli",
"*",
"Client",
")",
"RegistryLogin",
"(",
"ctx",
"context",
".",
"Context",
",",
"auth",
"types",
".",
"AuthConfig",
")",
"(",
"types",
".",
"AuthResponse",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"cli",
".",
"post",
"("... | // RegistryLogin authenticates the docker server with a given docker registry.
// It returns UnauthorizerError when the authentication fails. | [
"RegistryLogin",
"authenticates",
"the",
"docker",
"server",
"with",
"a",
"given",
"docker",
"registry",
".",
"It",
"returns",
"UnauthorizerError",
"when",
"the",
"authentication",
"fails",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/client/login.go#L14-L28 |
17,953 | docker/engine-api | types/reference/image_reference.go | GetTagFromNamedRef | func GetTagFromNamedRef(ref distreference.Named) string {
var tag string
switch x := ref.(type) {
case distreference.Digested:
tag = x.Digest().String()
case distreference.NamedTagged:
tag = x.Tag()
default:
tag = "latest"
}
return tag
} | go | func GetTagFromNamedRef(ref distreference.Named) string {
var tag string
switch x := ref.(type) {
case distreference.Digested:
tag = x.Digest().String()
case distreference.NamedTagged:
tag = x.Tag()
default:
tag = "latest"
}
return tag
} | [
"func",
"GetTagFromNamedRef",
"(",
"ref",
"distreference",
".",
"Named",
")",
"string",
"{",
"var",
"tag",
"string",
"\n",
"switch",
"x",
":=",
"ref",
".",
"(",
"type",
")",
"{",
"case",
"distreference",
".",
"Digested",
":",
"tag",
"=",
"x",
".",
"Dig... | // GetTagFromNamedRef returns a tag from the specified reference.
// This function is necessary as long as the docker "server" api makes the distinction between repository
// and tags. | [
"GetTagFromNamedRef",
"returns",
"a",
"tag",
"from",
"the",
"specified",
"reference",
".",
"This",
"function",
"is",
"necessary",
"as",
"long",
"as",
"the",
"docker",
"server",
"api",
"makes",
"the",
"distinction",
"between",
"repository",
"and",
"tags",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/types/reference/image_reference.go#L23-L34 |
17,954 | docker/engine-api | client/container_start.go | ContainerStart | func (cli *Client) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error {
query := url.Values{}
if len(options.CheckpointID) != 0 {
query.Set("checkpoint", options.CheckpointID)
}
resp, err := cli.post(ctx, "/containers/"+containerID+"/start", query, nil, nil)
ensur... | go | func (cli *Client) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error {
query := url.Values{}
if len(options.CheckpointID) != 0 {
query.Set("checkpoint", options.CheckpointID)
}
resp, err := cli.post(ctx, "/containers/"+containerID+"/start", query, nil, nil)
ensur... | [
"func",
"(",
"cli",
"*",
"Client",
")",
"ContainerStart",
"(",
"ctx",
"context",
".",
"Context",
",",
"containerID",
"string",
",",
"options",
"types",
".",
"ContainerStartOptions",
")",
"error",
"{",
"query",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
... | // ContainerStart sends a request to the docker daemon to start a container. | [
"ContainerStart",
"sends",
"a",
"request",
"to",
"the",
"docker",
"daemon",
"to",
"start",
"a",
"container",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/client/container_start.go#L12-L21 |
17,955 | docker/engine-api | client/service_remove.go | ServiceRemove | func (cli *Client) ServiceRemove(ctx context.Context, serviceID string) error {
resp, err := cli.delete(ctx, "/services/"+serviceID, nil, nil)
ensureReaderClosed(resp)
return err
} | go | func (cli *Client) ServiceRemove(ctx context.Context, serviceID string) error {
resp, err := cli.delete(ctx, "/services/"+serviceID, nil, nil)
ensureReaderClosed(resp)
return err
} | [
"func",
"(",
"cli",
"*",
"Client",
")",
"ServiceRemove",
"(",
"ctx",
"context",
".",
"Context",
",",
"serviceID",
"string",
")",
"error",
"{",
"resp",
",",
"err",
":=",
"cli",
".",
"delete",
"(",
"ctx",
",",
"\"",
"\"",
"+",
"serviceID",
",",
"nil",
... | // ServiceRemove kills and removes a service. | [
"ServiceRemove",
"kills",
"and",
"removes",
"a",
"service",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/client/service_remove.go#L6-L10 |
17,956 | docker/engine-api | client/node_remove.go | NodeRemove | func (cli *Client) NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error {
query := url.Values{}
if options.Force {
query.Set("force", "1")
}
resp, err := cli.delete(ctx, "/nodes/"+nodeID, query, nil)
ensureReaderClosed(resp)
return err
} | go | func (cli *Client) NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error {
query := url.Values{}
if options.Force {
query.Set("force", "1")
}
resp, err := cli.delete(ctx, "/nodes/"+nodeID, query, nil)
ensureReaderClosed(resp)
return err
} | [
"func",
"(",
"cli",
"*",
"Client",
")",
"NodeRemove",
"(",
"ctx",
"context",
".",
"Context",
",",
"nodeID",
"string",
",",
"options",
"types",
".",
"NodeRemoveOptions",
")",
"error",
"{",
"query",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
"if",
"opti... | // NodeRemove removes a Node. | [
"NodeRemove",
"removes",
"a",
"Node",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/client/node_remove.go#L12-L21 |
17,957 | docker/engine-api | client/task_inspect.go | TaskInspectWithRaw | func (cli *Client) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) {
serverResp, err := cli.get(ctx, "/tasks/"+taskID, nil, nil)
if err != nil {
if serverResp.statusCode == http.StatusNotFound {
return swarm.Task{}, nil, taskNotFoundError{taskID}
}
return swarm.Task{}, nil,... | go | func (cli *Client) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) {
serverResp, err := cli.get(ctx, "/tasks/"+taskID, nil, nil)
if err != nil {
if serverResp.statusCode == http.StatusNotFound {
return swarm.Task{}, nil, taskNotFoundError{taskID}
}
return swarm.Task{}, nil,... | [
"func",
"(",
"cli",
"*",
"Client",
")",
"TaskInspectWithRaw",
"(",
"ctx",
"context",
".",
"Context",
",",
"taskID",
"string",
")",
"(",
"swarm",
".",
"Task",
",",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"serverResp",
",",
"err",
":=",
"cli",
".",
... | // TaskInspectWithRaw returns the task information and its raw representation.. | [
"TaskInspectWithRaw",
"returns",
"the",
"task",
"information",
"and",
"its",
"raw",
"representation",
".."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/client/task_inspect.go#L15-L34 |
17,958 | docker/engine-api | client/checkpoint_list.go | CheckpointList | func (cli *Client) CheckpointList(ctx context.Context, container string) ([]types.Checkpoint, error) {
var checkpoints []types.Checkpoint
resp, err := cli.get(ctx, "/containers/"+container+"/checkpoints", nil, nil)
if err != nil {
return checkpoints, err
}
err = json.NewDecoder(resp.body).Decode(&checkpoints)
... | go | func (cli *Client) CheckpointList(ctx context.Context, container string) ([]types.Checkpoint, error) {
var checkpoints []types.Checkpoint
resp, err := cli.get(ctx, "/containers/"+container+"/checkpoints", nil, nil)
if err != nil {
return checkpoints, err
}
err = json.NewDecoder(resp.body).Decode(&checkpoints)
... | [
"func",
"(",
"cli",
"*",
"Client",
")",
"CheckpointList",
"(",
"ctx",
"context",
".",
"Context",
",",
"container",
"string",
")",
"(",
"[",
"]",
"types",
".",
"Checkpoint",
",",
"error",
")",
"{",
"var",
"checkpoints",
"[",
"]",
"types",
".",
"Checkpoi... | // CheckpointList returns the volumes configured in the docker host. | [
"CheckpointList",
"returns",
"the",
"volumes",
"configured",
"in",
"the",
"docker",
"host",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/client/checkpoint_list.go#L11-L22 |
17,959 | docker/engine-api | client/request.go | post | func (cli *Client) post(ctx context.Context, path string, query url.Values, obj interface{}, headers map[string][]string) (serverResponse, error) {
return cli.sendRequest(ctx, "POST", path, query, obj, headers)
} | go | func (cli *Client) post(ctx context.Context, path string, query url.Values, obj interface{}, headers map[string][]string) (serverResponse, error) {
return cli.sendRequest(ctx, "POST", path, query, obj, headers)
} | [
"func",
"(",
"cli",
"*",
"Client",
")",
"post",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"query",
"url",
".",
"Values",
",",
"obj",
"interface",
"{",
"}",
",",
"headers",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",... | // postWithContext sends an http request to the docker API using the method POST with a specific go context. | [
"postWithContext",
"sends",
"an",
"http",
"request",
"to",
"the",
"docker",
"API",
"using",
"the",
"method",
"POST",
"with",
"a",
"specific",
"go",
"context",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/client/request.go#L38-L40 |
17,960 | docker/engine-api | client/events.go | Events | func (cli *Client) Events(ctx context.Context, options types.EventsOptions) (io.ReadCloser, error) {
query := url.Values{}
ref := time.Now()
if options.Since != "" {
ts, err := timetypes.GetTimestamp(options.Since, ref)
if err != nil {
return nil, err
}
query.Set("since", ts)
}
if options.Until != "" {... | go | func (cli *Client) Events(ctx context.Context, options types.EventsOptions) (io.ReadCloser, error) {
query := url.Values{}
ref := time.Now()
if options.Since != "" {
ts, err := timetypes.GetTimestamp(options.Since, ref)
if err != nil {
return nil, err
}
query.Set("since", ts)
}
if options.Until != "" {... | [
"func",
"(",
"cli",
"*",
"Client",
")",
"Events",
"(",
"ctx",
"context",
".",
"Context",
",",
"options",
"types",
".",
"EventsOptions",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"query",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
... | // Events returns a stream of events in the daemon in a ReadCloser.
// It's up to the caller to close the stream. | [
"Events",
"returns",
"a",
"stream",
"of",
"events",
"in",
"the",
"daemon",
"in",
"a",
"ReadCloser",
".",
"It",
"s",
"up",
"to",
"the",
"caller",
"to",
"close",
"the",
"stream",
"."
] | 4290f40c056686fcaa5c9caf02eac1dde9315adf | https://github.com/docker/engine-api/blob/4290f40c056686fcaa5c9caf02eac1dde9315adf/client/events.go#L17-L48 |
17,961 | revel/cmd | revel/version.go | UpdateConfig | func (v *VersionCommand) UpdateConfig(c *model.CommandConfig, args []string) bool {
if len(args) > 0 {
c.Version.ImportPath = args[0]
}
return true
} | go | func (v *VersionCommand) UpdateConfig(c *model.CommandConfig, args []string) bool {
if len(args) > 0 {
c.Version.ImportPath = args[0]
}
return true
} | [
"func",
"(",
"v",
"*",
"VersionCommand",
")",
"UpdateConfig",
"(",
"c",
"*",
"model",
".",
"CommandConfig",
",",
"args",
"[",
"]",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"args",
")",
">",
"0",
"{",
"c",
".",
"Version",
".",
"ImportPath",
"="... | // Update the version | [
"Update",
"the",
"version"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/version.go#L58-L63 |
17,962 | revel/cmd | revel/version.go | RunWith | func (v *VersionCommand) RunWith(c *model.CommandConfig) (err error) {
utils.Logger.Info("Requesting version information", "config", c)
v.Command = c
// Update the versions with the local values
v.updateLocalVersions()
needsUpdates := true
versionInfo := ""
for x := 0; x < 2 && needsUpdates; x++ {
needsUpdat... | go | func (v *VersionCommand) RunWith(c *model.CommandConfig) (err error) {
utils.Logger.Info("Requesting version information", "config", c)
v.Command = c
// Update the versions with the local values
v.updateLocalVersions()
needsUpdates := true
versionInfo := ""
for x := 0; x < 2 && needsUpdates; x++ {
needsUpdat... | [
"func",
"(",
"v",
"*",
"VersionCommand",
")",
"RunWith",
"(",
"c",
"*",
"model",
".",
"CommandConfig",
")",
"(",
"err",
"error",
")",
"{",
"utils",
".",
"Logger",
".",
"Info",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"c",
")",
"\n",
"v",
".",
"Co... | // Displays the version of go and Revel | [
"Displays",
"the",
"version",
"of",
"go",
"and",
"Revel"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/version.go#L66-L90 |
17,963 | revel/cmd | revel/version.go | doRepoCheck | func (v *VersionCommand) doRepoCheck(updateLibs bool) (versionInfo string, needsUpdate bool) {
var (
title string
localVersion *model.Version
)
for _, repo := range []string{"revel", "cmd", "modules"} {
versonFromRepo, err := v.versionFromRepo(repo, "", "version.go")
if err != nil {
utils.Logger.Info("Fai... | go | func (v *VersionCommand) doRepoCheck(updateLibs bool) (versionInfo string, needsUpdate bool) {
var (
title string
localVersion *model.Version
)
for _, repo := range []string{"revel", "cmd", "modules"} {
versonFromRepo, err := v.versionFromRepo(repo, "", "version.go")
if err != nil {
utils.Logger.Info("Fai... | [
"func",
"(",
"v",
"*",
"VersionCommand",
")",
"doRepoCheck",
"(",
"updateLibs",
"bool",
")",
"(",
"versionInfo",
"string",
",",
"needsUpdate",
"bool",
")",
"{",
"var",
"(",
"title",
"string",
"\n",
"localVersion",
"*",
"model",
".",
"Version",
"\n",
")",
... | // Checks the Revel repos for the latest version | [
"Checks",
"the",
"Revel",
"repos",
"for",
"the",
"latest",
"version"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/version.go#L93-L126 |
17,964 | revel/cmd | revel/version.go | doUpdate | func (v *VersionCommand) doUpdate(title, repo string, local, remote *model.Version) {
utils.Logger.Info("Updating package", "package", title, "repo",repo)
fmt.Println("Attempting to update package", title)
if err := v.Command.PackageResolver(repo); err != nil {
utils.Logger.Error("Unable to update repo", "repo", r... | go | func (v *VersionCommand) doUpdate(title, repo string, local, remote *model.Version) {
utils.Logger.Info("Updating package", "package", title, "repo",repo)
fmt.Println("Attempting to update package", title)
if err := v.Command.PackageResolver(repo); err != nil {
utils.Logger.Error("Unable to update repo", "repo", r... | [
"func",
"(",
"v",
"*",
"VersionCommand",
")",
"doUpdate",
"(",
"title",
",",
"repo",
"string",
",",
"local",
",",
"remote",
"*",
"model",
".",
"Version",
")",
"{",
"utils",
".",
"Logger",
".",
"Info",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"title",... | // Checks for updates if needed | [
"Checks",
"for",
"updates",
"if",
"needed"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/version.go#L129-L139 |
17,965 | revel/cmd | revel/version.go | outputVersion | func (v *VersionCommand) outputVersion(title, repo string, local, remote *model.Version) (output string) {
buffer := &bytes.Buffer{}
remoteVersion := "Unknown"
if remote != nil {
remoteVersion = remote.VersionString()
}
localVersion := "Unknown"
if local != nil {
localVersion = local.VersionString()
}
fmt.... | go | func (v *VersionCommand) outputVersion(title, repo string, local, remote *model.Version) (output string) {
buffer := &bytes.Buffer{}
remoteVersion := "Unknown"
if remote != nil {
remoteVersion = remote.VersionString()
}
localVersion := "Unknown"
if local != nil {
localVersion = local.VersionString()
}
fmt.... | [
"func",
"(",
"v",
"*",
"VersionCommand",
")",
"outputVersion",
"(",
"title",
",",
"repo",
"string",
",",
"local",
",",
"remote",
"*",
"model",
".",
"Version",
")",
"(",
"output",
"string",
")",
"{",
"buffer",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"... | // Prints out the local and remote versions, calls update if needed | [
"Prints",
"out",
"the",
"local",
"and",
"remote",
"versions",
"calls",
"update",
"if",
"needed"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/version.go#L142-L155 |
17,966 | revel/cmd | revel/version.go | versionFromRepo | func (v *VersionCommand) versionFromRepo(repoName, branchName, fileName string) (version *model.Version, err error) {
if branchName == "" {
branchName = "master"
}
// Try to download the version of file from the repo, just use an http connection to retrieve the source
// Assuming that the repo is github
fullurl ... | go | func (v *VersionCommand) versionFromRepo(repoName, branchName, fileName string) (version *model.Version, err error) {
if branchName == "" {
branchName = "master"
}
// Try to download the version of file from the repo, just use an http connection to retrieve the source
// Assuming that the repo is github
fullurl ... | [
"func",
"(",
"v",
"*",
"VersionCommand",
")",
"versionFromRepo",
"(",
"repoName",
",",
"branchName",
",",
"fileName",
"string",
")",
"(",
"version",
"*",
"model",
".",
"Version",
",",
"err",
"error",
")",
"{",
"if",
"branchName",
"==",
"\"",
"\"",
"{",
... | // Returns the version from the repository | [
"Returns",
"the",
"version",
"from",
"the",
"repository"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/version.go#L158-L177 |
17,967 | revel/cmd | revel/version.go | updateLocalVersions | func (v *VersionCommand) updateLocalVersions() {
v.cmdVersion = &model.Version{}
v.cmdVersion.ParseVersion(cmd.Version)
v.cmdVersion.BuildDate = cmd.BuildDate
v.cmdVersion.MinGoVersion = cmd.MinimumGoVersion
var modulePath, revelPath string
_, revelPath, err := utils.FindSrcPaths(v.Command.ImportPath, model.Rev... | go | func (v *VersionCommand) updateLocalVersions() {
v.cmdVersion = &model.Version{}
v.cmdVersion.ParseVersion(cmd.Version)
v.cmdVersion.BuildDate = cmd.BuildDate
v.cmdVersion.MinGoVersion = cmd.MinimumGoVersion
var modulePath, revelPath string
_, revelPath, err := utils.FindSrcPaths(v.Command.ImportPath, model.Rev... | [
"func",
"(",
"v",
"*",
"VersionCommand",
")",
"updateLocalVersions",
"(",
")",
"{",
"v",
".",
"cmdVersion",
"=",
"&",
"model",
".",
"Version",
"{",
"}",
"\n",
"v",
".",
"cmdVersion",
".",
"ParseVersion",
"(",
"cmd",
".",
"Version",
")",
"\n",
"v",
".... | // Fetch the local version of revel from the file system | [
"Fetch",
"the",
"local",
"version",
"of",
"revel",
"from",
"the",
"file",
"system"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/version.go#L231-L262 |
17,968 | revel/cmd | revel/build.go | updateBuildConfig | func updateBuildConfig(c *model.CommandConfig, args []string) bool {
c.Index = model.BUILD
// If arguments were passed in then there must be two
if len(args) < 2 {
fmt.Fprintf(os.Stderr, "%s\n%s", cmdBuild.UsageLine, cmdBuild.Long)
return false
}
c.Build.ImportPath = args[0]
c.Build.TargetPath = args[1]
if ... | go | func updateBuildConfig(c *model.CommandConfig, args []string) bool {
c.Index = model.BUILD
// If arguments were passed in then there must be two
if len(args) < 2 {
fmt.Fprintf(os.Stderr, "%s\n%s", cmdBuild.UsageLine, cmdBuild.Long)
return false
}
c.Build.ImportPath = args[0]
c.Build.TargetPath = args[1]
if ... | [
"func",
"updateBuildConfig",
"(",
"c",
"*",
"model",
".",
"CommandConfig",
",",
"args",
"[",
"]",
"string",
")",
"bool",
"{",
"c",
".",
"Index",
"=",
"model",
".",
"BUILD",
"\n",
"// If arguments were passed in then there must be two",
"if",
"len",
"(",
"args"... | // The update config updates the configuration command so that it can run | [
"The",
"update",
"config",
"updates",
"the",
"configuration",
"command",
"so",
"that",
"it",
"can",
"run"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/build.go#L39-L53 |
17,969 | revel/cmd | revel/build.go | buildApp | func buildApp(c *model.CommandConfig) (err error) {
appImportPath, destPath, mode := c.ImportPath, c.Build.TargetPath, DefaultRunMode
if len(c.Build.Mode) > 0 {
mode = c.Build.Mode
}
// Convert target to absolute path
c.Build.TargetPath, _ = filepath.Abs(destPath)
c.Build.Mode = mode
c.Build.ImportPath = appI... | go | func buildApp(c *model.CommandConfig) (err error) {
appImportPath, destPath, mode := c.ImportPath, c.Build.TargetPath, DefaultRunMode
if len(c.Build.Mode) > 0 {
mode = c.Build.Mode
}
// Convert target to absolute path
c.Build.TargetPath, _ = filepath.Abs(destPath)
c.Build.Mode = mode
c.Build.ImportPath = appI... | [
"func",
"buildApp",
"(",
"c",
"*",
"model",
".",
"CommandConfig",
")",
"(",
"err",
"error",
")",
"{",
"appImportPath",
",",
"destPath",
",",
"mode",
":=",
"c",
".",
"ImportPath",
",",
"c",
".",
"Build",
".",
"TargetPath",
",",
"DefaultRunMode",
"\n",
"... | // The main entry point to build application from command line | [
"The",
"main",
"entry",
"point",
"to",
"build",
"application",
"from",
"command",
"line"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/build.go#L56-L99 |
17,970 | revel/cmd | revel/build.go | buildCopyFiles | func buildCopyFiles(c *model.CommandConfig, app *harness.App, revel_paths *model.RevelContainer) (packageFolders []string, err error) {
appImportPath, destPath := c.ImportPath, c.Build.TargetPath
// Revel and the app are in a directory structure mirroring import path
srcPath := filepath.Join(destPath, "src")
destB... | go | func buildCopyFiles(c *model.CommandConfig, app *harness.App, revel_paths *model.RevelContainer) (packageFolders []string, err error) {
appImportPath, destPath := c.ImportPath, c.Build.TargetPath
// Revel and the app are in a directory structure mirroring import path
srcPath := filepath.Join(destPath, "src")
destB... | [
"func",
"buildCopyFiles",
"(",
"c",
"*",
"model",
".",
"CommandConfig",
",",
"app",
"*",
"harness",
".",
"App",
",",
"revel_paths",
"*",
"model",
".",
"RevelContainer",
")",
"(",
"packageFolders",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"appIm... | // Copy the files to the target | [
"Copy",
"the",
"files",
"to",
"the",
"target"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/build.go#L102-L147 |
17,971 | revel/cmd | revel/build.go | buildCopyModules | func buildCopyModules(c *model.CommandConfig, revel_paths *model.RevelContainer, packageFolders []string) (err error) {
destPath := filepath.Join(c.Build.TargetPath, "src")
// Find all the modules used and copy them over.
config := revel_paths.Config.Raw()
modulePaths := make(map[string]string) // import path => fi... | go | func buildCopyModules(c *model.CommandConfig, revel_paths *model.RevelContainer, packageFolders []string) (err error) {
destPath := filepath.Join(c.Build.TargetPath, "src")
// Find all the modules used and copy them over.
config := revel_paths.Config.Raw()
modulePaths := make(map[string]string) // import path => fi... | [
"func",
"buildCopyModules",
"(",
"c",
"*",
"model",
".",
"CommandConfig",
",",
"revel_paths",
"*",
"model",
".",
"RevelContainer",
",",
"packageFolders",
"[",
"]",
"string",
")",
"(",
"err",
"error",
")",
"{",
"destPath",
":=",
"filepath",
".",
"Join",
"("... | // Based on the section copy over the build modules | [
"Based",
"on",
"the",
"section",
"copy",
"over",
"the",
"build",
"modules"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/build.go#L150-L203 |
17,972 | revel/cmd | revel/build.go | buildWriteScripts | func buildWriteScripts(c *model.CommandConfig, app *harness.App) (err error) {
tmplData := map[string]interface{}{
"BinName": filepath.Base(app.BinaryPath),
"ImportPath": c.Build.ImportPath,
"Mode": c.Build.Mode,
}
err = utils.GenerateTemplate(
filepath.Join(c.Build.TargetPath, "run.sh"),
PACKAGE... | go | func buildWriteScripts(c *model.CommandConfig, app *harness.App) (err error) {
tmplData := map[string]interface{}{
"BinName": filepath.Base(app.BinaryPath),
"ImportPath": c.Build.ImportPath,
"Mode": c.Build.Mode,
}
err = utils.GenerateTemplate(
filepath.Join(c.Build.TargetPath, "run.sh"),
PACKAGE... | [
"func",
"buildWriteScripts",
"(",
"c",
"*",
"model",
".",
"CommandConfig",
",",
"app",
"*",
"harness",
".",
"App",
")",
"(",
"err",
"error",
")",
"{",
"tmplData",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"filepath... | // Write the run scripts for the build | [
"Write",
"the",
"run",
"scripts",
"for",
"the",
"build"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/build.go#L206-L234 |
17,973 | revel/cmd | revel/build.go | buildSafetyCheck | func buildSafetyCheck(destPath string) error {
// First, verify that it is either already empty or looks like a previous
// build (to avoid clobbering anything)
if utils.Exists(destPath) && !utils.Empty(destPath) && !utils.Exists(filepath.Join(destPath, "run.sh")) {
return utils.NewBuildError("Abort: %s exists an... | go | func buildSafetyCheck(destPath string) error {
// First, verify that it is either already empty or looks like a previous
// build (to avoid clobbering anything)
if utils.Exists(destPath) && !utils.Empty(destPath) && !utils.Exists(filepath.Join(destPath, "run.sh")) {
return utils.NewBuildError("Abort: %s exists an... | [
"func",
"buildSafetyCheck",
"(",
"destPath",
"string",
")",
"error",
"{",
"// First, verify that it is either already empty or looks like a previous",
"// build (to avoid clobbering anything)",
"if",
"utils",
".",
"Exists",
"(",
"destPath",
")",
"&&",
"!",
"utils",
".",
"Em... | // Checks to see if the target folder exists and can be created | [
"Checks",
"to",
"see",
"if",
"the",
"target",
"folder",
"exists",
"and",
"can",
"be",
"created"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/build.go#L237-L253 |
17,974 | revel/cmd | model/revel_container.go | NewWrappedRevelCallback | func NewWrappedRevelCallback(fe func(key Event, value interface{}) (response EventResponse), ie func(pkgName string) error) RevelCallback {
return &WrappedRevelCallback{fe, ie}
} | go | func NewWrappedRevelCallback(fe func(key Event, value interface{}) (response EventResponse), ie func(pkgName string) error) RevelCallback {
return &WrappedRevelCallback{fe, ie}
} | [
"func",
"NewWrappedRevelCallback",
"(",
"fe",
"func",
"(",
"key",
"Event",
",",
"value",
"interface",
"{",
"}",
")",
"(",
"response",
"EventResponse",
")",
",",
"ie",
"func",
"(",
"pkgName",
"string",
")",
"error",
")",
"RevelCallback",
"{",
"return",
"&",... | // Simple Wrapped RevelCallback | [
"Simple",
"Wrapped",
"RevelCallback"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/revel_container.go#L78-L80 |
17,975 | revel/cmd | model/revel_container.go | FireEvent | func (w *WrappedRevelCallback) FireEvent(key Event, value interface{}) (response EventResponse) {
if w.FireEventFunction != nil {
response = w.FireEventFunction(key, value)
}
return
} | go | func (w *WrappedRevelCallback) FireEvent(key Event, value interface{}) (response EventResponse) {
if w.FireEventFunction != nil {
response = w.FireEventFunction(key, value)
}
return
} | [
"func",
"(",
"w",
"*",
"WrappedRevelCallback",
")",
"FireEvent",
"(",
"key",
"Event",
",",
"value",
"interface",
"{",
"}",
")",
"(",
"response",
"EventResponse",
")",
"{",
"if",
"w",
".",
"FireEventFunction",
"!=",
"nil",
"{",
"response",
"=",
"w",
".",
... | // Function to implement the FireEvent | [
"Function",
"to",
"implement",
"the",
"FireEvent"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/revel_container.go#L83-L88 |
17,976 | revel/cmd | model/revel_container.go | loadModules | func (rp *RevelContainer) loadModules(callback RevelCallback) (err error) {
keys := []string{}
for _, key := range rp.Config.Options("module.") {
keys = append(keys, key)
}
// Reorder module order by key name, a poor mans sort but at least it is consistent
sort.Strings(keys)
for _, key := range keys {
module... | go | func (rp *RevelContainer) loadModules(callback RevelCallback) (err error) {
keys := []string{}
for _, key := range rp.Config.Options("module.") {
keys = append(keys, key)
}
// Reorder module order by key name, a poor mans sort but at least it is consistent
sort.Strings(keys)
for _, key := range keys {
module... | [
"func",
"(",
"rp",
"*",
"RevelContainer",
")",
"loadModules",
"(",
"callback",
"RevelCallback",
")",
"(",
"err",
"error",
")",
"{",
"keys",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"key",
":=",
"range",
"rp",
".",
"Config",
".",
"... | // Loads modules based on the configuration setup.
// This will fire the REVEL_BEFORE_MODULE_LOADED, REVEL_AFTER_MODULE_LOADED
// for each module loaded. The callback will receive the RevelContainer, name, moduleImportPath and modulePath
// It will automatically add in the code paths for the module to the
// container ... | [
"Loads",
"modules",
"based",
"on",
"the",
"configuration",
"setup",
".",
"This",
"will",
"fire",
"the",
"REVEL_BEFORE_MODULE_LOADED",
"REVEL_AFTER_MODULE_LOADED",
"for",
"each",
"module",
"loaded",
".",
"The",
"callback",
"will",
"receive",
"the",
"RevelContainer",
... | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/revel_container.go#L214-L247 |
17,977 | revel/cmd | model/revel_container.go | addModulePaths | func (rp *RevelContainer) addModulePaths(name, importPath, modulePath string) {
if codePath := filepath.Join(modulePath, "app"); utils.DirExists(codePath) {
rp.CodePaths = append(rp.CodePaths, codePath)
rp.ModulePathMap[name] = modulePath
if viewsPath := filepath.Join(modulePath, "app", "views"); utils.DirExists... | go | func (rp *RevelContainer) addModulePaths(name, importPath, modulePath string) {
if codePath := filepath.Join(modulePath, "app"); utils.DirExists(codePath) {
rp.CodePaths = append(rp.CodePaths, codePath)
rp.ModulePathMap[name] = modulePath
if viewsPath := filepath.Join(modulePath, "app", "views"); utils.DirExists... | [
"func",
"(",
"rp",
"*",
"RevelContainer",
")",
"addModulePaths",
"(",
"name",
",",
"importPath",
",",
"modulePath",
"string",
")",
"{",
"if",
"codePath",
":=",
"filepath",
".",
"Join",
"(",
"modulePath",
",",
"\"",
"\"",
")",
";",
"utils",
".",
"DirExist... | // Adds a module paths to the container object | [
"Adds",
"a",
"module",
"paths",
"to",
"the",
"container",
"object"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/revel_container.go#L250-L268 |
17,978 | revel/cmd | harness/build.go | genSource | func genSource(paths *model.RevelContainer, dir, filename, templateSource string, args map[string]interface{}) error {
return utils.GenerateTemplate(filepath.Join(paths.AppPath, dir, filename), templateSource, args)
} | go | func genSource(paths *model.RevelContainer, dir, filename, templateSource string, args map[string]interface{}) error {
return utils.GenerateTemplate(filepath.Join(paths.AppPath, dir, filename), templateSource, args)
} | [
"func",
"genSource",
"(",
"paths",
"*",
"model",
".",
"RevelContainer",
",",
"dir",
",",
"filename",
",",
"templateSource",
"string",
",",
"args",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"utils",
".",
"GenerateTemplat... | // genSource renders the given template to produce source code, which it writes
// to the given directory and file. | [
"genSource",
"renders",
"the",
"given",
"template",
"to",
"produce",
"source",
"code",
"which",
"it",
"writes",
"to",
"the",
"given",
"directory",
"and",
"file",
"."
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/build.go#L309-L312 |
17,979 | revel/cmd | harness/build.go | calcImportAliases | func calcImportAliases(src *model.SourceInfo) map[string]string {
aliases := make(map[string]string)
typeArrays := [][]*model.TypeInfo{src.ControllerSpecs(), src.TestSuites()}
for _, specs := range typeArrays {
for _, spec := range specs {
addAlias(aliases, spec.ImportPath, spec.PackageName)
for _, methSpec... | go | func calcImportAliases(src *model.SourceInfo) map[string]string {
aliases := make(map[string]string)
typeArrays := [][]*model.TypeInfo{src.ControllerSpecs(), src.TestSuites()}
for _, specs := range typeArrays {
for _, spec := range specs {
addAlias(aliases, spec.ImportPath, spec.PackageName)
for _, methSpec... | [
"func",
"calcImportAliases",
"(",
"src",
"*",
"model",
".",
"SourceInfo",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"aliases",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"typeArrays",
":=",
"[",
"]",
"[",
"]",
"*",
"model... | // Looks through all the method args and returns a set of unique import paths
// that cover all the method arg types.
// Additionally, assign package aliases when necessary to resolve ambiguity. | [
"Looks",
"through",
"all",
"the",
"method",
"args",
"and",
"returns",
"a",
"set",
"of",
"unique",
"import",
"paths",
"that",
"cover",
"all",
"the",
"method",
"arg",
"types",
".",
"Additionally",
"assign",
"package",
"aliases",
"when",
"necessary",
"to",
"res... | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/build.go#L317-L344 |
17,980 | revel/cmd | harness/build.go | addAlias | func addAlias(aliases map[string]string, importPath, pkgName string) {
alias, ok := aliases[importPath]
if ok {
return
}
alias = makePackageAlias(aliases, pkgName)
aliases[importPath] = alias
} | go | func addAlias(aliases map[string]string, importPath, pkgName string) {
alias, ok := aliases[importPath]
if ok {
return
}
alias = makePackageAlias(aliases, pkgName)
aliases[importPath] = alias
} | [
"func",
"addAlias",
"(",
"aliases",
"map",
"[",
"string",
"]",
"string",
",",
"importPath",
",",
"pkgName",
"string",
")",
"{",
"alias",
",",
"ok",
":=",
"aliases",
"[",
"importPath",
"]",
"\n",
"if",
"ok",
"{",
"return",
"\n",
"}",
"\n",
"alias",
"=... | // Adds an alias to the map of alias names | [
"Adds",
"an",
"alias",
"to",
"the",
"map",
"of",
"alias",
"names"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/build.go#L347-L354 |
17,981 | revel/cmd | harness/build.go | makePackageAlias | func makePackageAlias(aliases map[string]string, pkgName string) string {
i := 0
alias := pkgName
for containsValue(aliases, alias) || alias == "revel" {
alias = fmt.Sprintf("%s%d", pkgName, i)
i++
}
return alias
} | go | func makePackageAlias(aliases map[string]string, pkgName string) string {
i := 0
alias := pkgName
for containsValue(aliases, alias) || alias == "revel" {
alias = fmt.Sprintf("%s%d", pkgName, i)
i++
}
return alias
} | [
"func",
"makePackageAlias",
"(",
"aliases",
"map",
"[",
"string",
"]",
"string",
",",
"pkgName",
"string",
")",
"string",
"{",
"i",
":=",
"0",
"\n",
"alias",
":=",
"pkgName",
"\n",
"for",
"containsValue",
"(",
"aliases",
",",
"alias",
")",
"||",
"alias",... | // Generates a package alias | [
"Generates",
"a",
"package",
"alias"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/build.go#L357-L365 |
17,982 | revel/cmd | harness/build.go | containsValue | func containsValue(m map[string]string, val string) bool {
for _, v := range m {
if v == val {
return true
}
}
return false
} | go | func containsValue(m map[string]string, val string) bool {
for _, v := range m {
if v == val {
return true
}
}
return false
} | [
"func",
"containsValue",
"(",
"m",
"map",
"[",
"string",
"]",
"string",
",",
"val",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"m",
"{",
"if",
"v",
"==",
"val",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
... | // Returns true if this value is in the map | [
"Returns",
"true",
"if",
"this",
"value",
"is",
"in",
"the",
"map"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/build.go#L368-L375 |
17,983 | revel/cmd | harness/build.go | newCompileError | func newCompileError(paths *model.RevelContainer, output []byte) *utils.Error {
errorMatch := regexp.MustCompile(`(?m)^([^:#]+):(\d+):(\d+:)? (.*)$`).
FindSubmatch(output)
if errorMatch == nil {
errorMatch = regexp.MustCompile(`(?m)^(.*?):(\d+):\s(.*?)$`).FindSubmatch(output)
if errorMatch == nil {
utils.Lo... | go | func newCompileError(paths *model.RevelContainer, output []byte) *utils.Error {
errorMatch := regexp.MustCompile(`(?m)^([^:#]+):(\d+):(\d+:)? (.*)$`).
FindSubmatch(output)
if errorMatch == nil {
errorMatch = regexp.MustCompile(`(?m)^(.*?):(\d+):\s(.*?)$`).FindSubmatch(output)
if errorMatch == nil {
utils.Lo... | [
"func",
"newCompileError",
"(",
"paths",
"*",
"model",
".",
"RevelContainer",
",",
"output",
"[",
"]",
"byte",
")",
"*",
"utils",
".",
"Error",
"{",
"errorMatch",
":=",
"regexp",
".",
"MustCompile",
"(",
"`(?m)^([^:#]+):(\\d+):(\\d+:)? (.*)$`",
")",
".",
"Find... | // Parse the output of the "go build" command.
// Return a detailed Error. | [
"Parse",
"the",
"output",
"of",
"the",
"go",
"build",
"command",
".",
"Return",
"a",
"detailed",
"Error",
"."
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/harness/build.go#L379-L445 |
17,984 | revel/cmd | utils/error.go | NewError | func NewError(source, title,path,description string) *Error {
return &Error {
SourceType:source,
Title:title,
Path:path,
Description:description,
}
} | go | func NewError(source, title,path,description string) *Error {
return &Error {
SourceType:source,
Title:title,
Path:path,
Description:description,
}
} | [
"func",
"NewError",
"(",
"source",
",",
"title",
",",
"path",
",",
"description",
"string",
")",
"*",
"Error",
"{",
"return",
"&",
"Error",
"{",
"SourceType",
":",
"source",
",",
"Title",
":",
"title",
",",
"Path",
":",
"path",
",",
"Description",
":",... | // Return a new error object | [
"Return",
"a",
"new",
"error",
"object"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/utils/error.go#L27-L34 |
17,985 | revel/cmd | parser/imports.go | addImports | func addImports(imports map[string]string, decl ast.Decl, srcDir string) {
genDecl, ok := decl.(*ast.GenDecl)
if !ok {
return
}
if genDecl.Tok != token.IMPORT {
return
}
for _, spec := range genDecl.Specs {
importSpec := spec.(*ast.ImportSpec)
var pkgAlias string
if importSpec.Name != nil {
pkgAlia... | go | func addImports(imports map[string]string, decl ast.Decl, srcDir string) {
genDecl, ok := decl.(*ast.GenDecl)
if !ok {
return
}
if genDecl.Tok != token.IMPORT {
return
}
for _, spec := range genDecl.Specs {
importSpec := spec.(*ast.ImportSpec)
var pkgAlias string
if importSpec.Name != nil {
pkgAlia... | [
"func",
"addImports",
"(",
"imports",
"map",
"[",
"string",
"]",
"string",
",",
"decl",
"ast",
".",
"Decl",
",",
"srcDir",
"string",
")",
"{",
"genDecl",
",",
"ok",
":=",
"decl",
".",
"(",
"*",
"ast",
".",
"GenDecl",
")",
"\n",
"if",
"!",
"ok",
"... | // Add imports to the map from the source dir | [
"Add",
"imports",
"to",
"the",
"map",
"from",
"the",
"source",
"dir"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/parser/imports.go#L13-L59 |
17,986 | revel/cmd | parser/imports.go | importPathFromPath | func importPathFromPath(root, basePath string) string {
vendorTest := filepath.Join(basePath, "vendor")
if len(root) > len(vendorTest) && root[:len(vendorTest)] == vendorTest {
return filepath.ToSlash(root[len(vendorTest)+1:])
}
for _, gopath := range filepath.SplitList(build.Default.GOPATH) {
srcPath := filepa... | go | func importPathFromPath(root, basePath string) string {
vendorTest := filepath.Join(basePath, "vendor")
if len(root) > len(vendorTest) && root[:len(vendorTest)] == vendorTest {
return filepath.ToSlash(root[len(vendorTest)+1:])
}
for _, gopath := range filepath.SplitList(build.Default.GOPATH) {
srcPath := filepa... | [
"func",
"importPathFromPath",
"(",
"root",
",",
"basePath",
"string",
")",
"string",
"{",
"vendorTest",
":=",
"filepath",
".",
"Join",
"(",
"basePath",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"root",
")",
">",
"len",
"(",
"vendorTest",
")",
"&&",... | // Returns a valid import string from the path
// using the build.Defaul.GOPATH to determine the root | [
"Returns",
"a",
"valid",
"import",
"string",
"from",
"the",
"path",
"using",
"the",
"build",
".",
"Defaul",
".",
"GOPATH",
"to",
"determine",
"the",
"root"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/parser/imports.go#L63-L83 |
17,987 | revel/cmd | model/source_info.go | ControllerSpecs | func (s *SourceInfo) ControllerSpecs() []*TypeInfo {
if s.controllerSpecs == nil {
s.controllerSpecs = s.TypesThatEmbed(RevelImportPath+".Controller", "controllers")
}
return s.controllerSpecs
} | go | func (s *SourceInfo) ControllerSpecs() []*TypeInfo {
if s.controllerSpecs == nil {
s.controllerSpecs = s.TypesThatEmbed(RevelImportPath+".Controller", "controllers")
}
return s.controllerSpecs
} | [
"func",
"(",
"s",
"*",
"SourceInfo",
")",
"ControllerSpecs",
"(",
")",
"[",
"]",
"*",
"TypeInfo",
"{",
"if",
"s",
".",
"controllerSpecs",
"==",
"nil",
"{",
"s",
".",
"controllerSpecs",
"=",
"s",
".",
"TypesThatEmbed",
"(",
"RevelImportPath",
"+",
"\"",
... | // ControllerSpecs returns the all the controllers that embeds
// `revel.Controller` | [
"ControllerSpecs",
"returns",
"the",
"all",
"the",
"controllers",
"that",
"embeds",
"revel",
".",
"Controller"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/source_info.go#L111-L116 |
17,988 | revel/cmd | revel/revel.go | ParseArgs | func ParseArgs(c *model.CommandConfig, parser *flags.Parser, args []string) (err error) {
var extraArgs []string
if ini := flag.String("ini", "none", ""); *ini != "none" {
if err = flags.NewIniParser(parser).ParseFile(*ini); err != nil {
return
}
} else {
if extraArgs, err = parser.ParseArgs(args); err != n... | go | func ParseArgs(c *model.CommandConfig, parser *flags.Parser, args []string) (err error) {
var extraArgs []string
if ini := flag.String("ini", "none", ""); *ini != "none" {
if err = flags.NewIniParser(parser).ParseFile(*ini); err != nil {
return
}
} else {
if extraArgs, err = parser.ParseArgs(args); err != n... | [
"func",
"ParseArgs",
"(",
"c",
"*",
"model",
".",
"CommandConfig",
",",
"parser",
"*",
"flags",
".",
"Parser",
",",
"args",
"[",
"]",
"string",
")",
"(",
"err",
"error",
")",
"{",
"var",
"extraArgs",
"[",
"]",
"string",
"\n",
"if",
"ini",
":=",
"fl... | // Parse the arguments passed into the model.CommandConfig | [
"Parse",
"the",
"arguments",
"passed",
"into",
"the",
"model",
".",
"CommandConfig"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/revel.go#L116-L155 |
17,989 | revel/cmd | utils/command.go | CmdInit | func CmdInit(c *exec.Cmd, basePath string) {
c.Dir = basePath
// Dep does not like paths that are not real, convert all paths in go to real paths
realPath := &bytes.Buffer{}
for _, p := range filepath.SplitList(build.Default.GOPATH) {
rp,_ := filepath.EvalSymlinks(p)
if realPath.Len() > 0 {
realPath.WriteStr... | go | func CmdInit(c *exec.Cmd, basePath string) {
c.Dir = basePath
// Dep does not like paths that are not real, convert all paths in go to real paths
realPath := &bytes.Buffer{}
for _, p := range filepath.SplitList(build.Default.GOPATH) {
rp,_ := filepath.EvalSymlinks(p)
if realPath.Len() > 0 {
realPath.WriteStr... | [
"func",
"CmdInit",
"(",
"c",
"*",
"exec",
".",
"Cmd",
",",
"basePath",
"string",
")",
"{",
"c",
".",
"Dir",
"=",
"basePath",
"\n",
"// Dep does not like paths that are not real, convert all paths in go to real paths",
"realPath",
":=",
"&",
"bytes",
".",
"Buffer",
... | // Initialize the command based on the GO environment | [
"Initialize",
"the",
"command",
"based",
"on",
"the",
"GO",
"environment"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/utils/command.go#L13-L34 |
17,990 | revel/cmd | revel/package.go | packageApp | func packageApp(c *model.CommandConfig) (err error) {
// Determine the run mode.
mode := DefaultRunMode
if len(c.Package.Mode) >= 0 {
mode = c.Package.Mode
}
appImportPath := c.ImportPath
revel_paths, err := model.NewRevelPaths(mode, appImportPath, "", model.NewWrappedRevelCallback(nil, c.PackageResolver))
i... | go | func packageApp(c *model.CommandConfig) (err error) {
// Determine the run mode.
mode := DefaultRunMode
if len(c.Package.Mode) >= 0 {
mode = c.Package.Mode
}
appImportPath := c.ImportPath
revel_paths, err := model.NewRevelPaths(mode, appImportPath, "", model.NewWrappedRevelCallback(nil, c.PackageResolver))
i... | [
"func",
"packageApp",
"(",
"c",
"*",
"model",
".",
"CommandConfig",
")",
"(",
"err",
"error",
")",
"{",
"// Determine the run mode.",
"mode",
":=",
"DefaultRunMode",
"\n",
"if",
"len",
"(",
"c",
".",
"Package",
".",
"Mode",
")",
">=",
"0",
"{",
"mode",
... | // Called to package the app | [
"Called",
"to",
"package",
"the",
"app"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/package.go#L52-L100 |
17,991 | revel/cmd | model/type_expr.go | NewTypeExprFromData | func NewTypeExprFromData(expr, pkgName string, pkgIndex int, valid bool) TypeExpr {
return TypeExpr{expr, pkgName, pkgIndex, valid}
} | go | func NewTypeExprFromData(expr, pkgName string, pkgIndex int, valid bool) TypeExpr {
return TypeExpr{expr, pkgName, pkgIndex, valid}
} | [
"func",
"NewTypeExprFromData",
"(",
"expr",
",",
"pkgName",
"string",
",",
"pkgIndex",
"int",
",",
"valid",
"bool",
")",
"TypeExpr",
"{",
"return",
"TypeExpr",
"{",
"expr",
",",
"pkgName",
",",
"pkgIndex",
",",
"valid",
"}",
"\n",
"}"
] | // Returns a new type from the data | [
"Returns",
"a",
"new",
"type",
"from",
"the",
"data"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/type_expr.go#L17-L19 |
17,992 | revel/cmd | model/type_expr.go | NewTypeExprFromAst | func NewTypeExprFromAst(pkgName string, expr ast.Expr) TypeExpr {
error := ""
switch t := expr.(type) {
case *ast.Ident:
if IsBuiltinType(t.Name) {
pkgName = ""
}
return TypeExpr{t.Name, pkgName, 0, true}
case *ast.SelectorExpr:
e := NewTypeExprFromAst(pkgName, t.X)
return NewTypeExprFromData(t.Sel.Nam... | go | func NewTypeExprFromAst(pkgName string, expr ast.Expr) TypeExpr {
error := ""
switch t := expr.(type) {
case *ast.Ident:
if IsBuiltinType(t.Name) {
pkgName = ""
}
return TypeExpr{t.Name, pkgName, 0, true}
case *ast.SelectorExpr:
e := NewTypeExprFromAst(pkgName, t.X)
return NewTypeExprFromData(t.Sel.Nam... | [
"func",
"NewTypeExprFromAst",
"(",
"pkgName",
"string",
",",
"expr",
"ast",
".",
"Expr",
")",
"TypeExpr",
"{",
"error",
":=",
"\"",
"\"",
"\n",
"switch",
"t",
":=",
"expr",
".",
"(",
"type",
")",
"{",
"case",
"*",
"ast",
".",
"Ident",
":",
"if",
"I... | // NewTypeExpr returns the syntactic expression for referencing this type in Go. | [
"NewTypeExpr",
"returns",
"the",
"syntactic",
"expression",
"for",
"referencing",
"this",
"type",
"in",
"Go",
"."
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/type_expr.go#L22-L53 |
17,993 | revel/cmd | model/type_expr.go | TypeName | func (e TypeExpr) TypeName(pkgOverride string) string {
pkgName := FirstNonEmpty(pkgOverride, e.PkgName)
if pkgName == "" {
return e.Expr
}
return e.Expr[:e.pkgIndex] + pkgName + "." + e.Expr[e.pkgIndex:]
} | go | func (e TypeExpr) TypeName(pkgOverride string) string {
pkgName := FirstNonEmpty(pkgOverride, e.PkgName)
if pkgName == "" {
return e.Expr
}
return e.Expr[:e.pkgIndex] + pkgName + "." + e.Expr[e.pkgIndex:]
} | [
"func",
"(",
"e",
"TypeExpr",
")",
"TypeName",
"(",
"pkgOverride",
"string",
")",
"string",
"{",
"pkgName",
":=",
"FirstNonEmpty",
"(",
"pkgOverride",
",",
"e",
".",
"PkgName",
")",
"\n",
"if",
"pkgName",
"==",
"\"",
"\"",
"{",
"return",
"e",
".",
"Exp... | // TypeName returns the fully-qualified type name for this expression.
// The caller may optionally specify a package name to override the default. | [
"TypeName",
"returns",
"the",
"fully",
"-",
"qualified",
"type",
"name",
"for",
"this",
"expression",
".",
"The",
"caller",
"may",
"optionally",
"specify",
"a",
"package",
"name",
"to",
"override",
"the",
"default",
"."
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/type_expr.go#L57-L63 |
17,994 | revel/cmd | model/command_config.go | InitGoPaths | func (c *CommandConfig) InitGoPaths() {
utils.Logger.Info("InitGoPaths")
// lookup go path
c.GoPath = build.Default.GOPATH
if c.GoPath == "" {
utils.Logger.Fatal("Abort: GOPATH environment variable is not set. " +
"Please refer to http://golang.org/doc/code.html to configure your Go environment.")
}
// chec... | go | func (c *CommandConfig) InitGoPaths() {
utils.Logger.Info("InitGoPaths")
// lookup go path
c.GoPath = build.Default.GOPATH
if c.GoPath == "" {
utils.Logger.Fatal("Abort: GOPATH environment variable is not set. " +
"Please refer to http://golang.org/doc/code.html to configure your Go environment.")
}
// chec... | [
"func",
"(",
"c",
"*",
"CommandConfig",
")",
"InitGoPaths",
"(",
")",
"{",
"utils",
".",
"Logger",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"// lookup go path",
"c",
".",
"GoPath",
"=",
"build",
".",
"Default",
".",
"GOPATH",
"\n",
"if",
"c",
".",
... | // lookup and set Go related variables | [
"lookup",
"and",
"set",
"Go",
"related",
"variables"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/command_config.go#L240-L296 |
17,995 | revel/cmd | model/command_config.go | SetVersions | func (c *CommandConfig) SetVersions() (err error) {
c.CommandVersion, _ = ParseVersion(cmd.Version)
_, revelPath, err := utils.FindSrcPaths(c.ImportPath, RevelImportPath, c.PackageResolver)
if err == nil {
utils.Logger.Info("Fullpath to revel", "dir", revelPath)
fset := token.NewFileSet() // positions are relati... | go | func (c *CommandConfig) SetVersions() (err error) {
c.CommandVersion, _ = ParseVersion(cmd.Version)
_, revelPath, err := utils.FindSrcPaths(c.ImportPath, RevelImportPath, c.PackageResolver)
if err == nil {
utils.Logger.Info("Fullpath to revel", "dir", revelPath)
fset := token.NewFileSet() // positions are relati... | [
"func",
"(",
"c",
"*",
"CommandConfig",
")",
"SetVersions",
"(",
")",
"(",
"err",
"error",
")",
"{",
"c",
".",
"CommandVersion",
",",
"_",
"=",
"ParseVersion",
"(",
"cmd",
".",
"Version",
")",
"\n",
"_",
",",
"revelPath",
",",
"err",
":=",
"utils",
... | // Sets the versions on the command config | [
"Sets",
"the",
"versions",
"on",
"the",
"command",
"config"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/model/command_config.go#L299-L341 |
17,996 | revel/cmd | revel/run.go | runIsImportPath | func runIsImportPath(pathToCheck string) bool {
if _, err := build.Import(pathToCheck, "", build.FindOnly);err==nil {
return true
}
return filepath.IsAbs(pathToCheck)
} | go | func runIsImportPath(pathToCheck string) bool {
if _, err := build.Import(pathToCheck, "", build.FindOnly);err==nil {
return true
}
return filepath.IsAbs(pathToCheck)
} | [
"func",
"runIsImportPath",
"(",
"pathToCheck",
"string",
")",
"bool",
"{",
"if",
"_",
",",
"err",
":=",
"build",
".",
"Import",
"(",
"pathToCheck",
",",
"\"",
"\"",
",",
"build",
".",
"FindOnly",
")",
";",
"err",
"==",
"nil",
"{",
"return",
"true",
"... | // Returns true if this is an absolute path or a relative gopath | [
"Returns",
"true",
"if",
"this",
"is",
"an",
"absolute",
"path",
"or",
"a",
"relative",
"gopath"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/run.go#L116-L121 |
17,997 | revel/cmd | revel/run.go | runApp | func runApp(c *model.CommandConfig) (err error) {
if c.Run.Mode == "" {
c.Run.Mode = "dev"
}
revel_path, err := model.NewRevelPaths(c.Run.Mode, c.ImportPath, "", model.NewWrappedRevelCallback(nil, c.PackageResolver))
if err != nil {
return utils.NewBuildIfError(err, "Revel paths")
}
if c.Run.Port > -1 {
re... | go | func runApp(c *model.CommandConfig) (err error) {
if c.Run.Mode == "" {
c.Run.Mode = "dev"
}
revel_path, err := model.NewRevelPaths(c.Run.Mode, c.ImportPath, "", model.NewWrappedRevelCallback(nil, c.PackageResolver))
if err != nil {
return utils.NewBuildIfError(err, "Revel paths")
}
if c.Run.Port > -1 {
re... | [
"func",
"runApp",
"(",
"c",
"*",
"model",
".",
"CommandConfig",
")",
"(",
"err",
"error",
")",
"{",
"if",
"c",
".",
"Run",
".",
"Mode",
"==",
"\"",
"\"",
"{",
"c",
".",
"Run",
".",
"Mode",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"revel_path",
",",
... | // Called to run the app | [
"Called",
"to",
"run",
"the",
"app"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/revel/run.go#L124-L166 |
17,998 | revel/cmd | utils/file.go | CopyFile | func CopyFile(destFilename, srcFilename string) (err error) {
destFile, err := os.Create(destFilename)
if err != nil {
return NewBuildIfError(err, "Failed to create file", "file", destFilename)
}
srcFile, err := os.Open(srcFilename)
if err != nil {
return NewBuildIfError(err, "Failed to open file", "file", s... | go | func CopyFile(destFilename, srcFilename string) (err error) {
destFile, err := os.Create(destFilename)
if err != nil {
return NewBuildIfError(err, "Failed to create file", "file", destFilename)
}
srcFile, err := os.Open(srcFilename)
if err != nil {
return NewBuildIfError(err, "Failed to open file", "file", s... | [
"func",
"CopyFile",
"(",
"destFilename",
",",
"srcFilename",
"string",
")",
"(",
"err",
"error",
")",
"{",
"destFile",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"destFilename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"NewBuildIfError",
"(",... | // Copy file returns error | [
"Copy",
"file",
"returns",
"error"
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/utils/file.go#L43-L71 |
17,999 | revel/cmd | utils/file.go | GenerateTemplate | func GenerateTemplate(filename, templateSource string, args map[string]interface{}) (err error) {
tmpl := template.Must(template.New("").Parse(templateSource))
var b bytes.Buffer
if err = tmpl.Execute(&b, args); err != nil {
return NewBuildIfError(err, "ExecuteTemplate: Execute failed")
}
sourceCode := b.String... | go | func GenerateTemplate(filename, templateSource string, args map[string]interface{}) (err error) {
tmpl := template.Must(template.New("").Parse(templateSource))
var b bytes.Buffer
if err = tmpl.Execute(&b, args); err != nil {
return NewBuildIfError(err, "ExecuteTemplate: Execute failed")
}
sourceCode := b.String... | [
"func",
"GenerateTemplate",
"(",
"filename",
",",
"templateSource",
"string",
",",
"args",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"tmpl",
":=",
"template",
".",
"Must",
"(",
"template",
".",
"New",
"(",
"\... | // GenerateTemplate renders the given template to produce source code, which it writes
// to the given file. | [
"GenerateTemplate",
"renders",
"the",
"given",
"template",
"to",
"produce",
"source",
"code",
"which",
"it",
"writes",
"to",
"the",
"given",
"file",
"."
] | 149f9f992be9b0957fb1ffeda43c14a123ceb43a | https://github.com/revel/cmd/blob/149f9f992be9b0957fb1ffeda43c14a123ceb43a/utils/file.go#L75-L106 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.