repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
naoina/genmai
genmai.go
Join
func (db *DB) Join(table interface{}) *JoinCondition { return (&JoinCondition{db: db}).Join(table) }
go
func (db *DB) Join(table interface{}) *JoinCondition { return (&JoinCondition{db: db}).Join(table) }
[ "func", "(", "db", "*", "DB", ")", "Join", "(", "table", "interface", "{", "}", ")", "*", "JoinCondition", "{", "return", "(", "&", "JoinCondition", "{", "db", ":", "db", "}", ")", ".", "Join", "(", "table", ")", "\n", "}" ]
// Join returns a new JoinCondition of "JOIN" clause.
[ "Join", "returns", "a", "new", "JoinCondition", "of", "JOIN", "clause", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L162-L164
test
naoina/genmai
genmai.go
Count
func (db *DB) Count(column ...interface{}) *Function { switch len(column) { case 0, 1: // do nothing. default: panic(fmt.Errorf("Count: a number of argument must be 0 or 1, got %v", len(column))) } return &Function{ Name: "COUNT", Args: column, } }
go
func (db *DB) Count(column ...interface{}) *Function { switch len(column) { case 0, 1: // do nothing. default: panic(fmt.Errorf("Count: a number of argument must be 0 or 1, got %v", len(column))) } return &Function{ Name: "COUNT", Args: column, } }
[ "func", "(", "db", "*", "DB", ")", "Count", "(", "column", "...", "interface", "{", "}", ")", "*", "Function", "{", "switch", "len", "(", "column", ")", "{", "case", "0", ",", "1", ":", "default", ":", "panic", "(", "fmt", ".", "Errorf", "(", "...
// Count returns "COUNT" function.
[ "Count", "returns", "COUNT", "function", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L171-L182
test
naoina/genmai
genmai.go
Update
func (db *DB) Update(obj interface{}) (affected int64, err error) { rv, rtype, tableName, err := db.tableValueOf("Update", obj) if err != nil { return -1, err } if hook, ok := obj.(BeforeUpdater); ok { if err := hook.BeforeUpdate(); err != nil { return -1, err } } fieldIndexes := db.collectFieldIndexes(r...
go
func (db *DB) Update(obj interface{}) (affected int64, err error) { rv, rtype, tableName, err := db.tableValueOf("Update", obj) if err != nil { return -1, err } if hook, ok := obj.(BeforeUpdater); ok { if err := hook.BeforeUpdate(); err != nil { return -1, err } } fieldIndexes := db.collectFieldIndexes(r...
[ "func", "(", "db", "*", "DB", ")", "Update", "(", "obj", "interface", "{", "}", ")", "(", "affected", "int64", ",", "err", "error", ")", "{", "rv", ",", "rtype", ",", "tableName", ",", "err", ":=", "db", ".", "tableValueOf", "(", "\"Update\"", ",",...
// Update updates the one record. // The obj must be struct, and must have field that specified "pk" struct tag. // Update will try to update record which searched by value of primary key in obj. // Update returns the number of rows affected by an update.
[ "Update", "updates", "the", "one", "record", ".", "The", "obj", "must", "be", "struct", "and", "must", "have", "field", "that", "specified", "pk", "struct", "tag", ".", "Update", "will", "try", "to", "update", "record", "which", "searched", "by", "value", ...
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L298-L342
test
naoina/genmai
genmai.go
Delete
func (db *DB) Delete(obj interface{}) (affected int64, err error) { objs, rtype, tableName, err := db.tableObjs("Delete", obj) if err != nil { return -1, err } if len(objs) < 1 { return 0, nil } for _, obj := range objs { if hook, ok := obj.(BeforeDeleter); ok { if err := hook.BeforeDelete(); err != nil ...
go
func (db *DB) Delete(obj interface{}) (affected int64, err error) { objs, rtype, tableName, err := db.tableObjs("Delete", obj) if err != nil { return -1, err } if len(objs) < 1 { return 0, nil } for _, obj := range objs { if hook, ok := obj.(BeforeDeleter); ok { if err := hook.BeforeDelete(); err != nil ...
[ "func", "(", "db", "*", "DB", ")", "Delete", "(", "obj", "interface", "{", "}", ")", "(", "affected", "int64", ",", "err", "error", ")", "{", "objs", ",", "rtype", ",", "tableName", ",", "err", ":=", "db", ".", "tableObjs", "(", "\"Delete\"", ",", ...
// Delete deletes the records from database table. // The obj must be pointer to struct or slice of struct, and must have field that specified "pk" struct tag. // Delete will try to delete record which searched by value of primary key in obj. // Delete returns teh number of rows affected by a delete.
[ "Delete", "deletes", "the", "records", "from", "database", "table", ".", "The", "obj", "must", "be", "pointer", "to", "struct", "or", "slice", "of", "struct", "and", "must", "have", "field", "that", "specified", "pk", "struct", "tag", ".", "Delete", "will"...
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L432-L482
test
naoina/genmai
genmai.go
Begin
func (db *DB) Begin() error { tx, err := db.db.Begin() if err != nil { return err } db.m.Lock() defer db.m.Unlock() db.tx = tx return nil }
go
func (db *DB) Begin() error { tx, err := db.db.Begin() if err != nil { return err } db.m.Lock() defer db.m.Unlock() db.tx = tx return nil }
[ "func", "(", "db", "*", "DB", ")", "Begin", "(", ")", "error", "{", "tx", ",", "err", ":=", "db", ".", "db", ".", "Begin", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "db", ".", "m", ".", "Lock", "(", ...
// Begin starts a transaction.
[ "Begin", "starts", "a", "transaction", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L485-L494
test
naoina/genmai
genmai.go
Commit
func (db *DB) Commit() error { db.m.Lock() defer db.m.Unlock() if db.tx == nil { return ErrTxDone } err := db.tx.Commit() db.tx = nil return err }
go
func (db *DB) Commit() error { db.m.Lock() defer db.m.Unlock() if db.tx == nil { return ErrTxDone } err := db.tx.Commit() db.tx = nil return err }
[ "func", "(", "db", "*", "DB", ")", "Commit", "(", ")", "error", "{", "db", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "db", ".", "m", ".", "Unlock", "(", ")", "\n", "if", "db", ".", "tx", "==", "nil", "{", "return", "ErrTxDone", "\n", ...
// Commit commits the transaction. // If Begin still not called, or Commit or Rollback already called, Commit returns ErrTxDone.
[ "Commit", "commits", "the", "transaction", ".", "If", "Begin", "still", "not", "called", "or", "Commit", "or", "Rollback", "already", "called", "Commit", "returns", "ErrTxDone", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L498-L507
test
naoina/genmai
genmai.go
Quote
func (db *DB) Quote(s string) string { return db.dialect.Quote(s) }
go
func (db *DB) Quote(s string) string { return db.dialect.Quote(s) }
[ "func", "(", "db", "*", "DB", ")", "Quote", "(", "s", "string", ")", "string", "{", "return", "db", ".", "dialect", ".", "Quote", "(", "s", ")", "\n", "}" ]
// Quote returns a quoted s. // It is for a column name, not a value.
[ "Quote", "returns", "a", "quoted", "s", ".", "It", "is", "for", "a", "column", "name", "not", "a", "value", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L544-L546
test
naoina/genmai
genmai.go
SetLogOutput
func (db *DB) SetLogOutput(w io.Writer) { if w == nil { db.logger = defaultLogger } else { db.logger = &templateLogger{w: w, t: defaultLoggerTemplate} } }
go
func (db *DB) SetLogOutput(w io.Writer) { if w == nil { db.logger = defaultLogger } else { db.logger = &templateLogger{w: w, t: defaultLoggerTemplate} } }
[ "func", "(", "db", "*", "DB", ")", "SetLogOutput", "(", "w", "io", ".", "Writer", ")", "{", "if", "w", "==", "nil", "{", "db", ".", "logger", "=", "defaultLogger", "\n", "}", "else", "{", "db", ".", "logger", "=", "&", "templateLogger", "{", "w",...
// SetLogOutput sets output destination for logging. // If w is nil, it unsets output of logging.
[ "SetLogOutput", "sets", "output", "destination", "for", "logging", ".", "If", "w", "is", "nil", "it", "unsets", "output", "of", "logging", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L555-L561
test
naoina/genmai
genmai.go
selectToSlice
func (db *DB) selectToSlice(rows *sql.Rows, t reflect.Type) (reflect.Value, error) { columns, err := rows.Columns() if err != nil { return reflect.Value{}, err } t = t.Elem() ptrN := 0 for ; t.Kind() == reflect.Ptr; ptrN++ { t = t.Elem() } fieldIndexes := make([][]int, len(columns)) for i, column := range ...
go
func (db *DB) selectToSlice(rows *sql.Rows, t reflect.Type) (reflect.Value, error) { columns, err := rows.Columns() if err != nil { return reflect.Value{}, err } t = t.Elem() ptrN := 0 for ; t.Kind() == reflect.Ptr; ptrN++ { t = t.Elem() } fieldIndexes := make([][]int, len(columns)) for i, column := range ...
[ "func", "(", "db", "*", "DB", ")", "selectToSlice", "(", "rows", "*", "sql", ".", "Rows", ",", "t", "reflect", ".", "Type", ")", "(", "reflect", ".", "Value", ",", "error", ")", "{", "columns", ",", "err", ":=", "rows", ".", "Columns", "(", ")", ...
// selectToSlice returns a slice value fetched from rows.
[ "selectToSlice", "returns", "a", "slice", "value", "fetched", "from", "rows", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L580-L625
test
naoina/genmai
genmai.go
selectToValue
func (db *DB) selectToValue(rows *sql.Rows, t reflect.Type) (reflect.Value, error) { ptrN := 0 for ; t.Kind() == reflect.Ptr; ptrN++ { t = t.Elem() } dest := reflect.New(t).Elem() if rows.Next() { if err := rows.Scan(dest.Addr().Interface()); err != nil { return reflect.Value{}, err } } for i := 0; i < ...
go
func (db *DB) selectToValue(rows *sql.Rows, t reflect.Type) (reflect.Value, error) { ptrN := 0 for ; t.Kind() == reflect.Ptr; ptrN++ { t = t.Elem() } dest := reflect.New(t).Elem() if rows.Next() { if err := rows.Scan(dest.Addr().Interface()); err != nil { return reflect.Value{}, err } } for i := 0; i < ...
[ "func", "(", "db", "*", "DB", ")", "selectToValue", "(", "rows", "*", "sql", ".", "Rows", ",", "t", "reflect", ".", "Type", ")", "(", "reflect", ".", "Value", ",", "error", ")", "{", "ptrN", ":=", "0", "\n", "for", ";", "t", ".", "Kind", "(", ...
// selectToValue returns a single value fetched from rows.
[ "selectToValue", "returns", "a", "single", "value", "fetched", "from", "rows", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L628-L643
test
naoina/genmai
genmai.go
fieldIndexByName
func (db *DB) fieldIndexByName(t reflect.Type, name string, index []int) []int { for i := 0; i < t.NumField(); i++ { field := t.Field(i) if candidate := db.columnFromTag(field); candidate == name { return append(index, i) } if field.Anonymous { if idx := db.fieldIndexByName(field.Type, name, append(index...
go
func (db *DB) fieldIndexByName(t reflect.Type, name string, index []int) []int { for i := 0; i < t.NumField(); i++ { field := t.Field(i) if candidate := db.columnFromTag(field); candidate == name { return append(index, i) } if field.Anonymous { if idx := db.fieldIndexByName(field.Type, name, append(index...
[ "func", "(", "db", "*", "DB", ")", "fieldIndexByName", "(", "t", "reflect", ".", "Type", ",", "name", "string", ",", "index", "[", "]", "int", ")", "[", "]", "int", "{", "for", "i", ":=", "0", ";", "i", "<", "t", ".", "NumField", "(", ")", ";...
// fieldIndexByName returns the nested field corresponding to the index sequence.
[ "fieldIndexByName", "returns", "the", "nested", "field", "corresponding", "to", "the", "index", "sequence", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L646-L659
test
naoina/genmai
genmai.go
columns
func (db *DB) columns(tableName string, columns []interface{}) string { if len(columns) == 0 { return ColumnName(db.dialect, tableName, "*") } names := make([]string, len(columns)) for i, col := range columns { switch c := col.(type) { case Raw: names[i] = fmt.Sprint(*c) case string: names[i] = Column...
go
func (db *DB) columns(tableName string, columns []interface{}) string { if len(columns) == 0 { return ColumnName(db.dialect, tableName, "*") } names := make([]string, len(columns)) for i, col := range columns { switch c := col.(type) { case Raw: names[i] = fmt.Sprint(*c) case string: names[i] = Column...
[ "func", "(", "db", "*", "DB", ")", "columns", "(", "tableName", "string", ",", "columns", "[", "]", "interface", "{", "}", ")", "string", "{", "if", "len", "(", "columns", ")", "==", "0", "{", "return", "ColumnName", "(", "db", ".", "dialect", ",",...
// columns returns the comma-separated column name with quoted.
[ "columns", "returns", "the", "comma", "-", "separated", "column", "name", "with", "quoted", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L708-L726
test
naoina/genmai
genmai.go
tagsFromField
func (db *DB) tagsFromField(field *reflect.StructField) (options []string) { if db.hasSkipTag(field) { return nil } for _, tag := range strings.Split(field.Tag.Get(dbTag), ",") { if t := strings.ToLower(strings.TrimSpace(tag)); t != "" { options = append(options, t) } } return options }
go
func (db *DB) tagsFromField(field *reflect.StructField) (options []string) { if db.hasSkipTag(field) { return nil } for _, tag := range strings.Split(field.Tag.Get(dbTag), ",") { if t := strings.ToLower(strings.TrimSpace(tag)); t != "" { options = append(options, t) } } return options }
[ "func", "(", "db", "*", "DB", ")", "tagsFromField", "(", "field", "*", "reflect", ".", "StructField", ")", "(", "options", "[", "]", "string", ")", "{", "if", "db", ".", "hasSkipTag", "(", "field", ")", "{", "return", "nil", "\n", "}", "\n", "for",...
// tagsFromField returns a slice of option strings.
[ "tagsFromField", "returns", "a", "slice", "of", "option", "strings", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L783-L793
test
naoina/genmai
genmai.go
hasSkipTag
func (db *DB) hasSkipTag(field *reflect.StructField) bool { if field.Tag.Get(dbTag) == skipTag { return true } return false }
go
func (db *DB) hasSkipTag(field *reflect.StructField) bool { if field.Tag.Get(dbTag) == skipTag { return true } return false }
[ "func", "(", "db", "*", "DB", ")", "hasSkipTag", "(", "field", "*", "reflect", ".", "StructField", ")", "bool", "{", "if", "field", ".", "Tag", ".", "Get", "(", "dbTag", ")", "==", "skipTag", "{", "return", "true", "\n", "}", "\n", "return", "false...
// hasSkipTag returns whether the struct field has the "-" tag.
[ "hasSkipTag", "returns", "whether", "the", "struct", "field", "has", "the", "-", "tag", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L796-L801
test
naoina/genmai
genmai.go
hasPKTag
func (db *DB) hasPKTag(field *reflect.StructField) bool { for _, tag := range db.tagsFromField(field) { if tag == "pk" { return true } } return false }
go
func (db *DB) hasPKTag(field *reflect.StructField) bool { for _, tag := range db.tagsFromField(field) { if tag == "pk" { return true } } return false }
[ "func", "(", "db", "*", "DB", ")", "hasPKTag", "(", "field", "*", "reflect", ".", "StructField", ")", "bool", "{", "for", "_", ",", "tag", ":=", "range", "db", ".", "tagsFromField", "(", "field", ")", "{", "if", "tag", "==", "\"pk\"", "{", "return"...
// hasPKTag returns whether the struct field has the "pk" tag.
[ "hasPKTag", "returns", "whether", "the", "struct", "field", "has", "the", "pk", "tag", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L804-L811
test
naoina/genmai
genmai.go
isAutoIncrementable
func (db *DB) isAutoIncrementable(field *reflect.StructField) bool { switch field.Type.Kind() { case reflect.Int, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64: return true } return false }
go
func (db *DB) isAutoIncrementable(field *reflect.StructField) bool { switch field.Type.Kind() { case reflect.Int, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64: return true } return false }
[ "func", "(", "db", "*", "DB", ")", "isAutoIncrementable", "(", "field", "*", "reflect", ".", "StructField", ")", "bool", "{", "switch", "field", ".", "Type", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Int", ",", "reflect", ".", "Int16", ","...
// isAutoIncrementable returns whether the struct field is integer.
[ "isAutoIncrementable", "returns", "whether", "the", "struct", "field", "is", "integer", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L814-L821
test
naoina/genmai
genmai.go
collectFieldIndexes
func (db *DB) collectFieldIndexes(typ reflect.Type, index []int) (indexes [][]int) { for i := 0; i < typ.NumField(); i++ { field := typ.Field(i) if IsUnexportedField(field) { continue } if !(db.hasSkipTag(&field) || (db.hasPKTag(&field) && db.isAutoIncrementable(&field))) { tmp := make([]int, len(index)+...
go
func (db *DB) collectFieldIndexes(typ reflect.Type, index []int) (indexes [][]int) { for i := 0; i < typ.NumField(); i++ { field := typ.Field(i) if IsUnexportedField(field) { continue } if !(db.hasSkipTag(&field) || (db.hasPKTag(&field) && db.isAutoIncrementable(&field))) { tmp := make([]int, len(index)+...
[ "func", "(", "db", "*", "DB", ")", "collectFieldIndexes", "(", "typ", "reflect", ".", "Type", ",", "index", "[", "]", "int", ")", "(", "indexes", "[", "]", "[", "]", "int", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "typ", ".", "NumField",...
// collectFieldIndexes returns the indexes of field which doesn't have skip tag and pk tag.
[ "collectFieldIndexes", "returns", "the", "indexes", "of", "field", "which", "doesn", "t", "have", "skip", "tag", "and", "pk", "tag", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L824-L842
test
naoina/genmai
genmai.go
findPKIndex
func (db *DB) findPKIndex(typ reflect.Type, index []int) []int { for i := 0; i < typ.NumField(); i++ { field := typ.Field(i) if IsUnexportedField(field) { continue } if field.Anonymous { if idx := db.findPKIndex(field.Type, append(index, i)); idx != nil { return append(index, idx...) } continue...
go
func (db *DB) findPKIndex(typ reflect.Type, index []int) []int { for i := 0; i < typ.NumField(); i++ { field := typ.Field(i) if IsUnexportedField(field) { continue } if field.Anonymous { if idx := db.findPKIndex(field.Type, append(index, i)); idx != nil { return append(index, idx...) } continue...
[ "func", "(", "db", "*", "DB", ")", "findPKIndex", "(", "typ", "reflect", ".", "Type", ",", "index", "[", "]", "int", ")", "[", "]", "int", "{", "for", "i", ":=", "0", ";", "i", "<", "typ", ".", "NumField", "(", ")", ";", "i", "++", "{", "fi...
// findPKIndex returns the nested field corresponding to the index sequence of field of primary key.
[ "findPKIndex", "returns", "the", "nested", "field", "corresponding", "to", "the", "index", "sequence", "of", "field", "of", "primary", "key", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L845-L862
test
naoina/genmai
genmai.go
sizeFromTag
func (db *DB) sizeFromTag(field *reflect.StructField) (size uint64, err error) { if s := field.Tag.Get(dbSizeTag); s != "" { size, err = strconv.ParseUint(s, 10, 64) } return size, err }
go
func (db *DB) sizeFromTag(field *reflect.StructField) (size uint64, err error) { if s := field.Tag.Get(dbSizeTag); s != "" { size, err = strconv.ParseUint(s, 10, 64) } return size, err }
[ "func", "(", "db", "*", "DB", ")", "sizeFromTag", "(", "field", "*", "reflect", ".", "StructField", ")", "(", "size", "uint64", ",", "err", "error", ")", "{", "if", "s", ":=", "field", ".", "Tag", ".", "Get", "(", "dbSizeTag", ")", ";", "s", "!="...
// sizeFromTag returns a size from tag. // If "size" tag specified to struct field, it will converted to uint64 and returns it. // If it doesn't specify, it returns 0. // If value of "size" tag cannot convert to uint64, it returns 0 and error.
[ "sizeFromTag", "returns", "a", "size", "from", "tag", ".", "If", "size", "tag", "specified", "to", "struct", "field", "it", "will", "converted", "to", "uint64", "and", "returns", "it", ".", "If", "it", "doesn", "t", "specify", "it", "returns", "0", ".", ...
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L868-L873
test
naoina/genmai
genmai.go
columnFromTag
func (db *DB) columnFromTag(field reflect.StructField) string { col := field.Tag.Get(dbColumnTag) if col == "" { return stringutil.ToSnakeCase(field.Name) } return col }
go
func (db *DB) columnFromTag(field reflect.StructField) string { col := field.Tag.Get(dbColumnTag) if col == "" { return stringutil.ToSnakeCase(field.Name) } return col }
[ "func", "(", "db", "*", "DB", ")", "columnFromTag", "(", "field", "reflect", ".", "StructField", ")", "string", "{", "col", ":=", "field", ".", "Tag", ".", "Get", "(", "dbColumnTag", ")", "\n", "if", "col", "==", "\"\"", "{", "return", "stringutil", ...
// columnFromTag returns the column name. // If "column" tag specified to struct field, returns it. // Otherwise, it returns snake-cased field name as column name.
[ "columnFromTag", "returns", "the", "column", "name", ".", "If", "column", "tag", "specified", "to", "struct", "field", "returns", "it", ".", "Otherwise", "it", "returns", "snake", "-", "cased", "field", "name", "as", "column", "name", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L885-L891
test
naoina/genmai
genmai.go
defaultFromTag
func (db *DB) defaultFromTag(field *reflect.StructField) (string, error) { def := field.Tag.Get(dbDefaultTag) if def == "" { return "", nil } switch field.Type.Kind() { case reflect.Bool: b, err := strconv.ParseBool(def) if err != nil { return "", err } return fmt.Sprintf("DEFAULT %v", db.dialect.Form...
go
func (db *DB) defaultFromTag(field *reflect.StructField) (string, error) { def := field.Tag.Get(dbDefaultTag) if def == "" { return "", nil } switch field.Type.Kind() { case reflect.Bool: b, err := strconv.ParseBool(def) if err != nil { return "", err } return fmt.Sprintf("DEFAULT %v", db.dialect.Form...
[ "func", "(", "db", "*", "DB", ")", "defaultFromTag", "(", "field", "*", "reflect", ".", "StructField", ")", "(", "string", ",", "error", ")", "{", "def", ":=", "field", ".", "Tag", ".", "Get", "(", "dbDefaultTag", ")", "\n", "if", "def", "==", "\"\...
// defaultFromTag returns a "DEFAULT ..." keyword. // If "default" tag specified to struct field, it use as the default value. // If it doesn't specify, it returns empty string.
[ "defaultFromTag", "returns", "a", "DEFAULT", "...", "keyword", ".", "If", "default", "tag", "specified", "to", "struct", "field", "it", "use", "as", "the", "default", "value", ".", "If", "it", "doesn", "t", "specify", "it", "returns", "empty", "string", "....
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L896-L910
test
naoina/genmai
genmai.go
Where
func (c *Condition) Where(cond interface{}, args ...interface{}) *Condition { return c.appendQueryByCondOrExpr("Where", 0, Where, cond, args...) }
go
func (c *Condition) Where(cond interface{}, args ...interface{}) *Condition { return c.appendQueryByCondOrExpr("Where", 0, Where, cond, args...) }
[ "func", "(", "c", "*", "Condition", ")", "Where", "(", "cond", "interface", "{", "}", ",", "args", "...", "interface", "{", "}", ")", "*", "Condition", "{", "return", "c", ".", "appendQueryByCondOrExpr", "(", "\"Where\"", ",", "0", ",", "Where", ",", ...
// Where adds "WHERE" clause to the Condition and returns it for method chain.
[ "Where", "adds", "WHERE", "clause", "to", "the", "Condition", "and", "returns", "it", "for", "method", "chain", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L1134-L1136
test
naoina/genmai
genmai.go
And
func (c *Condition) And(cond interface{}, args ...interface{}) *Condition { return c.appendQueryByCondOrExpr("And", 100, And, cond, args...) }
go
func (c *Condition) And(cond interface{}, args ...interface{}) *Condition { return c.appendQueryByCondOrExpr("And", 100, And, cond, args...) }
[ "func", "(", "c", "*", "Condition", ")", "And", "(", "cond", "interface", "{", "}", ",", "args", "...", "interface", "{", "}", ")", "*", "Condition", "{", "return", "c", ".", "appendQueryByCondOrExpr", "(", "\"And\"", ",", "100", ",", "And", ",", "co...
// And adds "AND" operator to the Condition and returns it for method chain.
[ "And", "adds", "AND", "operator", "to", "the", "Condition", "and", "returns", "it", "for", "method", "chain", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L1139-L1141
test
naoina/genmai
genmai.go
Or
func (c *Condition) Or(cond interface{}, args ...interface{}) *Condition { return c.appendQueryByCondOrExpr("Or", 100, Or, cond, args...) }
go
func (c *Condition) Or(cond interface{}, args ...interface{}) *Condition { return c.appendQueryByCondOrExpr("Or", 100, Or, cond, args...) }
[ "func", "(", "c", "*", "Condition", ")", "Or", "(", "cond", "interface", "{", "}", ",", "args", "...", "interface", "{", "}", ")", "*", "Condition", "{", "return", "c", ".", "appendQueryByCondOrExpr", "(", "\"Or\"", ",", "100", ",", "Or", ",", "cond"...
// Or adds "OR" operator to the Condition and returns it for method chain.
[ "Or", "adds", "OR", "operator", "to", "the", "Condition", "and", "returns", "it", "for", "method", "chain", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L1144-L1146
test
naoina/genmai
genmai.go
Like
func (c *Condition) Like(arg string) *Condition { return c.appendQuery(100, Like, arg) }
go
func (c *Condition) Like(arg string) *Condition { return c.appendQuery(100, Like, arg) }
[ "func", "(", "c", "*", "Condition", ")", "Like", "(", "arg", "string", ")", "*", "Condition", "{", "return", "c", ".", "appendQuery", "(", "100", ",", "Like", ",", "arg", ")", "\n", "}" ]
// Like adds "LIKE" clause to the Condition and returns it for method chain.
[ "Like", "adds", "LIKE", "clause", "to", "the", "Condition", "and", "returns", "it", "for", "method", "chain", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L1154-L1156
test
naoina/genmai
genmai.go
Between
func (c *Condition) Between(from, to interface{}) *Condition { return c.appendQuery(100, Between, &between{from, to}) }
go
func (c *Condition) Between(from, to interface{}) *Condition { return c.appendQuery(100, Between, &between{from, to}) }
[ "func", "(", "c", "*", "Condition", ")", "Between", "(", "from", ",", "to", "interface", "{", "}", ")", "*", "Condition", "{", "return", "c", ".", "appendQuery", "(", "100", ",", "Between", ",", "&", "between", "{", "from", ",", "to", "}", ")", "...
// Between adds "BETWEEN ... AND ..." clause to the Condition and returns it for method chain.
[ "Between", "adds", "BETWEEN", "...", "AND", "...", "clause", "to", "the", "Condition", "and", "returns", "it", "for", "method", "chain", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L1159-L1161
test
naoina/genmai
genmai.go
OrderBy
func (c *Condition) OrderBy(table, col interface{}, order ...interface{}) *Condition { order = append([]interface{}{table, col}, order...) orderbys := make([]orderBy, 0, 1) for len(order) > 0 { o, rest := order[0], order[1:] if _, ok := o.(string); ok { if len(rest) < 1 { panic(fmt.Errorf("OrderBy: few ar...
go
func (c *Condition) OrderBy(table, col interface{}, order ...interface{}) *Condition { order = append([]interface{}{table, col}, order...) orderbys := make([]orderBy, 0, 1) for len(order) > 0 { o, rest := order[0], order[1:] if _, ok := o.(string); ok { if len(rest) < 1 { panic(fmt.Errorf("OrderBy: few ar...
[ "func", "(", "c", "*", "Condition", ")", "OrderBy", "(", "table", ",", "col", "interface", "{", "}", ",", "order", "...", "interface", "{", "}", ")", "*", "Condition", "{", "order", "=", "append", "(", "[", "]", "interface", "{", "}", "{", "table",...
// OrderBy adds "ORDER BY" clause to the Condition and returns it for method chain.
[ "OrderBy", "adds", "ORDER", "BY", "clause", "to", "the", "Condition", "and", "returns", "it", "for", "method", "chain", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L1174-L1196
test
naoina/genmai
genmai.go
Limit
func (c *Condition) Limit(lim int) *Condition { return c.appendQuery(500, Limit, lim) }
go
func (c *Condition) Limit(lim int) *Condition { return c.appendQuery(500, Limit, lim) }
[ "func", "(", "c", "*", "Condition", ")", "Limit", "(", "lim", "int", ")", "*", "Condition", "{", "return", "c", ".", "appendQuery", "(", "500", ",", "Limit", ",", "lim", ")", "\n", "}" ]
// Limit adds "LIMIT" clause to the Condition and returns it for method chain.
[ "Limit", "adds", "LIMIT", "clause", "to", "the", "Condition", "and", "returns", "it", "for", "method", "chain", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L1199-L1201
test
naoina/genmai
genmai.go
Offset
func (c *Condition) Offset(offset int) *Condition { return c.appendQuery(700, Offset, offset) }
go
func (c *Condition) Offset(offset int) *Condition { return c.appendQuery(700, Offset, offset) }
[ "func", "(", "c", "*", "Condition", ")", "Offset", "(", "offset", "int", ")", "*", "Condition", "{", "return", "c", ".", "appendQuery", "(", "700", ",", "Offset", ",", "offset", ")", "\n", "}" ]
// Offset adds "OFFSET" clause to the Condition and returns it for method chain.
[ "Offset", "adds", "OFFSET", "clause", "to", "the", "Condition", "and", "returns", "it", "for", "method", "chain", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L1204-L1206
test
naoina/genmai
log.go
SetFormat
func (l *templateLogger) SetFormat(format string) error { l.m.Lock() defer l.m.Unlock() t, err := template.New("genmai").Parse(format) if err != nil { return err } l.t = t return nil }
go
func (l *templateLogger) SetFormat(format string) error { l.m.Lock() defer l.m.Unlock() t, err := template.New("genmai").Parse(format) if err != nil { return err } l.t = t return nil }
[ "func", "(", "l", "*", "templateLogger", ")", "SetFormat", "(", "format", "string", ")", "error", "{", "l", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "m", ".", "Unlock", "(", ")", "\n", "t", ",", "err", ":=", "template", ".", "N...
// SetFormat sets the format for logging.
[ "SetFormat", "sets", "the", "format", "for", "logging", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/log.go#L38-L47
test
naoina/genmai
log.go
Print
func (l *templateLogger) Print(start time.Time, query string, args ...interface{}) error { if len(args) > 0 { values := make([]string, len(args)) for i, arg := range args { values[i] = fmt.Sprintf("%#v", arg) } query = fmt.Sprintf("%v; [%v]", query, strings.Join(values, ", ")) } else { query = fmt.Sprint...
go
func (l *templateLogger) Print(start time.Time, query string, args ...interface{}) error { if len(args) > 0 { values := make([]string, len(args)) for i, arg := range args { values[i] = fmt.Sprintf("%#v", arg) } query = fmt.Sprintf("%v; [%v]", query, strings.Join(values, ", ")) } else { query = fmt.Sprint...
[ "func", "(", "l", "*", "templateLogger", ")", "Print", "(", "start", "time", ".", "Time", ",", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "if", "len", "(", "args", ")", ">", "0", "{", "values", ":=", "make", ...
// Print outputs query log using format template. // All arguments will be used to formatting.
[ "Print", "outputs", "query", "log", "using", "format", "template", ".", "All", "arguments", "will", "be", "used", "to", "formatting", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/log.go#L51-L76
test
naoina/genmai
log.go
Print
func (l *nullLogger) Print(start time.Time, query string, args ...interface{}) error { return nil }
go
func (l *nullLogger) Print(start time.Time, query string, args ...interface{}) error { return nil }
[ "func", "(", "l", "*", "nullLogger", ")", "Print", "(", "start", "time", ".", "Time", ",", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "return", "nil", "\n", "}" ]
// Print is a dummy method.
[ "Print", "is", "a", "dummy", "method", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/log.go#L88-L90
test
naoina/genmai
dialect.go
Quote
func (d *MySQLDialect) Quote(s string) string { return fmt.Sprintf("`%s`", strings.Replace(s, "`", "``", -1)) }
go
func (d *MySQLDialect) Quote(s string) string { return fmt.Sprintf("`%s`", strings.Replace(s, "`", "``", -1)) }
[ "func", "(", "d", "*", "MySQLDialect", ")", "Quote", "(", "s", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"`%s`\"", ",", "strings", ".", "Replace", "(", "s", ",", "\"`\"", ",", "\"``\"", ",", "-", "1", ")", ")", "\n", "...
// Quote returns a quoted s for a column name.
[ "Quote", "returns", "a", "quoted", "s", "for", "a", "column", "name", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/dialect.go#L138-L140
test
naoina/genmai
dialect.go
SQLType
func (d *PostgresDialect) SQLType(v interface{}, autoIncrement bool, size uint64) (name string, allowNull bool) { switch v.(type) { case bool: return "boolean", false case *bool, sql.NullBool: return "boolean", true case int8, int16, uint8, uint16: return d.smallint(autoIncrement), false case *int8, *int16, ...
go
func (d *PostgresDialect) SQLType(v interface{}, autoIncrement bool, size uint64) (name string, allowNull bool) { switch v.(type) { case bool: return "boolean", false case *bool, sql.NullBool: return "boolean", true case int8, int16, uint8, uint16: return d.smallint(autoIncrement), false case *int8, *int16, ...
[ "func", "(", "d", "*", "PostgresDialect", ")", "SQLType", "(", "v", "interface", "{", "}", ",", "autoIncrement", "bool", ",", "size", "uint64", ")", "(", "name", "string", ",", "allowNull", "bool", ")", "{", "switch", "v", ".", "(", "type", ")", "{",...
// SQLType returns the SQL type of the v for PostgreSQL.
[ "SQLType", "returns", "the", "SQL", "type", "of", "the", "v", "for", "PostgreSQL", "." ]
78583835e1e41e3938e1ddfffd7101f8ad27fae0
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/dialect.go#L251-L291
test
goreleaser/archive
archive.go
New
func New(file *os.File) Archive { if filepath.Ext(file.Name()) == ".zip" { return zip.New(file) } return tar.New(file) }
go
func New(file *os.File) Archive { if filepath.Ext(file.Name()) == ".zip" { return zip.New(file) } return tar.New(file) }
[ "func", "New", "(", "file", "*", "os", ".", "File", ")", "Archive", "{", "if", "filepath", ".", "Ext", "(", "file", ".", "Name", "(", ")", ")", "==", "\".zip\"", "{", "return", "zip", ".", "New", "(", "file", ")", "\n", "}", "\n", "return", "ta...
// New archive // If the exentions of the target file is .zip, the archive will be in the zip // format, otherwise, it will be a tar.gz archive.
[ "New", "archive", "If", "the", "exentions", "of", "the", "target", "file", "is", ".", "zip", "the", "archive", "will", "be", "in", "the", "zip", "format", "otherwise", "it", "will", "be", "a", "tar", ".", "gz", "archive", "." ]
9c6b0c177751034bab579499b81c69993ddfe563
https://github.com/goreleaser/archive/blob/9c6b0c177751034bab579499b81c69993ddfe563/archive.go#L22-L27
test
hooklift/govix
host.go
Disconnect
func (h *Host) Disconnect() { // TODO(c4milo): Return an error to the user given that this error // may be thrown due to insufficient hardware resources if h.handle == C.VIX_E_CANCELLED { return } if &h.handle != nil && h.handle != C.VIX_INVALID_HANDLE { C.VixHost_Disconnect(h.handle) h.handle = C.VIX_IN...
go
func (h *Host) Disconnect() { // TODO(c4milo): Return an error to the user given that this error // may be thrown due to insufficient hardware resources if h.handle == C.VIX_E_CANCELLED { return } if &h.handle != nil && h.handle != C.VIX_INVALID_HANDLE { C.VixHost_Disconnect(h.handle) h.handle = C.VIX_IN...
[ "func", "(", "h", "*", "Host", ")", "Disconnect", "(", ")", "{", "if", "h", ".", "handle", "==", "C", ".", "VIX_E_CANCELLED", "{", "return", "\n", "}", "\n", "if", "&", "h", ".", "handle", "!=", "nil", "&&", "h", ".", "handle", "!=", "C", ".", ...
// Disconnect destroys the state for a particular host instance. // // Call this function to disconnect the host. After you call this function the // Host object is no longer valid and you should not longer use it. // Similarly, you should not use any other object instances obtained from the // Host object while it was...
[ "Disconnect", "destroys", "the", "state", "for", "a", "particular", "host", "instance", ".", "Call", "this", "function", "to", "disconnect", "the", "host", ".", "After", "you", "call", "this", "function", "the", "Host", "object", "is", "no", "longer", "valid...
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/host.go#L31-L44
test
hooklift/govix
network.go
nextNetworkAdapterID
func (v *VM) nextNetworkAdapterID(vmx map[string]string) int { var nextID int prefix := "ethernet" for key := range vmx { if strings.HasPrefix(key, prefix) { ethN := strings.Split(key, ".")[0] number, _ := strconv.Atoi(strings.Split(ethN, prefix)[1]) // If ethN is not present, its id is recycled if v...
go
func (v *VM) nextNetworkAdapterID(vmx map[string]string) int { var nextID int prefix := "ethernet" for key := range vmx { if strings.HasPrefix(key, prefix) { ethN := strings.Split(key, ".")[0] number, _ := strconv.Atoi(strings.Split(ethN, prefix)[1]) // If ethN is not present, its id is recycled if v...
[ "func", "(", "v", "*", "VM", ")", "nextNetworkAdapterID", "(", "vmx", "map", "[", "string", "]", "string", ")", "int", "{", "var", "nextID", "int", "\n", "prefix", ":=", "\"ethernet\"", "\n", "for", "key", ":=", "range", "vmx", "{", "if", "strings", ...
// nextNetworkAdapterID returns the next available ethernet ID, reusing ids if // the ethernet adapter has "present" equal to "FALSE"
[ "nextNetworkAdapterID", "returns", "the", "next", "available", "ethernet", "ID", "reusing", "ids", "if", "the", "ethernet", "adapter", "has", "present", "equal", "to", "FALSE" ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/network.go#L305-L328
test
hooklift/govix
network.go
totalNetworkAdapters
func (v *VM) totalNetworkAdapters(vmx map[string]string) int { var total int prefix := "ethernet" for key := range vmx { if strings.HasPrefix(key, prefix) { ethN := strings.Split(key, ".")[0] number, _ := strconv.Atoi(strings.Split(ethN, prefix)[1]) if number > total { total = number } } } r...
go
func (v *VM) totalNetworkAdapters(vmx map[string]string) int { var total int prefix := "ethernet" for key := range vmx { if strings.HasPrefix(key, prefix) { ethN := strings.Split(key, ".")[0] number, _ := strconv.Atoi(strings.Split(ethN, prefix)[1]) if number > total { total = number } } } r...
[ "func", "(", "v", "*", "VM", ")", "totalNetworkAdapters", "(", "vmx", "map", "[", "string", "]", "string", ")", "int", "{", "var", "total", "int", "\n", "prefix", ":=", "\"ethernet\"", "\n", "for", "key", ":=", "range", "vmx", "{", "if", "strings", "...
// totalNetworkAdapters returns the total number of network adapters in the VMX file.
[ "totalNetworkAdapters", "returns", "the", "total", "number", "of", "network", "adapters", "in", "the", "VMX", "file", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/network.go#L331-L347
test
hooklift/govix
network.go
RemoveAllNetworkAdapters
func (v *VM) RemoveAllNetworkAdapters() error { vmxPath, err := v.VmxPath() if err != nil { return err } vmx, err := readVmx(vmxPath) if err != nil { return err } for key := range vmx { if strings.HasPrefix(key, "ethernet") { delete(vmx, key) } } return writeVmx(vmxPath, vmx) }
go
func (v *VM) RemoveAllNetworkAdapters() error { vmxPath, err := v.VmxPath() if err != nil { return err } vmx, err := readVmx(vmxPath) if err != nil { return err } for key := range vmx { if strings.HasPrefix(key, "ethernet") { delete(vmx, key) } } return writeVmx(vmxPath, vmx) }
[ "func", "(", "v", "*", "VM", ")", "RemoveAllNetworkAdapters", "(", ")", "error", "{", "vmxPath", ",", "err", ":=", "v", ".", "VmxPath", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "vmx", ",", "err", ":=", "rea...
// RemoveAllNetworkAdapters deletes all network adapters from a VM.
[ "RemoveAllNetworkAdapters", "deletes", "all", "network", "adapters", "from", "a", "VM", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/network.go#L350-L368
test
hooklift/govix
network.go
RemoveNetworkAdapter
func (v *VM) RemoveNetworkAdapter(adapter *NetworkAdapter) error { isVMRunning, err := v.IsRunning() if err != nil { return err } if isVMRunning { return &Error{ Operation: "vm.RemoveNetworkAdapter", Code: 100000, Text: "The VM has to be powered off in order to change its vmx settings", } ...
go
func (v *VM) RemoveNetworkAdapter(adapter *NetworkAdapter) error { isVMRunning, err := v.IsRunning() if err != nil { return err } if isVMRunning { return &Error{ Operation: "vm.RemoveNetworkAdapter", Code: 100000, Text: "The VM has to be powered off in order to change its vmx settings", } ...
[ "func", "(", "v", "*", "VM", ")", "RemoveNetworkAdapter", "(", "adapter", "*", "NetworkAdapter", ")", "error", "{", "isVMRunning", ",", "err", ":=", "v", ".", "IsRunning", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n...
// RemoveNetworkAdapter deletes network adapter from VMX file that matches the ID in "adapter.Id".
[ "RemoveNetworkAdapter", "deletes", "network", "adapter", "from", "VMX", "file", "that", "matches", "the", "ID", "in", "adapter", ".", "Id", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/network.go#L371-L411
test
hooklift/govix
network.go
NetworkAdapters
func (v *VM) NetworkAdapters() ([]*NetworkAdapter, error) { vmxPath, err := v.VmxPath() if err != nil { return nil, err } vmx, err := readVmx(vmxPath) if err != nil { return nil, err } var adapters []*NetworkAdapter // VMX ethernet adapters seem to not be zero based for i := 1; i <= v.totalNetworkAdapter...
go
func (v *VM) NetworkAdapters() ([]*NetworkAdapter, error) { vmxPath, err := v.VmxPath() if err != nil { return nil, err } vmx, err := readVmx(vmxPath) if err != nil { return nil, err } var adapters []*NetworkAdapter // VMX ethernet adapters seem to not be zero based for i := 1; i <= v.totalNetworkAdapter...
[ "func", "(", "v", "*", "VM", ")", "NetworkAdapters", "(", ")", "(", "[", "]", "*", "NetworkAdapter", ",", "error", ")", "{", "vmxPath", ",", "err", ":=", "v", ".", "VmxPath", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", ...
// NetworkAdapters lists current network adapters attached to the virtual // machine.
[ "NetworkAdapters", "lists", "current", "network", "adapters", "attached", "to", "the", "virtual", "machine", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/network.go#L415-L464
test
kjk/lzmadec
lzmadec.go
newArchive
func newArchive(path string, password *string) (*Archive, error) { err := detect7zCached() if err != nil { return nil, err } cmd := exec.Command("7z", "l", "-slt", "-sccUTF-8", path) out, err := cmd.CombinedOutput() if err != nil { return nil, err } entries, err := parse7zListOutput(out) if err != nil { ...
go
func newArchive(path string, password *string) (*Archive, error) { err := detect7zCached() if err != nil { return nil, err } cmd := exec.Command("7z", "l", "-slt", "-sccUTF-8", path) out, err := cmd.CombinedOutput() if err != nil { return nil, err } entries, err := parse7zListOutput(out) if err != nil { ...
[ "func", "newArchive", "(", "path", "string", ",", "password", "*", "string", ")", "(", "*", "Archive", ",", "error", ")", "{", "err", ":=", "detect7zCached", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n...
// NewArchive uses 7z to extract a list of files in .7z archive
[ "NewArchive", "uses", "7z", "to", "extract", "a", "list", "of", "files", "in", ".", "7z", "archive" ]
4c61f00ce86f6f11ed9630fa16b771889b08147b
https://github.com/kjk/lzmadec/blob/4c61f00ce86f6f11ed9630fa16b771889b08147b/lzmadec.go#L198-L217
test
kjk/lzmadec
lzmadec.go
GetFileReader
func (a *Archive) GetFileReader(name string) (io.ReadCloser, error) { found := false for _, e := range a.Entries { if e.Path == name { found = true break } } if !found { return nil, errors.New("file not in the archive") } params := []string{"x", "-so"} if a.password != nil { params = append(params...
go
func (a *Archive) GetFileReader(name string) (io.ReadCloser, error) { found := false for _, e := range a.Entries { if e.Path == name { found = true break } } if !found { return nil, errors.New("file not in the archive") } params := []string{"x", "-so"} if a.password != nil { params = append(params...
[ "func", "(", "a", "*", "Archive", ")", "GetFileReader", "(", "name", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "found", ":=", "false", "\n", "for", "_", ",", "e", ":=", "range", "a", ".", "Entries", "{", "if", "e", ".",...
// GetFileReader returns a reader for reading a given file
[ "GetFileReader", "returns", "a", "reader", "for", "reading", "a", "given", "file" ]
4c61f00ce86f6f11ed9630fa16b771889b08147b
https://github.com/kjk/lzmadec/blob/4c61f00ce86f6f11ed9630fa16b771889b08147b/lzmadec.go#L238-L268
test
kjk/lzmadec
lzmadec.go
ExtractToWriter
func (a *Archive) ExtractToWriter(dst io.Writer, name string) error { r, err := a.GetFileReader(name) if err != nil { return err } _, err = io.Copy(dst, r) err2 := r.Close() if err != nil { return err } return err2 }
go
func (a *Archive) ExtractToWriter(dst io.Writer, name string) error { r, err := a.GetFileReader(name) if err != nil { return err } _, err = io.Copy(dst, r) err2 := r.Close() if err != nil { return err } return err2 }
[ "func", "(", "a", "*", "Archive", ")", "ExtractToWriter", "(", "dst", "io", ".", "Writer", ",", "name", "string", ")", "error", "{", "r", ",", "err", ":=", "a", ".", "GetFileReader", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// ExtractToWriter writes the content of a given file inside the archive to dst
[ "ExtractToWriter", "writes", "the", "content", "of", "a", "given", "file", "inside", "the", "archive", "to", "dst" ]
4c61f00ce86f6f11ed9630fa16b771889b08147b
https://github.com/kjk/lzmadec/blob/4c61f00ce86f6f11ed9630fa16b771889b08147b/lzmadec.go#L271-L282
test
kjk/lzmadec
lzmadec.go
ExtractToFile
func (a *Archive) ExtractToFile(dstPath string, name string) error { f, err := os.Create(dstPath) if err != nil { return err } defer f.Close() return a.ExtractToWriter(f, name) }
go
func (a *Archive) ExtractToFile(dstPath string, name string) error { f, err := os.Create(dstPath) if err != nil { return err } defer f.Close() return a.ExtractToWriter(f, name) }
[ "func", "(", "a", "*", "Archive", ")", "ExtractToFile", "(", "dstPath", "string", ",", "name", "string", ")", "error", "{", "f", ",", "err", ":=", "os", ".", "Create", "(", "dstPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n",...
// ExtractToFile extracts a given file from the archive to a file on disk
[ "ExtractToFile", "extracts", "a", "given", "file", "from", "the", "archive", "to", "a", "file", "on", "disk" ]
4c61f00ce86f6f11ed9630fa16b771889b08147b
https://github.com/kjk/lzmadec/blob/4c61f00ce86f6f11ed9630fa16b771889b08147b/lzmadec.go#L285-L292
test
hooklift/govix
guest.go
SharedFoldersParentDir
func (g *Guest) SharedFoldersParentDir() (string, error) { var err C.VixError = C.VIX_OK var path *C.char err = C.get_property(g.handle, C.VIX_PROPERTY_GUEST_SHAREDFOLDERS_SHARES_PATH, unsafe.Pointer(&path)) defer C.Vix_FreeBuffer(unsafe.Pointer(path)) if C.VIX_OK != err { return "", &Error{ Operation:...
go
func (g *Guest) SharedFoldersParentDir() (string, error) { var err C.VixError = C.VIX_OK var path *C.char err = C.get_property(g.handle, C.VIX_PROPERTY_GUEST_SHAREDFOLDERS_SHARES_PATH, unsafe.Pointer(&path)) defer C.Vix_FreeBuffer(unsafe.Pointer(path)) if C.VIX_OK != err { return "", &Error{ Operation:...
[ "func", "(", "g", "*", "Guest", ")", "SharedFoldersParentDir", "(", ")", "(", "string", ",", "error", ")", "{", "var", "err", "C", ".", "VixError", "=", "C", ".", "VIX_OK", "\n", "var", "path", "*", "C", ".", "char", "\n", "err", "=", "C", ".", ...
// SharedFoldersParentDir returns the parent dir for share folders in the Guest.
[ "SharedFoldersParentDir", "returns", "the", "parent", "dir", "for", "share", "folders", "in", "the", "Guest", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/guest.go#L23-L42
test
hooklift/govix
snapshot.go
Name
func (s *Snapshot) Name() (string, error) { var err C.VixError = C.VIX_OK var name *C.char err = C.get_property(s.handle, C.VIX_PROPERTY_SNAPSHOT_DISPLAYNAME, unsafe.Pointer(&name)) defer C.Vix_FreeBuffer(unsafe.Pointer(name)) if C.VIX_OK != err { return "", &Error{ Operation: "snapshot.Name", Code:...
go
func (s *Snapshot) Name() (string, error) { var err C.VixError = C.VIX_OK var name *C.char err = C.get_property(s.handle, C.VIX_PROPERTY_SNAPSHOT_DISPLAYNAME, unsafe.Pointer(&name)) defer C.Vix_FreeBuffer(unsafe.Pointer(name)) if C.VIX_OK != err { return "", &Error{ Operation: "snapshot.Name", Code:...
[ "func", "(", "s", "*", "Snapshot", ")", "Name", "(", ")", "(", "string", ",", "error", ")", "{", "var", "err", "C", ".", "VixError", "=", "C", ".", "VIX_OK", "\n", "var", "name", "*", "C", ".", "char", "\n", "err", "=", "C", ".", "get_property"...
// Name returns user defined name for the snapshot.
[ "Name", "returns", "user", "defined", "name", "for", "the", "snapshot", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/snapshot.go#L25-L44
test
hooklift/govix
snapshot.go
Description
func (s *Snapshot) Description() (string, error) { var err C.VixError = C.VIX_OK var desc *C.char err = C.get_property(s.handle, C.VIX_PROPERTY_SNAPSHOT_DESCRIPTION, unsafe.Pointer(&desc)) defer C.Vix_FreeBuffer(unsafe.Pointer(desc)) if C.VIX_OK != err { return "", &Error{ Operation: "snapshot.Descript...
go
func (s *Snapshot) Description() (string, error) { var err C.VixError = C.VIX_OK var desc *C.char err = C.get_property(s.handle, C.VIX_PROPERTY_SNAPSHOT_DESCRIPTION, unsafe.Pointer(&desc)) defer C.Vix_FreeBuffer(unsafe.Pointer(desc)) if C.VIX_OK != err { return "", &Error{ Operation: "snapshot.Descript...
[ "func", "(", "s", "*", "Snapshot", ")", "Description", "(", ")", "(", "string", ",", "error", ")", "{", "var", "err", "C", ".", "VixError", "=", "C", ".", "VIX_OK", "\n", "var", "desc", "*", "C", ".", "char", "\n", "err", "=", "C", ".", "get_pr...
// Description returns user defined description for the snapshot.
[ "Description", "returns", "user", "defined", "description", "for", "the", "snapshot", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/snapshot.go#L47-L66
test
hooklift/govix
snapshot.go
cleanupSnapshot
func cleanupSnapshot(s *Snapshot) { if s.handle != C.VIX_INVALID_HANDLE { C.Vix_ReleaseHandle(s.handle) s.handle = C.VIX_INVALID_HANDLE } }
go
func cleanupSnapshot(s *Snapshot) { if s.handle != C.VIX_INVALID_HANDLE { C.Vix_ReleaseHandle(s.handle) s.handle = C.VIX_INVALID_HANDLE } }
[ "func", "cleanupSnapshot", "(", "s", "*", "Snapshot", ")", "{", "if", "s", ".", "handle", "!=", "C", ".", "VIX_INVALID_HANDLE", "{", "C", ".", "Vix_ReleaseHandle", "(", "s", ".", "handle", ")", "\n", "s", ".", "handle", "=", "C", ".", "VIX_INVALID_HAND...
// cleanupSnapshot cleans up snapshot internal C handle.
[ "cleanupSnapshot", "cleans", "up", "snapshot", "internal", "C", "handle", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/snapshot.go#L162-L167
test
hooklift/govix
cddvd.go
BusTypeFromID
func BusTypeFromID(ID string) vmx.BusType { var bus vmx.BusType switch { case strings.HasPrefix(ID, string(vmx.IDE)): bus = vmx.IDE case strings.HasPrefix(ID, string(vmx.SCSI)): bus = vmx.SCSI case strings.HasPrefix(ID, string(vmx.SATA)): bus = vmx.SATA } return bus }
go
func BusTypeFromID(ID string) vmx.BusType { var bus vmx.BusType switch { case strings.HasPrefix(ID, string(vmx.IDE)): bus = vmx.IDE case strings.HasPrefix(ID, string(vmx.SCSI)): bus = vmx.SCSI case strings.HasPrefix(ID, string(vmx.SATA)): bus = vmx.SATA } return bus }
[ "func", "BusTypeFromID", "(", "ID", "string", ")", "vmx", ".", "BusType", "{", "var", "bus", "vmx", ".", "BusType", "\n", "switch", "{", "case", "strings", ".", "HasPrefix", "(", "ID", ",", "string", "(", "vmx", ".", "IDE", ")", ")", ":", "bus", "=...
// BusTypeFromID gets BusType from device ID.
[ "BusTypeFromID", "gets", "BusType", "from", "device", "ID", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/cddvd.go#L178-L190
test
hooklift/govix
vmx.go
Read
func (vmxfile *VMXFile) Read() error { data, err := ioutil.ReadFile(vmxfile.path) if err != nil { return err } model := new(vmx.VirtualMachine) err = vmx.Unmarshal(data, model) if err != nil { return err } vmxfile.model = model return nil }
go
func (vmxfile *VMXFile) Read() error { data, err := ioutil.ReadFile(vmxfile.path) if err != nil { return err } model := new(vmx.VirtualMachine) err = vmx.Unmarshal(data, model) if err != nil { return err } vmxfile.model = model return nil }
[ "func", "(", "vmxfile", "*", "VMXFile", ")", "Read", "(", ")", "error", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "vmxfile", ".", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "model", ":...
// Read reads VMX file from disk and unmarshals it
[ "Read", "reads", "VMX", "file", "from", "disk", "and", "unmarshals", "it" ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vmx.go#L27-L43
test
hooklift/govix
vmx.go
Write
func (vmxfile *VMXFile) Write() error { file, err := os.Create(vmxfile.path) if err != nil { return err } defer file.Close() data, err := vmx.Marshal(vmxfile.model) if err != nil { return err } _, err = file.Write(data) if err != nil { return err } return nil }
go
func (vmxfile *VMXFile) Write() error { file, err := os.Create(vmxfile.path) if err != nil { return err } defer file.Close() data, err := vmx.Marshal(vmxfile.model) if err != nil { return err } _, err = file.Write(data) if err != nil { return err } return nil }
[ "func", "(", "vmxfile", "*", "VMXFile", ")", "Write", "(", ")", "error", "{", "file", ",", "err", ":=", "os", ".", "Create", "(", "vmxfile", ".", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "file",...
// Write marshals and writes VMX file to disk
[ "Write", "marshals", "and", "writes", "VMX", "file", "to", "disk" ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vmx.go#L46-L64
test
hooklift/govix
vm.go
NewVirtualMachine
func NewVirtualMachine(handle C.VixHandle, vmxpath string) (*VM, error) { vmxfile := &VMXFile{ path: vmxpath, } // Loads VMX file in memory err := vmxfile.Read() if err != nil { return nil, err } vm := &VM{ handle: handle, vmxfile: vmxfile, } runtime.SetFinalizer(vm, cleanupVM) return vm, nil }
go
func NewVirtualMachine(handle C.VixHandle, vmxpath string) (*VM, error) { vmxfile := &VMXFile{ path: vmxpath, } // Loads VMX file in memory err := vmxfile.Read() if err != nil { return nil, err } vm := &VM{ handle: handle, vmxfile: vmxfile, } runtime.SetFinalizer(vm, cleanupVM) return vm, nil }
[ "func", "NewVirtualMachine", "(", "handle", "C", ".", "VixHandle", ",", "vmxpath", "string", ")", "(", "*", "VM", ",", "error", ")", "{", "vmxfile", ":=", "&", "VMXFile", "{", "path", ":", "vmxpath", ",", "}", "\n", "err", ":=", "vmxfile", ".", "Read...
// NewVirtualMachine creates a new VM instance.
[ "NewVirtualMachine", "creates", "a", "new", "VM", "instance", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L33-L51
test
hooklift/govix
vm.go
Vcpus
func (v *VM) Vcpus() (uint8, error) { var err C.VixError = C.VIX_OK vcpus := C.VIX_PROPERTY_NONE err = C.get_property(v.handle, C.VIX_PROPERTY_VM_NUM_VCPUS, unsafe.Pointer(&vcpus)) if C.VIX_OK != err { return 0, &Error{ Operation: "vm.Vcpus", Code: int(err & 0xFFFF), Text: C.GoString(C.Vi...
go
func (v *VM) Vcpus() (uint8, error) { var err C.VixError = C.VIX_OK vcpus := C.VIX_PROPERTY_NONE err = C.get_property(v.handle, C.VIX_PROPERTY_VM_NUM_VCPUS, unsafe.Pointer(&vcpus)) if C.VIX_OK != err { return 0, &Error{ Operation: "vm.Vcpus", Code: int(err & 0xFFFF), Text: C.GoString(C.Vi...
[ "func", "(", "v", "*", "VM", ")", "Vcpus", "(", ")", "(", "uint8", ",", "error", ")", "{", "var", "err", "C", ".", "VixError", "=", "C", ".", "VIX_OK", "\n", "vcpus", ":=", "C", ".", "VIX_PROPERTY_NONE", "\n", "err", "=", "C", ".", "get_property"...
// Vcpus returns number of virtual CPUs configured for the virtual machine.
[ "Vcpus", "returns", "number", "of", "virtual", "CPUs", "configured", "for", "the", "virtual", "machine", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L54-L71
test
hooklift/govix
vm.go
VmxPath
func (v *VM) VmxPath() (string, error) { var err C.VixError = C.VIX_OK var path *C.char err = C.get_property(v.handle, C.VIX_PROPERTY_VM_VMX_PATHNAME, unsafe.Pointer(&path)) defer C.Vix_FreeBuffer(unsafe.Pointer(path)) if C.VIX_OK != err { return "", &Error{ Operation: "vm.VmxPath", Code: int(e...
go
func (v *VM) VmxPath() (string, error) { var err C.VixError = C.VIX_OK var path *C.char err = C.get_property(v.handle, C.VIX_PROPERTY_VM_VMX_PATHNAME, unsafe.Pointer(&path)) defer C.Vix_FreeBuffer(unsafe.Pointer(path)) if C.VIX_OK != err { return "", &Error{ Operation: "vm.VmxPath", Code: int(e...
[ "func", "(", "v", "*", "VM", ")", "VmxPath", "(", ")", "(", "string", ",", "error", ")", "{", "var", "err", "C", ".", "VixError", "=", "C", ".", "VIX_OK", "\n", "var", "path", "*", "C", ".", "char", "\n", "err", "=", "C", ".", "get_property", ...
// VmxPath returns path to the virtual machine configuration file.
[ "VmxPath", "returns", "path", "to", "the", "virtual", "machine", "configuration", "file", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L74-L93
test
hooklift/govix
vm.go
MemorySize
func (v *VM) MemorySize() (uint, error) { var err C.VixError = C.VIX_OK memsize := C.VIX_PROPERTY_NONE err = C.get_property(v.handle, C.VIX_PROPERTY_VM_MEMORY_SIZE, unsafe.Pointer(&memsize)) if C.VIX_OK != err { return 0, &Error{ Operation: "vm.MemorySize", Code: int(err & 0xFFFF), Text: ...
go
func (v *VM) MemorySize() (uint, error) { var err C.VixError = C.VIX_OK memsize := C.VIX_PROPERTY_NONE err = C.get_property(v.handle, C.VIX_PROPERTY_VM_MEMORY_SIZE, unsafe.Pointer(&memsize)) if C.VIX_OK != err { return 0, &Error{ Operation: "vm.MemorySize", Code: int(err & 0xFFFF), Text: ...
[ "func", "(", "v", "*", "VM", ")", "MemorySize", "(", ")", "(", "uint", ",", "error", ")", "{", "var", "err", "C", ".", "VixError", "=", "C", ".", "VIX_OK", "\n", "memsize", ":=", "C", ".", "VIX_PROPERTY_NONE", "\n", "err", "=", "C", ".", "get_pro...
// MemorySize returns memory size of the virtual machine.
[ "MemorySize", "returns", "memory", "size", "of", "the", "virtual", "machine", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L118-L135
test
hooklift/govix
vm.go
ReadOnly
func (v *VM) ReadOnly() (bool, error) { var err C.VixError = C.VIX_OK readonly := C.VIX_PROPERTY_NONE err = C.get_property(v.handle, C.VIX_PROPERTY_VM_READ_ONLY, unsafe.Pointer(&readonly)) if C.VIX_OK != err { return false, &Error{ Operation: "vm.ReadOnly", Code: int(err & 0xFFFF), Text: ...
go
func (v *VM) ReadOnly() (bool, error) { var err C.VixError = C.VIX_OK readonly := C.VIX_PROPERTY_NONE err = C.get_property(v.handle, C.VIX_PROPERTY_VM_READ_ONLY, unsafe.Pointer(&readonly)) if C.VIX_OK != err { return false, &Error{ Operation: "vm.ReadOnly", Code: int(err & 0xFFFF), Text: ...
[ "func", "(", "v", "*", "VM", ")", "ReadOnly", "(", ")", "(", "bool", ",", "error", ")", "{", "var", "err", "C", ".", "VixError", "=", "C", ".", "VIX_OK", "\n", "readonly", ":=", "C", ".", "VIX_PROPERTY_NONE", "\n", "err", "=", "C", ".", "get_prop...
// ReadOnly tells whether or not the VM is read-only.
[ "ReadOnly", "tells", "whether", "or", "not", "the", "VM", "is", "read", "-", "only", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L138-L159
test
hooklift/govix
vm.go
InVMTeam
func (v *VM) InVMTeam() (bool, error) { var err C.VixError = C.VIX_OK inTeam := C.VIX_PROPERTY_NONE err = C.get_property(v.handle, C.VIX_PROPERTY_VM_IN_VMTEAM, unsafe.Pointer(&inTeam)) if C.VIX_OK != err { return false, &Error{ Operation: "vm.InVmTeam", Code: int(err & 0xFFFF), Text: C.Go...
go
func (v *VM) InVMTeam() (bool, error) { var err C.VixError = C.VIX_OK inTeam := C.VIX_PROPERTY_NONE err = C.get_property(v.handle, C.VIX_PROPERTY_VM_IN_VMTEAM, unsafe.Pointer(&inTeam)) if C.VIX_OK != err { return false, &Error{ Operation: "vm.InVmTeam", Code: int(err & 0xFFFF), Text: C.Go...
[ "func", "(", "v", "*", "VM", ")", "InVMTeam", "(", ")", "(", "bool", ",", "error", ")", "{", "var", "err", "C", ".", "VixError", "=", "C", ".", "VIX_OK", "\n", "inTeam", ":=", "C", ".", "VIX_PROPERTY_NONE", "\n", "err", "=", "C", ".", "get_proper...
// InVMTeam returns whether the virtual machine is a member of a team.
[ "InVMTeam", "returns", "whether", "the", "virtual", "machine", "is", "a", "member", "of", "a", "team", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L162-L183
test
hooklift/govix
vm.go
PowerState
func (v *VM) PowerState() (VMPowerState, error) { var err C.VixError = C.VIX_OK var state C.VixPowerState = 0x0 err = C.get_property(v.handle, C.VIX_PROPERTY_VM_POWER_STATE, unsafe.Pointer(&state)) if C.VIX_OK != err { return VMPowerState(0x0), &Error{ Operation: "vm.PowerState", Code: int(err & ...
go
func (v *VM) PowerState() (VMPowerState, error) { var err C.VixError = C.VIX_OK var state C.VixPowerState = 0x0 err = C.get_property(v.handle, C.VIX_PROPERTY_VM_POWER_STATE, unsafe.Pointer(&state)) if C.VIX_OK != err { return VMPowerState(0x0), &Error{ Operation: "vm.PowerState", Code: int(err & ...
[ "func", "(", "v", "*", "VM", ")", "PowerState", "(", ")", "(", "VMPowerState", ",", "error", ")", "{", "var", "err", "C", ".", "VixError", "=", "C", ".", "VIX_OK", "\n", "var", "state", "C", ".", "VixPowerState", "=", "0x0", "\n", "err", "=", "C"...
// PowerState returns power state of the virtual machine.
[ "PowerState", "returns", "power", "state", "of", "the", "virtual", "machine", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L186-L203
test
hooklift/govix
vm.go
ToolsState
func (v *VM) ToolsState() (GuestToolsState, error) { var err C.VixError = C.VIX_OK state := C.VIX_TOOLSSTATE_UNKNOWN err = C.get_property(v.handle, C.VIX_PROPERTY_VM_TOOLS_STATE, unsafe.Pointer(&state)) if C.VIX_OK != err { return TOOLSSTATE_UNKNOWN, &Error{ Operation: "vm.ToolsState", Code: int(...
go
func (v *VM) ToolsState() (GuestToolsState, error) { var err C.VixError = C.VIX_OK state := C.VIX_TOOLSSTATE_UNKNOWN err = C.get_property(v.handle, C.VIX_PROPERTY_VM_TOOLS_STATE, unsafe.Pointer(&state)) if C.VIX_OK != err { return TOOLSSTATE_UNKNOWN, &Error{ Operation: "vm.ToolsState", Code: int(...
[ "func", "(", "v", "*", "VM", ")", "ToolsState", "(", ")", "(", "GuestToolsState", ",", "error", ")", "{", "var", "err", "C", ".", "VixError", "=", "C", ".", "VIX_OK", "\n", "state", ":=", "C", ".", "VIX_TOOLSSTATE_UNKNOWN", "\n", "err", "=", "C", "...
// ToolsState returns state of the VMware Tools suite in the guest.
[ "ToolsState", "returns", "state", "of", "the", "VMware", "Tools", "suite", "in", "the", "guest", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L206-L223
test
hooklift/govix
vm.go
IsRunning
func (v *VM) IsRunning() (bool, error) { var err C.VixError = C.VIX_OK running := C.VIX_PROPERTY_NONE err = C.get_property(v.handle, C.VIX_PROPERTY_VM_IS_RUNNING, unsafe.Pointer(&running)) if C.VIX_OK != err { return false, &Error{ Operation: "vm.IsRunning", Code: int(err & 0xFFFF), Text: ...
go
func (v *VM) IsRunning() (bool, error) { var err C.VixError = C.VIX_OK running := C.VIX_PROPERTY_NONE err = C.get_property(v.handle, C.VIX_PROPERTY_VM_IS_RUNNING, unsafe.Pointer(&running)) if C.VIX_OK != err { return false, &Error{ Operation: "vm.IsRunning", Code: int(err & 0xFFFF), Text: ...
[ "func", "(", "v", "*", "VM", ")", "IsRunning", "(", ")", "(", "bool", ",", "error", ")", "{", "var", "err", "C", ".", "VixError", "=", "C", ".", "VIX_OK", "\n", "running", ":=", "C", ".", "VIX_PROPERTY_NONE", "\n", "err", "=", "C", ".", "get_prop...
// IsRunning returns whether the virtual machine is running.
[ "IsRunning", "returns", "whether", "the", "virtual", "machine", "is", "running", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L226-L247
test
hooklift/govix
vm.go
GuestOS
func (v *VM) GuestOS() (string, error) { var err C.VixError = C.VIX_OK var os *C.char err = C.get_property(v.handle, C.VIX_PROPERTY_VM_GUESTOS, unsafe.Pointer(&os)) defer C.Vix_FreeBuffer(unsafe.Pointer(os)) if C.VIX_OK != err { return "", &Error{ Operation: "vm.GuestOS", Code: int(err & 0xFFFF...
go
func (v *VM) GuestOS() (string, error) { var err C.VixError = C.VIX_OK var os *C.char err = C.get_property(v.handle, C.VIX_PROPERTY_VM_GUESTOS, unsafe.Pointer(&os)) defer C.Vix_FreeBuffer(unsafe.Pointer(os)) if C.VIX_OK != err { return "", &Error{ Operation: "vm.GuestOS", Code: int(err & 0xFFFF...
[ "func", "(", "v", "*", "VM", ")", "GuestOS", "(", ")", "(", "string", ",", "error", ")", "{", "var", "err", "C", ".", "VixError", "=", "C", ".", "VIX_OK", "\n", "var", "os", "*", "C", ".", "char", "\n", "err", "=", "C", ".", "get_property", "...
// GuestOS returns the guest os.
[ "GuestOS", "returns", "the", "guest", "os", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L250-L269
test
hooklift/govix
vm.go
cleanupVM
func cleanupVM(v *VM) { if v.handle != C.VIX_INVALID_HANDLE { C.Vix_ReleaseHandle(v.handle) v.handle = C.VIX_INVALID_HANDLE } }
go
func cleanupVM(v *VM) { if v.handle != C.VIX_INVALID_HANDLE { C.Vix_ReleaseHandle(v.handle) v.handle = C.VIX_INVALID_HANDLE } }
[ "func", "cleanupVM", "(", "v", "*", "VM", ")", "{", "if", "v", ".", "handle", "!=", "C", ".", "VIX_INVALID_HANDLE", "{", "C", ".", "Vix_ReleaseHandle", "(", "v", ".", "handle", ")", "\n", "v", ".", "handle", "=", "C", ".", "VIX_INVALID_HANDLE", "\n",...
// cleanupVM cleans up VM VIX handle.
[ "cleanupVM", "cleans", "up", "VM", "VIX", "handle", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L593-L598
test
hooklift/govix
vm.go
updateVMX
func (v *VM) updateVMX(updateFunc func(model *vmx.VirtualMachine) error) error { isVMRunning, err := v.IsRunning() if err != nil { return err } if isVMRunning { return &Error{ Operation: "vm.updateVMX", Code: 100000, Text: "The VM has to be powered off in order to change its vmx settings", ...
go
func (v *VM) updateVMX(updateFunc func(model *vmx.VirtualMachine) error) error { isVMRunning, err := v.IsRunning() if err != nil { return err } if isVMRunning { return &Error{ Operation: "vm.updateVMX", Code: 100000, Text: "The VM has to be powered off in order to change its vmx settings", ...
[ "func", "(", "v", "*", "VM", ")", "updateVMX", "(", "updateFunc", "func", "(", "model", "*", "vmx", ".", "VirtualMachine", ")", "error", ")", "error", "{", "isVMRunning", ",", "err", ":=", "v", ".", "IsRunning", "(", ")", "\n", "if", "err", "!=", "...
// updateVMX updates VMX file for the VM.
[ "updateVMX", "updates", "VMX", "file", "for", "the", "VM", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L1959-L2001
test
hooklift/govix
vm.go
SetMemorySize
func (v *VM) SetMemorySize(size uint) error { if size == 0 { size = 4 } // Makes sure memory size is divisible by 4, otherwise VMware is going to // silently fail, cancelling vix operations. if size%4 != 0 { size = uint(math.Floor(float64((size / 4) * 4))) } return v.updateVMX(func(model *vmx.VirtualMachin...
go
func (v *VM) SetMemorySize(size uint) error { if size == 0 { size = 4 } // Makes sure memory size is divisible by 4, otherwise VMware is going to // silently fail, cancelling vix operations. if size%4 != 0 { size = uint(math.Floor(float64((size / 4) * 4))) } return v.updateVMX(func(model *vmx.VirtualMachin...
[ "func", "(", "v", "*", "VM", ")", "SetMemorySize", "(", "size", "uint", ")", "error", "{", "if", "size", "==", "0", "{", "size", "=", "4", "\n", "}", "\n", "if", "size", "%", "4", "!=", "0", "{", "size", "=", "uint", "(", "math", ".", "Floor"...
// SetMemorySize sets memory size in megabytes. VM has to be powered off in order to change this parameter.
[ "SetMemorySize", "sets", "memory", "size", "in", "megabytes", ".", "VM", "has", "to", "be", "powered", "off", "in", "order", "to", "change", "this", "parameter", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L2004-L2019
test
hooklift/govix
vm.go
SetNumberVcpus
func (v *VM) SetNumberVcpus(vcpus uint) error { if vcpus < 1 { vcpus = 1 } return v.updateVMX(func(model *vmx.VirtualMachine) error { model.NumvCPUs = vcpus return nil }) }
go
func (v *VM) SetNumberVcpus(vcpus uint) error { if vcpus < 1 { vcpus = 1 } return v.updateVMX(func(model *vmx.VirtualMachine) error { model.NumvCPUs = vcpus return nil }) }
[ "func", "(", "v", "*", "VM", ")", "SetNumberVcpus", "(", "vcpus", "uint", ")", "error", "{", "if", "vcpus", "<", "1", "{", "vcpus", "=", "1", "\n", "}", "\n", "return", "v", ".", "updateVMX", "(", "func", "(", "model", "*", "vmx", ".", "VirtualMa...
// SetNumberVcpus sets number of virtual cpus assigned to this machine. VM has to be powered off in order to change this parameter.
[ "SetNumberVcpus", "sets", "number", "of", "virtual", "cpus", "assigned", "to", "this", "machine", ".", "VM", "has", "to", "be", "powered", "off", "in", "order", "to", "change", "this", "parameter", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L2022-L2031
test
hooklift/govix
vm.go
SetDisplayName
func (v *VM) SetDisplayName(name string) error { return v.updateVMX(func(model *vmx.VirtualMachine) error { model.DisplayName = name return nil }) }
go
func (v *VM) SetDisplayName(name string) error { return v.updateVMX(func(model *vmx.VirtualMachine) error { model.DisplayName = name return nil }) }
[ "func", "(", "v", "*", "VM", ")", "SetDisplayName", "(", "name", "string", ")", "error", "{", "return", "v", ".", "updateVMX", "(", "func", "(", "model", "*", "vmx", ".", "VirtualMachine", ")", "error", "{", "model", ".", "DisplayName", "=", "name", ...
// SetDisplayName sets virtual machine name.
[ "SetDisplayName", "sets", "virtual", "machine", "name", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L2034-L2039
test
hooklift/govix
vm.go
SetAnnotation
func (v *VM) SetAnnotation(text string) error { return v.updateVMX(func(model *vmx.VirtualMachine) error { model.Annotation = text return nil }) }
go
func (v *VM) SetAnnotation(text string) error { return v.updateVMX(func(model *vmx.VirtualMachine) error { model.Annotation = text return nil }) }
[ "func", "(", "v", "*", "VM", ")", "SetAnnotation", "(", "text", "string", ")", "error", "{", "return", "v", ".", "updateVMX", "(", "func", "(", "model", "*", "vmx", ".", "VirtualMachine", ")", "error", "{", "model", ".", "Annotation", "=", "text", "\...
// SetAnnotation sets annotations for the virtual machine.
[ "SetAnnotation", "sets", "annotations", "for", "the", "virtual", "machine", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L2047-L2052
test
hooklift/govix
vm.go
SetVirtualHwVersion
func (v *VM) SetVirtualHwVersion(version string) error { return v.updateVMX(func(model *vmx.VirtualMachine) error { version, err := strconv.ParseInt(version, 10, 32) if err != nil { return err } model.Vhardware.Compat = "hosted" model.Vhardware.Version = int(version) return nil }) }
go
func (v *VM) SetVirtualHwVersion(version string) error { return v.updateVMX(func(model *vmx.VirtualMachine) error { version, err := strconv.ParseInt(version, 10, 32) if err != nil { return err } model.Vhardware.Compat = "hosted" model.Vhardware.Version = int(version) return nil }) }
[ "func", "(", "v", "*", "VM", ")", "SetVirtualHwVersion", "(", "version", "string", ")", "error", "{", "return", "v", ".", "updateVMX", "(", "func", "(", "model", "*", "vmx", ".", "VirtualMachine", ")", "error", "{", "version", ",", "err", ":=", "strcon...
// SetVirtualHwVersion sets a virtual hardware version in the VMX file of the VM.
[ "SetVirtualHwVersion", "sets", "a", "virtual", "hardware", "version", "in", "the", "VMX", "file", "of", "the", "VM", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L2060-L2070
test
hooklift/govix
vix.go
Error
func (e *Error) Error() string { return fmt.Sprintf("VIX Error: %s, code: %d, operation: %s", e.Text, e.Code, e.Operation) }
go
func (e *Error) Error() string { return fmt.Sprintf("VIX Error: %s, code: %d, operation: %s", e.Text, e.Code, e.Operation) }
[ "func", "(", "e", "*", "Error", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"VIX Error: %s, code: %d, operation: %s\"", ",", "e", ".", "Text", ",", "e", ".", "Code", ",", "e", ".", "Operation", ")", "\n", "}" ]
// Error returns a description of the error along with its code and operation // implementing Go's error interface.
[ "Error", "returns", "a", "description", "of", "the", "error", "along", "with", "its", "code", "and", "operation", "implementing", "Go", "s", "error", "interface", "." ]
063702285520a992b920fc1575e305dc9ffd6ffe
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vix.go#L396-L398
test
st3v/tracerr
tracerr.go
Errorf
func Errorf(message string, a ...interface{}) error { return wrap(fmt.Errorf(message, a...)) }
go
func Errorf(message string, a ...interface{}) error { return wrap(fmt.Errorf(message, a...)) }
[ "func", "Errorf", "(", "message", "string", ",", "a", "...", "interface", "{", "}", ")", "error", "{", "return", "wrap", "(", "fmt", ".", "Errorf", "(", "message", ",", "a", "...", ")", ")", "\n", "}" ]
// Errorf returns a traceable error with the given formatted message.
[ "Errorf", "returns", "a", "traceable", "error", "with", "the", "given", "formatted", "message", "." ]
07f754d5ee02576c14a8272df820e8947d87e723
https://github.com/st3v/tracerr/blob/07f754d5ee02576c14a8272df820e8947d87e723/tracerr.go#L39-L41
test
st3v/tracerr
tracerr.go
Error
func (t *traceableError) Error() string { str := t.err.Error() for _, frame := range t.stack { str += fmt.Sprintf("\n at %s", frame.string()) } return str }
go
func (t *traceableError) Error() string { str := t.err.Error() for _, frame := range t.stack { str += fmt.Sprintf("\n at %s", frame.string()) } return str }
[ "func", "(", "t", "*", "traceableError", ")", "Error", "(", ")", "string", "{", "str", ":=", "t", ".", "err", ".", "Error", "(", ")", "\n", "for", "_", ",", "frame", ":=", "range", "t", ".", "stack", "{", "str", "+=", "fmt", ".", "Sprintf", "("...
// Error returns the original error message plus the stack trace captured // at the time the error was first wrapped.
[ "Error", "returns", "the", "original", "error", "message", "plus", "the", "stack", "trace", "captured", "at", "the", "time", "the", "error", "was", "first", "wrapped", "." ]
07f754d5ee02576c14a8272df820e8947d87e723
https://github.com/st3v/tracerr/blob/07f754d5ee02576c14a8272df820e8947d87e723/tracerr.go#L65-L71
test
st3v/tracerr
tracerr.go
string
func (s *stackFrame) string() string { return fmt.Sprintf("%s (%s:%d)", s.function, s.file, s.line) }
go
func (s *stackFrame) string() string { return fmt.Sprintf("%s (%s:%d)", s.function, s.file, s.line) }
[ "func", "(", "s", "*", "stackFrame", ")", "string", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"%s (%s:%d)\"", ",", "s", ".", "function", ",", "s", ".", "file", ",", "s", ".", "line", ")", "\n", "}" ]
// string converts a given stack frame to a formated string.
[ "string", "converts", "a", "given", "stack", "frame", "to", "a", "formated", "string", "." ]
07f754d5ee02576c14a8272df820e8947d87e723
https://github.com/st3v/tracerr/blob/07f754d5ee02576c14a8272df820e8947d87e723/tracerr.go#L81-L83
test
st3v/tracerr
tracerr.go
newStackFrame
func newStackFrame(pc uintptr) *stackFrame { fn := runtime.FuncForPC(pc) file, line := fn.FileLine(pc) packagePath, funcSignature := parseFuncName(fn.Name()) _, fileName := filepath.Split(file) return &stackFrame{ file: filepath.Join(packagePath, fileName), line: line, function: funcSignature, } }
go
func newStackFrame(pc uintptr) *stackFrame { fn := runtime.FuncForPC(pc) file, line := fn.FileLine(pc) packagePath, funcSignature := parseFuncName(fn.Name()) _, fileName := filepath.Split(file) return &stackFrame{ file: filepath.Join(packagePath, fileName), line: line, function: funcSignature, } }
[ "func", "newStackFrame", "(", "pc", "uintptr", ")", "*", "stackFrame", "{", "fn", ":=", "runtime", ".", "FuncForPC", "(", "pc", ")", "\n", "file", ",", "line", ":=", "fn", ".", "FileLine", "(", "pc", ")", "\n", "packagePath", ",", "funcSignature", ":="...
// newStackFrame returns a new stack frame initialized from the passed // in program counter.
[ "newStackFrame", "returns", "a", "new", "stack", "frame", "initialized", "from", "the", "passed", "in", "program", "counter", "." ]
07f754d5ee02576c14a8272df820e8947d87e723
https://github.com/st3v/tracerr/blob/07f754d5ee02576c14a8272df820e8947d87e723/tracerr.go#L87-L98
test
st3v/tracerr
tracerr.go
captureStack
func captureStack(skip, maxDepth int) []*stackFrame { pcs := make([]uintptr, maxDepth) count := runtime.Callers(skip+1, pcs) frames := make([]*stackFrame, count) for i, pc := range pcs[0:count] { frames[i] = newStackFrame(pc) } return frames }
go
func captureStack(skip, maxDepth int) []*stackFrame { pcs := make([]uintptr, maxDepth) count := runtime.Callers(skip+1, pcs) frames := make([]*stackFrame, count) for i, pc := range pcs[0:count] { frames[i] = newStackFrame(pc) } return frames }
[ "func", "captureStack", "(", "skip", ",", "maxDepth", "int", ")", "[", "]", "*", "stackFrame", "{", "pcs", ":=", "make", "(", "[", "]", "uintptr", ",", "maxDepth", ")", "\n", "count", ":=", "runtime", ".", "Callers", "(", "skip", "+", "1", ",", "pc...
// captureStack returns a slice of stack frames representing the stack // of the calling go routine.
[ "captureStack", "returns", "a", "slice", "of", "stack", "frames", "representing", "the", "stack", "of", "the", "calling", "go", "routine", "." ]
07f754d5ee02576c14a8272df820e8947d87e723
https://github.com/st3v/tracerr/blob/07f754d5ee02576c14a8272df820e8947d87e723/tracerr.go#L102-L112
test
st3v/tracerr
tracerr.go
parseFuncName
func parseFuncName(fnName string) (packagePath, signature string) { regEx := regexp.MustCompile("([^\\(]*)\\.(.*)") parts := regEx.FindStringSubmatch(fnName) packagePath = parts[1] signature = parts[2] return }
go
func parseFuncName(fnName string) (packagePath, signature string) { regEx := regexp.MustCompile("([^\\(]*)\\.(.*)") parts := regEx.FindStringSubmatch(fnName) packagePath = parts[1] signature = parts[2] return }
[ "func", "parseFuncName", "(", "fnName", "string", ")", "(", "packagePath", ",", "signature", "string", ")", "{", "regEx", ":=", "regexp", ".", "MustCompile", "(", "\"([^\\\\(]*)\\\\.(.*)\"", ")", "\n", "\\\\", "\n", "\\\\", "\n", "parts", ":=", "regEx", ".",...
// parseFuncName returns the package path and function signature for a // give Func name.
[ "parseFuncName", "returns", "the", "package", "path", "and", "function", "signature", "for", "a", "give", "Func", "name", "." ]
07f754d5ee02576c14a8272df820e8947d87e723
https://github.com/st3v/tracerr/blob/07f754d5ee02576c14a8272df820e8947d87e723/tracerr.go#L116-L122
test
HiLittleCat/core
log/log.go
Stack
func Stack(err interface{}) { stack := make([]byte, 64<<10) stack = stack[:runtime.Stack(stack, false)] log.Printf("%v\n%s", err, stack) }
go
func Stack(err interface{}) { stack := make([]byte, 64<<10) stack = stack[:runtime.Stack(stack, false)] log.Printf("%v\n%s", err, stack) }
[ "func", "Stack", "(", "err", "interface", "{", "}", ")", "{", "stack", ":=", "make", "(", "[", "]", "byte", ",", "64", "<<", "10", ")", "\n", "stack", "=", "stack", "[", ":", "runtime", ".", "Stack", "(", "stack", ",", "false", ")", "]", "\n", ...
// Stack logs the error err with the stack trace.
[ "Stack", "logs", "the", "error", "err", "with", "the", "stack", "trace", "." ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/log/log.go#L11-L16
test
HiLittleCat/core
log/log.go
StackWithCaller
func StackWithCaller(err interface{}) { stack := make([]byte, 64<<10) stack = stack[:runtime.Stack(stack, false)] if pack, ok := callerPackage(); ok { log.Printf("%s: %v\n%s", pack, err, stack) } else { log.Printf("%v\n%s", err, stack) } }
go
func StackWithCaller(err interface{}) { stack := make([]byte, 64<<10) stack = stack[:runtime.Stack(stack, false)] if pack, ok := callerPackage(); ok { log.Printf("%s: %v\n%s", pack, err, stack) } else { log.Printf("%v\n%s", err, stack) } }
[ "func", "StackWithCaller", "(", "err", "interface", "{", "}", ")", "{", "stack", ":=", "make", "(", "[", "]", "byte", ",", "64", "<<", "10", ")", "\n", "stack", "=", "stack", "[", ":", "runtime", ".", "Stack", "(", "stack", ",", "false", ")", "]"...
// StackWithCaller logs the error err with the caller package name and the stack trace.
[ "StackWithCaller", "logs", "the", "error", "err", "with", "the", "caller", "package", "name", "and", "the", "stack", "trace", "." ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/log/log.go#L19-L28
test
HiLittleCat/core
httputil/response.go
Write
func (w responseWriterBinder) Write(p []byte) (int, error) { for _, f := range w.before { f(p) } return w.Writer.Write(p) }
go
func (w responseWriterBinder) Write(p []byte) (int, error) { for _, f := range w.before { f(p) } return w.Writer.Write(p) }
[ "func", "(", "w", "responseWriterBinder", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "for", "_", ",", "f", ":=", "range", "w", ".", "before", "{", "f", "(", "p", ")", "\n", "}", "\n", "return", "w", "."...
// Write calls the writer upstream after executing the functions in the before field.
[ "Write", "calls", "the", "writer", "upstream", "after", "executing", "the", "functions", "in", "the", "before", "field", "." ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/httputil/response.go#L20-L25
test
HiLittleCat/core
httputil/response.go
ResponseStatus
func ResponseStatus(w http.ResponseWriter) int { return int(httpResponseStruct(reflect.ValueOf(w)).FieldByName("status").Int()) }
go
func ResponseStatus(w http.ResponseWriter) int { return int(httpResponseStruct(reflect.ValueOf(w)).FieldByName("status").Int()) }
[ "func", "ResponseStatus", "(", "w", "http", ".", "ResponseWriter", ")", "int", "{", "return", "int", "(", "httpResponseStruct", "(", "reflect", ".", "ValueOf", "(", "w", ")", ")", ".", "FieldByName", "(", "\"status\"", ")", ".", "Int", "(", ")", ")", "...
// ResponseStatus returns the HTTP response status. // Remember that the status is only set by the server after WriteHeader has been called.
[ "ResponseStatus", "returns", "the", "HTTP", "response", "status", ".", "Remember", "that", "the", "status", "is", "only", "set", "by", "the", "server", "after", "WriteHeader", "has", "been", "called", "." ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/httputil/response.go#L35-L37
test
HiLittleCat/core
httputil/response.go
httpResponseStruct
func httpResponseStruct(v reflect.Value) reflect.Value { if v.Kind() == reflect.Ptr { v = v.Elem() } if v.Type().String() == "http.response" { return v } return httpResponseStruct(v.FieldByName("ResponseWriter").Elem()) }
go
func httpResponseStruct(v reflect.Value) reflect.Value { if v.Kind() == reflect.Ptr { v = v.Elem() } if v.Type().String() == "http.response" { return v } return httpResponseStruct(v.FieldByName("ResponseWriter").Elem()) }
[ "func", "httpResponseStruct", "(", "v", "reflect", ".", "Value", ")", "reflect", ".", "Value", "{", "if", "v", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "v", "=", "v", ".", "Elem", "(", ")", "\n", "}", "\n", "if", "v", ".", "Type...
// httpResponseStruct returns the response structure after going trough all the intermediary response writers.
[ "httpResponseStruct", "returns", "the", "response", "structure", "after", "going", "trough", "all", "the", "intermediary", "response", "writers", "." ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/httputil/response.go#L40-L50
test
HiLittleCat/core
httputil/response.go
SetDetectedContentType
func SetDetectedContentType(w http.ResponseWriter, p []byte) string { ct := w.Header().Get("Content-Type") if ct == "" { ct = http.DetectContentType(p) w.Header().Set("Content-Type", ct) } return ct }
go
func SetDetectedContentType(w http.ResponseWriter, p []byte) string { ct := w.Header().Get("Content-Type") if ct == "" { ct = http.DetectContentType(p) w.Header().Set("Content-Type", ct) } return ct }
[ "func", "SetDetectedContentType", "(", "w", "http", ".", "ResponseWriter", ",", "p", "[", "]", "byte", ")", "string", "{", "ct", ":=", "w", ".", "Header", "(", ")", ".", "Get", "(", "\"Content-Type\"", ")", "\n", "if", "ct", "==", "\"\"", "{", "ct", ...
// SetDetectedContentType detects, sets and returns the response Conten-Type header value.
[ "SetDetectedContentType", "detects", "sets", "and", "returns", "the", "response", "Conten", "-", "Type", "header", "value", "." ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/httputil/response.go#L53-L60
test
HiLittleCat/core
errors.go
New
func (e *ServerError) New(message string) *ServerError { e.HTTPCode = http.StatusInternalServerError e.Errno = 0 e.Message = message return e }
go
func (e *ServerError) New(message string) *ServerError { e.HTTPCode = http.StatusInternalServerError e.Errno = 0 e.Message = message return e }
[ "func", "(", "e", "*", "ServerError", ")", "New", "(", "message", "string", ")", "*", "ServerError", "{", "e", ".", "HTTPCode", "=", "http", ".", "StatusInternalServerError", "\n", "e", ".", "Errno", "=", "0", "\n", "e", ".", "Message", "=", "message",...
// New ServerError.New
[ "New", "ServerError", ".", "New" ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/errors.go#L50-L55
test
HiLittleCat/core
errors.go
New
func (e *DBError) New(dbName string, message string) *DBError { e.HTTPCode = http.StatusInternalServerError e.Errno = 0 e.Message = message e.DBName = dbName return e }
go
func (e *DBError) New(dbName string, message string) *DBError { e.HTTPCode = http.StatusInternalServerError e.Errno = 0 e.Message = message e.DBName = dbName return e }
[ "func", "(", "e", "*", "DBError", ")", "New", "(", "dbName", "string", ",", "message", "string", ")", "*", "DBError", "{", "e", ".", "HTTPCode", "=", "http", ".", "StatusInternalServerError", "\n", "e", ".", "Errno", "=", "0", "\n", "e", ".", "Messag...
// New DBError.New
[ "New", "DBError", ".", "New" ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/errors.go#L77-L83
test
HiLittleCat/core
errors.go
New
func (e *ValidationError) New(message string) *ValidationError { e.HTTPCode = http.StatusBadRequest e.Errno = 0 e.Message = message return e }
go
func (e *ValidationError) New(message string) *ValidationError { e.HTTPCode = http.StatusBadRequest e.Errno = 0 e.Message = message return e }
[ "func", "(", "e", "*", "ValidationError", ")", "New", "(", "message", "string", ")", "*", "ValidationError", "{", "e", ".", "HTTPCode", "=", "http", ".", "StatusBadRequest", "\n", "e", ".", "Errno", "=", "0", "\n", "e", ".", "Message", "=", "message", ...
// New ValidationError.New
[ "New", "ValidationError", ".", "New" ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/errors.go#L91-L96
test
HiLittleCat/core
errors.go
New
func (e *NotFoundError) New(message string) *NotFoundError { e.HTTPCode = http.StatusNotFound e.Errno = 0 e.Message = message return e }
go
func (e *NotFoundError) New(message string) *NotFoundError { e.HTTPCode = http.StatusNotFound e.Errno = 0 e.Message = message return e }
[ "func", "(", "e", "*", "NotFoundError", ")", "New", "(", "message", "string", ")", "*", "NotFoundError", "{", "e", ".", "HTTPCode", "=", "http", ".", "StatusNotFound", "\n", "e", ".", "Errno", "=", "0", "\n", "e", ".", "Message", "=", "message", "\n"...
// New NotFoundError.New
[ "New", "NotFoundError", ".", "New" ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/errors.go#L104-L109
test
HiLittleCat/core
controller.go
StrLength
func (c *Controller) StrLength(fieldName string, p interface{}, n int) string { if p == nil { p = "" } v, ok := p.(string) if ok == false { panic((&ValidationError{}).New(fieldName + "长度应该为" + strconv.Itoa(n))) } b := c.Validate.Length(v, n) if b == false { panic((&ValidationError{}).New(fieldName + "长度应该为...
go
func (c *Controller) StrLength(fieldName string, p interface{}, n int) string { if p == nil { p = "" } v, ok := p.(string) if ok == false { panic((&ValidationError{}).New(fieldName + "长度应该为" + strconv.Itoa(n))) } b := c.Validate.Length(v, n) if b == false { panic((&ValidationError{}).New(fieldName + "长度应该为...
[ "func", "(", "c", "*", "Controller", ")", "StrLength", "(", "fieldName", "string", ",", "p", "interface", "{", "}", ",", "n", "int", ")", "string", "{", "if", "p", "==", "nil", "{", "p", "=", "\"\"", "\n", "}", "\n", "v", ",", "ok", ":=", "p", ...
// StrLength param is a string, length must be n
[ "StrLength", "param", "is", "a", "string", "length", "must", "be", "n" ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/controller.go#L154-L167
test
HiLittleCat/core
controller.go
StrLenIn
func (c *Controller) StrLenIn(fieldName string, p interface{}, l ...int) string { if p == nil { p = "" } v, ok := p.(string) if ok == false { panic((&ValidationError{}).New(fieldName + "格式错误")) } length := utf8.RuneCountInString(v) b := false for i := 0; i < len(l); i++ { if l[i] == length { b = true ...
go
func (c *Controller) StrLenIn(fieldName string, p interface{}, l ...int) string { if p == nil { p = "" } v, ok := p.(string) if ok == false { panic((&ValidationError{}).New(fieldName + "格式错误")) } length := utf8.RuneCountInString(v) b := false for i := 0; i < len(l); i++ { if l[i] == length { b = true ...
[ "func", "(", "c", "*", "Controller", ")", "StrLenIn", "(", "fieldName", "string", ",", "p", "interface", "{", "}", ",", "l", "...", "int", ")", "string", "{", "if", "p", "==", "nil", "{", "p", "=", "\"\"", "\n", "}", "\n", "v", ",", "ok", ":=",...
// StrLenIn param is a string, length is in array
[ "StrLenIn", "param", "is", "a", "string", "length", "is", "in", "array" ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/controller.go#L186-L205
test
HiLittleCat/core
controller.go
StrIn
func (c *Controller) StrIn(fieldName string, p interface{}, l ...string) string { if p == nil { p = "" } v, ok := p.(string) if ok == false { panic((&ValidationError{}).New(fieldName + "格式错误")) } b := false for i := 0; i < len(l); i++ { if l[i] == v { b = true } } if b == false { panic((&Validatio...
go
func (c *Controller) StrIn(fieldName string, p interface{}, l ...string) string { if p == nil { p = "" } v, ok := p.(string) if ok == false { panic((&ValidationError{}).New(fieldName + "格式错误")) } b := false for i := 0; i < len(l); i++ { if l[i] == v { b = true } } if b == false { panic((&Validatio...
[ "func", "(", "c", "*", "Controller", ")", "StrIn", "(", "fieldName", "string", ",", "p", "interface", "{", "}", ",", "l", "...", "string", ")", "string", "{", "if", "p", "==", "nil", "{", "p", "=", "\"\"", "\n", "}", "\n", "v", ",", "ok", ":=",...
// StrIn param is a string, the string is in array
[ "StrIn", "param", "is", "a", "string", "the", "string", "is", "in", "array" ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/controller.go#L208-L226
test
HiLittleCat/core
controller.go
GetEmail
func (c *Controller) GetEmail(fieldName string, p interface{}) string { if p == nil { p = "" } v, ok := p.(string) if ok == false { panic((&ValidationError{}).New(fieldName + "格式错误")) } b := c.Validate.Email(v) if b == false { panic((&ValidationError{}).New(fieldName + "格式错误")) } return v }
go
func (c *Controller) GetEmail(fieldName string, p interface{}) string { if p == nil { p = "" } v, ok := p.(string) if ok == false { panic((&ValidationError{}).New(fieldName + "格式错误")) } b := c.Validate.Email(v) if b == false { panic((&ValidationError{}).New(fieldName + "格式错误")) } return v }
[ "func", "(", "c", "*", "Controller", ")", "GetEmail", "(", "fieldName", "string", ",", "p", "interface", "{", "}", ")", "string", "{", "if", "p", "==", "nil", "{", "p", "=", "\"\"", "\n", "}", "\n", "v", ",", "ok", ":=", "p", ".", "(", "string"...
// GetEmail check is a email
[ "GetEmail", "check", "is", "a", "email" ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/controller.go#L229-L242
test
Financial-Times/neo-model-utils-go
mapper/types.go
MostSpecificType
func MostSpecificType(types []string) (string, error) { if len(types) == 0 { return "", errors.New("no types supplied") } sorted, err := SortTypes(types) if err != nil { return "", err } return sorted[len(sorted)-1], nil }
go
func MostSpecificType(types []string) (string, error) { if len(types) == 0 { return "", errors.New("no types supplied") } sorted, err := SortTypes(types) if err != nil { return "", err } return sorted[len(sorted)-1], nil }
[ "func", "MostSpecificType", "(", "types", "[", "]", "string", ")", "(", "string", ",", "error", ")", "{", "if", "len", "(", "types", ")", "==", "0", "{", "return", "\"\"", ",", "errors", ".", "New", "(", "\"no types supplied\"", ")", "\n", "}", "\n",...
// MostSpecific returns the most specific from a list of types in an hierarchy // behaviour is undefined if any of the types are siblings.
[ "MostSpecific", "returns", "the", "most", "specific", "from", "a", "list", "of", "types", "in", "an", "hierarchy", "behaviour", "is", "undefined", "if", "any", "of", "the", "types", "are", "siblings", "." ]
aea1e95c83055aaed6761c5e546400dd383fb220
https://github.com/Financial-Times/neo-model-utils-go/blob/aea1e95c83055aaed6761c5e546400dd383fb220/mapper/types.go#L51-L60
test
Financial-Times/neo-model-utils-go
mapper/types.go
FullTypeHierarchy
func FullTypeHierarchy(highestLevelType string) []string { var typeHierarchy []string t := strings.Split(highestLevelType, "/") typeToCheck := t[len(t)-1] for { typeHierarchy = append(typeHierarchy, typeToCheck) parentType := ParentType(typeToCheck) if parentType != "" { typeToCheck = parentType } else {...
go
func FullTypeHierarchy(highestLevelType string) []string { var typeHierarchy []string t := strings.Split(highestLevelType, "/") typeToCheck := t[len(t)-1] for { typeHierarchy = append(typeHierarchy, typeToCheck) parentType := ParentType(typeToCheck) if parentType != "" { typeToCheck = parentType } else {...
[ "func", "FullTypeHierarchy", "(", "highestLevelType", "string", ")", "[", "]", "string", "{", "var", "typeHierarchy", "[", "]", "string", "\n", "t", ":=", "strings", ".", "Split", "(", "highestLevelType", ",", "\"/\"", ")", "\n", "typeToCheck", ":=", "t", ...
//Full type hierarchy is returned when provided either the concept type // or full uri of the most specific concept type
[ "Full", "type", "hierarchy", "is", "returned", "when", "provided", "either", "the", "concept", "type", "or", "full", "uri", "of", "the", "most", "specific", "concept", "type" ]
aea1e95c83055aaed6761c5e546400dd383fb220
https://github.com/Financial-Times/neo-model-utils-go/blob/aea1e95c83055aaed6761c5e546400dd383fb220/mapper/types.go#L64-L78
test
Financial-Times/neo-model-utils-go
mapper/types.go
SortTypes
func SortTypes(types []string) ([]string, error) { ts := &typeSorter{types: make([]string, len(types))} copy(ts.types, types) sort.Sort(ts) if ts.invalid { return types, ErrNotHierarchy } return ts.types, nil }
go
func SortTypes(types []string) ([]string, error) { ts := &typeSorter{types: make([]string, len(types))} copy(ts.types, types) sort.Sort(ts) if ts.invalid { return types, ErrNotHierarchy } return ts.types, nil }
[ "func", "SortTypes", "(", "types", "[", "]", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "ts", ":=", "&", "typeSorter", "{", "types", ":", "make", "(", "[", "]", "string", ",", "len", "(", "types", ")", ")", "}", "\n", "copy...
// SortTypes sorts the given types from least specific to most specific
[ "SortTypes", "sorts", "the", "given", "types", "from", "least", "specific", "to", "most", "specific" ]
aea1e95c83055aaed6761c5e546400dd383fb220
https://github.com/Financial-Times/neo-model-utils-go/blob/aea1e95c83055aaed6761c5e546400dd383fb220/mapper/types.go#L83-L91
test
HiLittleCat/core
store.go
Delete
func (rs *redisStore) Delete(key string) error { delete(rs.Values, key) err := provider.refresh(rs) return err }
go
func (rs *redisStore) Delete(key string) error { delete(rs.Values, key) err := provider.refresh(rs) return err }
[ "func", "(", "rs", "*", "redisStore", ")", "Delete", "(", "key", "string", ")", "error", "{", "delete", "(", "rs", ".", "Values", ",", "key", ")", "\n", "err", ":=", "provider", ".", "refresh", "(", "rs", ")", "\n", "return", "err", "\n", "}" ]
// Delete value in redis session
[ "Delete", "value", "in", "redis", "session" ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/store.go#L47-L51
test
HiLittleCat/core
store.go
Set
func (rp *redisProvider) Set(key string, values map[string]string) (*redisStore, error) { rs := &redisStore{SID: key, Values: values} err := provider.refresh(rs) return rs, err }
go
func (rp *redisProvider) Set(key string, values map[string]string) (*redisStore, error) { rs := &redisStore{SID: key, Values: values} err := provider.refresh(rs) return rs, err }
[ "func", "(", "rp", "*", "redisProvider", ")", "Set", "(", "key", "string", ",", "values", "map", "[", "string", "]", "string", ")", "(", "*", "redisStore", ",", "error", ")", "{", "rs", ":=", "&", "redisStore", "{", "SID", ":", "key", ",", "Values"...
// Set value in redis session
[ "Set", "value", "in", "redis", "session" ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/store.go#L63-L67
test
HiLittleCat/core
store.go
refresh
func (rp *redisProvider) refresh(rs *redisStore) error { var err error redisPool.Exec(func(c *redis.Client) { err = c.HMSet(rs.SID, rs.Values).Err() if err != nil { return } err = c.Expire(rs.SID, sessExpire).Err() }) return nil }
go
func (rp *redisProvider) refresh(rs *redisStore) error { var err error redisPool.Exec(func(c *redis.Client) { err = c.HMSet(rs.SID, rs.Values).Err() if err != nil { return } err = c.Expire(rs.SID, sessExpire).Err() }) return nil }
[ "func", "(", "rp", "*", "redisProvider", ")", "refresh", "(", "rs", "*", "redisStore", ")", "error", "{", "var", "err", "error", "\n", "redisPool", ".", "Exec", "(", "func", "(", "c", "*", "redis", ".", "Client", ")", "{", "err", "=", "c", ".", "...
// refresh refresh store to redis
[ "refresh", "refresh", "store", "to", "redis" ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/store.go#L70-L80
test
HiLittleCat/core
store.go
Get
func (rp *redisProvider) Get(sid string) (*redisStore, error) { var rs = &redisStore{} var val map[string]string var err error redisPool.Exec(func(c *redis.Client) { val, err = c.HGetAll(sid).Result() rs.Values = val }) return rs, err }
go
func (rp *redisProvider) Get(sid string) (*redisStore, error) { var rs = &redisStore{} var val map[string]string var err error redisPool.Exec(func(c *redis.Client) { val, err = c.HGetAll(sid).Result() rs.Values = val }) return rs, err }
[ "func", "(", "rp", "*", "redisProvider", ")", "Get", "(", "sid", "string", ")", "(", "*", "redisStore", ",", "error", ")", "{", "var", "rs", "=", "&", "redisStore", "{", "}", "\n", "var", "val", "map", "[", "string", "]", "string", "\n", "var", "...
// Get read redis session by sid
[ "Get", "read", "redis", "session", "by", "sid" ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/store.go#L83-L92
test
HiLittleCat/core
store.go
Destroy
func (rp *redisProvider) Destroy(sid string) error { var err error redisPool.Exec(func(c *redis.Client) { err = c.Del(sid).Err() }) return err }
go
func (rp *redisProvider) Destroy(sid string) error { var err error redisPool.Exec(func(c *redis.Client) { err = c.Del(sid).Err() }) return err }
[ "func", "(", "rp", "*", "redisProvider", ")", "Destroy", "(", "sid", "string", ")", "error", "{", "var", "err", "error", "\n", "redisPool", ".", "Exec", "(", "func", "(", "c", "*", "redis", ".", "Client", ")", "{", "err", "=", "c", ".", "Del", "(...
// Destroy delete redis session by id
[ "Destroy", "delete", "redis", "session", "by", "id" ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/store.go#L95-L101
test
HiLittleCat/core
store.go
UpExpire
func (rp *redisProvider) UpExpire(sid string) error { var err error redisPool.Exec(func(c *redis.Client) { err = c.Expire(sid, sessExpire).Err() }) return err }
go
func (rp *redisProvider) UpExpire(sid string) error { var err error redisPool.Exec(func(c *redis.Client) { err = c.Expire(sid, sessExpire).Err() }) return err }
[ "func", "(", "rp", "*", "redisProvider", ")", "UpExpire", "(", "sid", "string", ")", "error", "{", "var", "err", "error", "\n", "redisPool", ".", "Exec", "(", "func", "(", "c", "*", "redis", ".", "Client", ")", "{", "err", "=", "c", ".", "Expire", ...
// UpExpire refresh session expire
[ "UpExpire", "refresh", "session", "expire" ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/store.go#L104-L110
test
HiLittleCat/core
handler.go
Use
func (hs *HandlersStack) Use(h RouterHandler) { hs.Handlers = append(hs.Handlers, h) }
go
func (hs *HandlersStack) Use(h RouterHandler) { hs.Handlers = append(hs.Handlers, h) }
[ "func", "(", "hs", "*", "HandlersStack", ")", "Use", "(", "h", "RouterHandler", ")", "{", "hs", ".", "Handlers", "=", "append", "(", "hs", ".", "Handlers", ",", "h", ")", "\n", "}" ]
// Use adds a handler to the handlers stack.
[ "Use", "adds", "a", "handler", "to", "the", "handlers", "stack", "." ]
ae2101184ecd36354d3fcff0ea69d67d3fdbe156
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/handler.go#L22-L24
test