id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
137,600 | guelfey/go.dbus | conn.go | outWorker | func (conn *Conn) outWorker() {
for msg := range conn.out {
err := conn.SendMessage(msg)
conn.callsLck.RLock()
if err != nil {
if c := conn.calls[msg.serial]; c != nil {
c.Err = err
c.Done <- c
}
conn.serialLck.Lock()
delete(conn.serialUsed, msg.serial)
conn.serialLck.Unlock()
} else if ... | go | func (conn *Conn) outWorker() {
for msg := range conn.out {
err := conn.SendMessage(msg)
conn.callsLck.RLock()
if err != nil {
if c := conn.calls[msg.serial]; c != nil {
c.Err = err
c.Done <- c
}
conn.serialLck.Lock()
delete(conn.serialUsed, msg.serial)
conn.serialLck.Unlock()
} else if ... | [
"func",
"(",
"conn",
"*",
"Conn",
")",
"outWorker",
"(",
")",
"{",
"for",
"msg",
":=",
"range",
"conn",
".",
"out",
"{",
"err",
":=",
"conn",
".",
"SendMessage",
"(",
"msg",
")",
"\n",
"conn",
".",
"callsLck",
".",
"RLock",
"(",
")",
"\n",
"if",
... | // outWorker runs in an own goroutine, encoding and sending messages that are
// sent to conn.out. | [
"outWorker",
"runs",
"in",
"an",
"own",
"goroutine",
"encoding",
"and",
"sending",
"messages",
"that",
"are",
"sent",
"to",
"conn",
".",
"out",
"."
] | f6a3a2366cc39b8479cadc499d3c735fb10fbdda | https://github.com/guelfey/go.dbus/blob/f6a3a2366cc39b8479cadc499d3c735fb10fbdda/conn.go#L366-L385 |
137,601 | guelfey/go.dbus | conn.go | Signal | func (conn *Conn) Signal(ch chan<- *Signal) {
conn.signalsLck.Lock()
conn.signals = append(conn.signals, ch)
conn.signalsLck.Unlock()
} | go | func (conn *Conn) Signal(ch chan<- *Signal) {
conn.signalsLck.Lock()
conn.signals = append(conn.signals, ch)
conn.signalsLck.Unlock()
} | [
"func",
"(",
"conn",
"*",
"Conn",
")",
"Signal",
"(",
"ch",
"chan",
"<-",
"*",
"Signal",
")",
"{",
"conn",
".",
"signalsLck",
".",
"Lock",
"(",
")",
"\n",
"conn",
".",
"signals",
"=",
"append",
"(",
"conn",
".",
"signals",
",",
"ch",
")",
"\n",
... | // Signal registers the given channel to be passed all received signal messages.
// The caller has to make sure that ch is sufficiently buffered; if a message
// arrives when a write to c is not possible, it is discarded.
//
// Multiple of these channels can be registered at the same time. Passing a
// channel that alr... | [
"Signal",
"registers",
"the",
"given",
"channel",
"to",
"be",
"passed",
"all",
"received",
"signal",
"messages",
".",
"The",
"caller",
"has",
"to",
"make",
"sure",
"that",
"ch",
"is",
"sufficiently",
"buffered",
";",
"if",
"a",
"message",
"arrives",
"when",
... | f6a3a2366cc39b8479cadc499d3c735fb10fbdda | https://github.com/guelfey/go.dbus/blob/f6a3a2366cc39b8479cadc499d3c735fb10fbdda/conn.go#L487-L491 |
137,602 | sethgrid/curse | curse.go | GetScreenDimensions | func GetScreenDimensions() (cols int, lines int, err error) {
ws, err := unix.IoctlGetWinsize(0, unix.TIOCGWINSZ)
if err != nil {
return -1, -1, err
}
return int(ws.Col), int(ws.Row), nil
} | go | func GetScreenDimensions() (cols int, lines int, err error) {
ws, err := unix.IoctlGetWinsize(0, unix.TIOCGWINSZ)
if err != nil {
return -1, -1, err
}
return int(ws.Col), int(ws.Row), nil
} | [
"func",
"GetScreenDimensions",
"(",
")",
"(",
"cols",
"int",
",",
"lines",
"int",
",",
"err",
"error",
")",
"{",
"ws",
",",
"err",
":=",
"unix",
".",
"IoctlGetWinsize",
"(",
"0",
",",
"unix",
".",
"TIOCGWINSZ",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // using named returns to help when using the method to know what is what | [
"using",
"named",
"returns",
"to",
"help",
"when",
"using",
"the",
"method",
"to",
"know",
"what",
"is",
"what"
] | d4ee583ebf0f588f3594a262c5e2726ddebda2cc | https://github.com/sethgrid/curse/blob/d4ee583ebf0f588f3594a262c5e2726ddebda2cc/curse.go#L146-L152 |
137,603 | patrickmn/sortutil | getter.go | SimpleGetter | func SimpleGetter() Getter {
return func(s reflect.Value) []reflect.Value {
vals := valueSlice(s.Len())
for i := range vals {
vals[i] = reflect.Indirect(reflect.Indirect(s.Index(i)))
}
return vals
}
} | go | func SimpleGetter() Getter {
return func(s reflect.Value) []reflect.Value {
vals := valueSlice(s.Len())
for i := range vals {
vals[i] = reflect.Indirect(reflect.Indirect(s.Index(i)))
}
return vals
}
} | [
"func",
"SimpleGetter",
"(",
")",
"Getter",
"{",
"return",
"func",
"(",
"s",
"reflect",
".",
"Value",
")",
"[",
"]",
"reflect",
".",
"Value",
"{",
"vals",
":=",
"valueSlice",
"(",
"s",
".",
"Len",
"(",
")",
")",
"\n",
"for",
"i",
":=",
"range",
"... | // Returns a Getter which returns the values from a reflect.Value for a
// slice. This is the default Getter used if none is passed to Sort. | [
"Returns",
"a",
"Getter",
"which",
"returns",
"the",
"values",
"from",
"a",
"reflect",
".",
"Value",
"for",
"a",
"slice",
".",
"This",
"is",
"the",
"default",
"Getter",
"used",
"if",
"none",
"is",
"passed",
"to",
"Sort",
"."
] | abeda66eb583fac2d8d98d3d2e6fbd5c67af7947 | https://github.com/patrickmn/sortutil/blob/abeda66eb583fac2d8d98d3d2e6fbd5c67af7947/getter.go#L20-L28 |
137,604 | patrickmn/sortutil | sortutil.go | Swap | func (s *Sorter) Swap(i, j int) {
x := s.Slice.Index(i)
y := s.Slice.Index(j)
tmp := reflect.New(s.itemType).Elem()
tmp.Set(x)
x.Set(y)
y.Set(tmp)
} | go | func (s *Sorter) Swap(i, j int) {
x := s.Slice.Index(i)
y := s.Slice.Index(j)
tmp := reflect.New(s.itemType).Elem()
tmp.Set(x)
x.Set(y)
y.Set(tmp)
} | [
"func",
"(",
"s",
"*",
"Sorter",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"x",
":=",
"s",
".",
"Slice",
".",
"Index",
"(",
"i",
")",
"\n",
"y",
":=",
"s",
".",
"Slice",
".",
"Index",
"(",
"j",
")",
"\n",
"tmp",
":=",
"reflect",
"... | // Swaps two indices in the slice being sorted. | [
"Swaps",
"two",
"indices",
"in",
"the",
"slice",
"being",
"sorted",
"."
] | abeda66eb583fac2d8d98d3d2e6fbd5c67af7947 | https://github.com/patrickmn/sortutil/blob/abeda66eb583fac2d8d98d3d2e6fbd5c67af7947/sortutil.go#L147-L154 |
137,605 | patrickmn/sortutil | sortutil.go | New | func New(slice interface{}, getter Getter, ordering Ordering) *Sorter {
v := reflect.ValueOf(slice)
return &Sorter{
Slice: v,
Getter: getter,
Ordering: ordering,
}
} | go | func New(slice interface{}, getter Getter, ordering Ordering) *Sorter {
v := reflect.ValueOf(slice)
return &Sorter{
Slice: v,
Getter: getter,
Ordering: ordering,
}
} | [
"func",
"New",
"(",
"slice",
"interface",
"{",
"}",
",",
"getter",
"Getter",
",",
"ordering",
"Ordering",
")",
"*",
"Sorter",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"slice",
")",
"\n",
"return",
"&",
"Sorter",
"{",
"Slice",
":",
"v",
",",
... | // Returns a Sorter for a slice which will sort according to the
// items retrieved by getter, in the given ordering. | [
"Returns",
"a",
"Sorter",
"for",
"a",
"slice",
"which",
"will",
"sort",
"according",
"to",
"the",
"items",
"retrieved",
"by",
"getter",
"in",
"the",
"given",
"ordering",
"."
] | abeda66eb583fac2d8d98d3d2e6fbd5c67af7947 | https://github.com/patrickmn/sortutil/blob/abeda66eb583fac2d8d98d3d2e6fbd5c67af7947/sortutil.go#L232-L239 |
137,606 | patrickmn/sortutil | sortutil.go | AscByField | func AscByField(slice interface{}, name string) {
New(slice, FieldGetter(name), Ascending).Sort()
} | go | func AscByField(slice interface{}, name string) {
New(slice, FieldGetter(name), Ascending).Sort()
} | [
"func",
"AscByField",
"(",
"slice",
"interface",
"{",
"}",
",",
"name",
"string",
")",
"{",
"New",
"(",
"slice",
",",
"FieldGetter",
"(",
"name",
")",
",",
"Ascending",
")",
".",
"Sort",
"(",
")",
"\n",
"}"
] | // Sort a slice in ascending order by a field name. | [
"Sort",
"a",
"slice",
"in",
"ascending",
"order",
"by",
"a",
"field",
"name",
"."
] | abeda66eb583fac2d8d98d3d2e6fbd5c67af7947 | https://github.com/patrickmn/sortutil/blob/abeda66eb583fac2d8d98d3d2e6fbd5c67af7947/sortutil.go#L272-L274 |
137,607 | patrickmn/sortutil | sortutil.go | DescByField | func DescByField(slice interface{}, name string) {
New(slice, FieldGetter(name), Descending).Sort()
} | go | func DescByField(slice interface{}, name string) {
New(slice, FieldGetter(name), Descending).Sort()
} | [
"func",
"DescByField",
"(",
"slice",
"interface",
"{",
"}",
",",
"name",
"string",
")",
"{",
"New",
"(",
"slice",
",",
"FieldGetter",
"(",
"name",
")",
",",
"Descending",
")",
".",
"Sort",
"(",
")",
"\n",
"}"
] | // Sort a slice in descending order by a field name. | [
"Sort",
"a",
"slice",
"in",
"descending",
"order",
"by",
"a",
"field",
"name",
"."
] | abeda66eb583fac2d8d98d3d2e6fbd5c67af7947 | https://github.com/patrickmn/sortutil/blob/abeda66eb583fac2d8d98d3d2e6fbd5c67af7947/sortutil.go#L277-L279 |
137,608 | patrickmn/sortutil | sortutil.go | AscByIndex | func AscByIndex(slice interface{}, index int) {
New(slice, IndexGetter(index), Ascending).Sort()
} | go | func AscByIndex(slice interface{}, index int) {
New(slice, IndexGetter(index), Ascending).Sort()
} | [
"func",
"AscByIndex",
"(",
"slice",
"interface",
"{",
"}",
",",
"index",
"int",
")",
"{",
"New",
"(",
"slice",
",",
"IndexGetter",
"(",
"index",
")",
",",
"Ascending",
")",
".",
"Sort",
"(",
")",
"\n",
"}"
] | // Sort a slice in ascending order by an index in a child slice. | [
"Sort",
"a",
"slice",
"in",
"ascending",
"order",
"by",
"an",
"index",
"in",
"a",
"child",
"slice",
"."
] | abeda66eb583fac2d8d98d3d2e6fbd5c67af7947 | https://github.com/patrickmn/sortutil/blob/abeda66eb583fac2d8d98d3d2e6fbd5c67af7947/sortutil.go#L324-L326 |
137,609 | patrickmn/sortutil | sortutil.go | DescByIndex | func DescByIndex(slice interface{}, index int) {
New(slice, IndexGetter(index), Descending).Sort()
} | go | func DescByIndex(slice interface{}, index int) {
New(slice, IndexGetter(index), Descending).Sort()
} | [
"func",
"DescByIndex",
"(",
"slice",
"interface",
"{",
"}",
",",
"index",
"int",
")",
"{",
"New",
"(",
"slice",
",",
"IndexGetter",
"(",
"index",
")",
",",
"Descending",
")",
".",
"Sort",
"(",
")",
"\n",
"}"
] | // Sort a slice in descending order by an index in a child slice. | [
"Sort",
"a",
"slice",
"in",
"descending",
"order",
"by",
"an",
"index",
"in",
"a",
"child",
"slice",
"."
] | abeda66eb583fac2d8d98d3d2e6fbd5c67af7947 | https://github.com/patrickmn/sortutil/blob/abeda66eb583fac2d8d98d3d2e6fbd5c67af7947/sortutil.go#L329-L331 |
137,610 | patrickmn/sortutil | sortutil.go | Reverse | func Reverse(slice interface{}) {
s := reverser{New(slice, nil, 0)}
if s.Len() < 2 {
return
}
s.itemType = s.Slice.Index(0).Type()
ReverseInterface(s)
} | go | func Reverse(slice interface{}) {
s := reverser{New(slice, nil, 0)}
if s.Len() < 2 {
return
}
s.itemType = s.Slice.Index(0).Type()
ReverseInterface(s)
} | [
"func",
"Reverse",
"(",
"slice",
"interface",
"{",
"}",
")",
"{",
"s",
":=",
"reverser",
"{",
"New",
"(",
"slice",
",",
"nil",
",",
"0",
")",
"}",
"\n",
"if",
"s",
".",
"Len",
"(",
")",
"<",
"2",
"{",
"return",
"\n",
"}",
"\n",
"s",
".",
"i... | // Reverse a slice. | [
"Reverse",
"a",
"slice",
"."
] | abeda66eb583fac2d8d98d3d2e6fbd5c67af7947 | https://github.com/patrickmn/sortutil/blob/abeda66eb583fac2d8d98d3d2e6fbd5c67af7947/sortutil.go#L346-L353 |
137,611 | patrickmn/sortutil | sortutil.go | ReverseInterface | func ReverseInterface(s sort.Interface) {
for i, j := 0, s.Len()-1; i < j; i, j = i+1, j-1 {
s.Swap(i, j)
}
} | go | func ReverseInterface(s sort.Interface) {
for i, j := 0, s.Len()-1; i < j; i, j = i+1, j-1 {
s.Swap(i, j)
}
} | [
"func",
"ReverseInterface",
"(",
"s",
"sort",
".",
"Interface",
")",
"{",
"for",
"i",
",",
"j",
":=",
"0",
",",
"s",
".",
"Len",
"(",
")",
"-",
"1",
";",
"i",
"<",
"j",
";",
"i",
",",
"j",
"=",
"i",
"+",
"1",
",",
"j",
"-",
"1",
"{",
"s... | // Reverse a type which implements sort.Interface. | [
"Reverse",
"a",
"type",
"which",
"implements",
"sort",
".",
"Interface",
"."
] | abeda66eb583fac2d8d98d3d2e6fbd5c67af7947 | https://github.com/patrickmn/sortutil/blob/abeda66eb583fac2d8d98d3d2e6fbd5c67af7947/sortutil.go#L356-L360 |
137,612 | LindsayBradford/go-dbf | godbf/dbftable.go | New | func New(encoding string) (table *DbfTable) {
// Create and populate DbaseTable struct
dt := new(DbfTable)
dt.fileEncoding = encoding
dt.encoder = mahonia.NewEncoder(encoding)
dt.decoder = mahonia.NewDecoder(encoding)
// set whether or not this table has been created from scratch
dt.createdFromScratch = true
... | go | func New(encoding string) (table *DbfTable) {
// Create and populate DbaseTable struct
dt := new(DbfTable)
dt.fileEncoding = encoding
dt.encoder = mahonia.NewEncoder(encoding)
dt.decoder = mahonia.NewDecoder(encoding)
// set whether or not this table has been created from scratch
dt.createdFromScratch = true
... | [
"func",
"New",
"(",
"encoding",
"string",
")",
"(",
"table",
"*",
"DbfTable",
")",
"{",
"// Create and populate DbaseTable struct",
"dt",
":=",
"new",
"(",
"DbfTable",
")",
"\n\n",
"dt",
".",
"fileEncoding",
"=",
"encoding",
"\n",
"dt",
".",
"encoder",
"=",
... | // New creates a new dbase table from scratch for the given character encoding | [
"New",
"creates",
"a",
"new",
"dbase",
"table",
"from",
"scratch",
"for",
"the",
"given",
"character",
"encoding"
] | 5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f | https://github.com/LindsayBradford/go-dbf/blob/5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f/godbf/dbftable.go#L59-L127 |
137,613 | LindsayBradford/go-dbf | godbf/dbftable.go | FieldNames | func (dt *DbfTable) FieldNames() []string {
names := make([]string, 0)
for _, field := range dt.Fields() {
names = append(names, field.name)
}
return names
} | go | func (dt *DbfTable) FieldNames() []string {
names := make([]string, 0)
for _, field := range dt.Fields() {
names = append(names, field.name)
}
return names
} | [
"func",
"(",
"dt",
"*",
"DbfTable",
")",
"FieldNames",
"(",
")",
"[",
"]",
"string",
"{",
"names",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n\n",
"for",
"_",
",",
"field",
":=",
"range",
"dt",
".",
"Fields",
"(",
")",
"{",
"names... | // FieldNames return the names of fields in the table as a slice | [
"FieldNames",
"return",
"the",
"names",
"of",
"fields",
"in",
"the",
"table",
"as",
"a",
"slice"
] | 5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f | https://github.com/LindsayBradford/go-dbf/blob/5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f/godbf/dbftable.go#L284-L292 |
137,614 | LindsayBradford/go-dbf | godbf/dbftable.go | HasField | func (dt *DbfTable) HasField(fieldName string) bool {
for i := 0; i < len(dt.fields); i++ {
if dt.fields[i].name == fieldName {
return true
}
}
return false
} | go | func (dt *DbfTable) HasField(fieldName string) bool {
for i := 0; i < len(dt.fields); i++ {
if dt.fields[i].name == fieldName {
return true
}
}
return false
} | [
"func",
"(",
"dt",
"*",
"DbfTable",
")",
"HasField",
"(",
"fieldName",
"string",
")",
"bool",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"dt",
".",
"fields",
")",
";",
"i",
"++",
"{",
"if",
"dt",
".",
"fields",
"[",
"i",
"]",
".",... | // HasField returns true if the table has a field with the given name
// If the field does not exist an error is returned. | [
"HasField",
"returns",
"true",
"if",
"the",
"table",
"has",
"a",
"field",
"with",
"the",
"given",
"name",
"If",
"the",
"field",
"does",
"not",
"exist",
"an",
"error",
"is",
"returned",
"."
] | 5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f | https://github.com/LindsayBradford/go-dbf/blob/5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f/godbf/dbftable.go#L296-L305 |
137,615 | LindsayBradford/go-dbf | godbf/dbftable.go | DecimalPlacesInField | func (dt *DbfTable) DecimalPlacesInField(fieldName string) (uint8, error) {
if !dt.HasField(fieldName) {
return 0, errors.New("Field name \"" + fieldName + "\" does not exist. ")
}
for i := 0; i < len(dt.fields); i++ {
if dt.fields[i].name == fieldName && dt.fields[i].usesDecimalPlaces() {
return dt.fields[i... | go | func (dt *DbfTable) DecimalPlacesInField(fieldName string) (uint8, error) {
if !dt.HasField(fieldName) {
return 0, errors.New("Field name \"" + fieldName + "\" does not exist. ")
}
for i := 0; i < len(dt.fields); i++ {
if dt.fields[i].name == fieldName && dt.fields[i].usesDecimalPlaces() {
return dt.fields[i... | [
"func",
"(",
"dt",
"*",
"DbfTable",
")",
"DecimalPlacesInField",
"(",
"fieldName",
"string",
")",
"(",
"uint8",
",",
"error",
")",
"{",
"if",
"!",
"dt",
".",
"HasField",
"(",
"fieldName",
")",
"{",
"return",
"0",
",",
"errors",
".",
"New",
"(",
"\"",... | // DecimalPlacesInField returns the number of decimal places for the field with the given name.
// If the field does not exist, or does not use decimal places, an error is returned. | [
"DecimalPlacesInField",
"returns",
"the",
"number",
"of",
"decimal",
"places",
"for",
"the",
"field",
"with",
"the",
"given",
"name",
".",
"If",
"the",
"field",
"does",
"not",
"exist",
"or",
"does",
"not",
"use",
"decimal",
"places",
"an",
"error",
"is",
"... | 5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f | https://github.com/LindsayBradford/go-dbf/blob/5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f/godbf/dbftable.go#L309-L321 |
137,616 | LindsayBradford/go-dbf | godbf/dbftable.go | AddNewRecord | func (dt *DbfTable) AddNewRecord() (newRecordNumber int) {
if dt.dataEntryStarted == false {
dt.dataEntryStarted = true
}
newRecord := make([]byte, dt.lengthOfEachRecord)
dt.dataStore = appendSlice(dt.dataStore, newRecord)
// since row numbers are "0" based first we set newRecordNumber
// and then increment ... | go | func (dt *DbfTable) AddNewRecord() (newRecordNumber int) {
if dt.dataEntryStarted == false {
dt.dataEntryStarted = true
}
newRecord := make([]byte, dt.lengthOfEachRecord)
dt.dataStore = appendSlice(dt.dataStore, newRecord)
// since row numbers are "0" based first we set newRecordNumber
// and then increment ... | [
"func",
"(",
"dt",
"*",
"DbfTable",
")",
"AddNewRecord",
"(",
")",
"(",
"newRecordNumber",
"int",
")",
"{",
"if",
"dt",
".",
"dataEntryStarted",
"==",
"false",
"{",
"dt",
".",
"dataEntryStarted",
"=",
"true",
"\n",
"}",
"\n\n",
"newRecord",
":=",
"make",... | // AddNewRecord adds a new empty record to the table, and returns the index number of the record. | [
"AddNewRecord",
"adds",
"a",
"new",
"empty",
"record",
"to",
"the",
"table",
"and",
"returns",
"the",
"index",
"number",
"of",
"the",
"record",
"."
] | 5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f | https://github.com/LindsayBradford/go-dbf/blob/5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f/godbf/dbftable.go#L324-L347 |
137,617 | LindsayBradford/go-dbf | godbf/dbftable.go | SetFieldValueByName | func (dt *DbfTable) SetFieldValueByName(row int, fieldName string, value string) (err error) {
if fieldIndex, found := dt.fieldMap[fieldName]; found {
return dt.SetFieldValue(row, fieldIndex, value)
}
return errors.New("Field name \"" + fieldName + "\" does not exist")
} | go | func (dt *DbfTable) SetFieldValueByName(row int, fieldName string, value string) (err error) {
if fieldIndex, found := dt.fieldMap[fieldName]; found {
return dt.SetFieldValue(row, fieldIndex, value)
}
return errors.New("Field name \"" + fieldName + "\" does not exist")
} | [
"func",
"(",
"dt",
"*",
"DbfTable",
")",
"SetFieldValueByName",
"(",
"row",
"int",
",",
"fieldName",
"string",
",",
"value",
"string",
")",
"(",
"err",
"error",
")",
"{",
"if",
"fieldIndex",
",",
"found",
":=",
"dt",
".",
"fieldMap",
"[",
"fieldName",
... | // SetFieldValueByName sets the value for the given row and field name as specified
// If the field name does not exist, or the value is incompatible with the field's type, an error is returned. | [
"SetFieldValueByName",
"sets",
"the",
"value",
"for",
"the",
"given",
"row",
"and",
"field",
"name",
"as",
"specified",
"If",
"the",
"field",
"name",
"does",
"not",
"exist",
"or",
"the",
"value",
"is",
"incompatible",
"with",
"the",
"field",
"s",
"type",
"... | 5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f | https://github.com/LindsayBradford/go-dbf/blob/5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f/godbf/dbftable.go#L356-L361 |
137,618 | LindsayBradford/go-dbf | godbf/dbftable.go | SetFieldValue | func (dt *DbfTable) SetFieldValue(row int, fieldIndex int, value string) (err error) {
b := []byte(dt.encoder.ConvertString(value))
fieldLength := int(dt.fields[fieldIndex].length)
//DEBUG
//fmt.Printf("dt.numberOfBytesInHeader=%v\n\n", dt.numberOfBytesInHeader)
//fmt.Printf("dt.lengthOfEachRecord=%v\n\n", dt.... | go | func (dt *DbfTable) SetFieldValue(row int, fieldIndex int, value string) (err error) {
b := []byte(dt.encoder.ConvertString(value))
fieldLength := int(dt.fields[fieldIndex].length)
//DEBUG
//fmt.Printf("dt.numberOfBytesInHeader=%v\n\n", dt.numberOfBytesInHeader)
//fmt.Printf("dt.lengthOfEachRecord=%v\n\n", dt.... | [
"func",
"(",
"dt",
"*",
"DbfTable",
")",
"SetFieldValue",
"(",
"row",
"int",
",",
"fieldIndex",
"int",
",",
"value",
"string",
")",
"(",
"err",
"error",
")",
"{",
"b",
":=",
"[",
"]",
"byte",
"(",
"dt",
".",
"encoder",
".",
"ConvertString",
"(",
"v... | // SetFieldValue sets the value for the given row and field index as specified
// If the field index is invalid, or the value is incompatible with the field's type, an error is returned. | [
"SetFieldValue",
"sets",
"the",
"value",
"for",
"the",
"given",
"row",
"and",
"field",
"index",
"as",
"specified",
"If",
"the",
"field",
"index",
"is",
"invalid",
"or",
"the",
"value",
"is",
"incompatible",
"with",
"the",
"field",
"s",
"type",
"an",
"error... | 5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f | https://github.com/LindsayBradford/go-dbf/blob/5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f/godbf/dbftable.go#L365-L417 |
137,619 | LindsayBradford/go-dbf | godbf/dbftable.go | FieldValue | func (dt *DbfTable) FieldValue(row int, fieldIndex int) (value string) {
offset := int(dt.numberOfBytesInHeader)
lengthOfRecord := int(dt.lengthOfEachRecord)
offset = offset + (row * lengthOfRecord)
recordOffset := 1
for i := 0; i < len(dt.fields); i++ {
if i == fieldIndex {
break
} else {
recordOffs... | go | func (dt *DbfTable) FieldValue(row int, fieldIndex int) (value string) {
offset := int(dt.numberOfBytesInHeader)
lengthOfRecord := int(dt.lengthOfEachRecord)
offset = offset + (row * lengthOfRecord)
recordOffset := 1
for i := 0; i < len(dt.fields); i++ {
if i == fieldIndex {
break
} else {
recordOffs... | [
"func",
"(",
"dt",
"*",
"DbfTable",
")",
"FieldValue",
"(",
"row",
"int",
",",
"fieldIndex",
"int",
")",
"(",
"value",
"string",
")",
"{",
"offset",
":=",
"int",
"(",
"dt",
".",
"numberOfBytesInHeader",
")",
"\n",
"lengthOfRecord",
":=",
"int",
"(",
"d... | //FieldValue returns the content for the record at the given row and field index as a string
// If the row or field index is invalid, an error is returned . | [
"FieldValue",
"returns",
"the",
"content",
"for",
"the",
"record",
"at",
"the",
"given",
"row",
"and",
"field",
"index",
"as",
"a",
"string",
"If",
"the",
"row",
"or",
"field",
"index",
"is",
"invalid",
"an",
"error",
"is",
"returned",
"."
] | 5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f | https://github.com/LindsayBradford/go-dbf/blob/5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f/godbf/dbftable.go#L427-L457 |
137,620 | LindsayBradford/go-dbf | godbf/dbftable.go | Float64FieldValueByName | func (dt *DbfTable) Float64FieldValueByName(row int, fieldName string) (value float64, err error) {
valueAsString, err := dt.FieldValueByName(row, fieldName)
return strconv.ParseFloat(valueAsString, 64)
} | go | func (dt *DbfTable) Float64FieldValueByName(row int, fieldName string) (value float64, err error) {
valueAsString, err := dt.FieldValueByName(row, fieldName)
return strconv.ParseFloat(valueAsString, 64)
} | [
"func",
"(",
"dt",
"*",
"DbfTable",
")",
"Float64FieldValueByName",
"(",
"row",
"int",
",",
"fieldName",
"string",
")",
"(",
"value",
"float64",
",",
"err",
"error",
")",
"{",
"valueAsString",
",",
"err",
":=",
"dt",
".",
"FieldValueByName",
"(",
"row",
... | // Float64FieldValueByName returns the value of a field given row number and name provided as a float64 | [
"Float64FieldValueByName",
"returns",
"the",
"value",
"of",
"a",
"field",
"given",
"row",
"number",
"and",
"name",
"provided",
"as",
"a",
"float64"
] | 5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f | https://github.com/LindsayBradford/go-dbf/blob/5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f/godbf/dbftable.go#L470-L473 |
137,621 | LindsayBradford/go-dbf | godbf/dbftable.go | Int64FieldValueByName | func (dt *DbfTable) Int64FieldValueByName(row int, fieldName string) (value int64, err error) {
valueAsString, err := dt.FieldValueByName(row, fieldName)
return strconv.ParseInt(valueAsString, 0, 64)
} | go | func (dt *DbfTable) Int64FieldValueByName(row int, fieldName string) (value int64, err error) {
valueAsString, err := dt.FieldValueByName(row, fieldName)
return strconv.ParseInt(valueAsString, 0, 64)
} | [
"func",
"(",
"dt",
"*",
"DbfTable",
")",
"Int64FieldValueByName",
"(",
"row",
"int",
",",
"fieldName",
"string",
")",
"(",
"value",
"int64",
",",
"err",
"error",
")",
"{",
"valueAsString",
",",
"err",
":=",
"dt",
".",
"FieldValueByName",
"(",
"row",
",",... | // Int64FieldValueByName returns the value of a field given row number and name provided as an int64 | [
"Int64FieldValueByName",
"returns",
"the",
"value",
"of",
"a",
"field",
"given",
"row",
"number",
"and",
"name",
"provided",
"as",
"an",
"int64"
] | 5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f | https://github.com/LindsayBradford/go-dbf/blob/5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f/godbf/dbftable.go#L476-L479 |
137,622 | LindsayBradford/go-dbf | godbf/dbftable.go | FieldValueByName | func (dt *DbfTable) FieldValueByName(row int, fieldName string) (value string, err error) {
if fieldIndex, entryFound := dt.fieldMap[fieldName]; entryFound {
return dt.FieldValue(row, fieldIndex), err
}
err = errors.New("Field name \"" + fieldName + "\" does not exist")
return
} | go | func (dt *DbfTable) FieldValueByName(row int, fieldName string) (value string, err error) {
if fieldIndex, entryFound := dt.fieldMap[fieldName]; entryFound {
return dt.FieldValue(row, fieldIndex), err
}
err = errors.New("Field name \"" + fieldName + "\" does not exist")
return
} | [
"func",
"(",
"dt",
"*",
"DbfTable",
")",
"FieldValueByName",
"(",
"row",
"int",
",",
"fieldName",
"string",
")",
"(",
"value",
"string",
",",
"err",
"error",
")",
"{",
"if",
"fieldIndex",
",",
"entryFound",
":=",
"dt",
".",
"fieldMap",
"[",
"fieldName",
... | // FieldValueByName returns the value of a field given row number and name provided | [
"FieldValueByName",
"returns",
"the",
"value",
"of",
"a",
"field",
"given",
"row",
"number",
"and",
"name",
"provided"
] | 5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f | https://github.com/LindsayBradford/go-dbf/blob/5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f/godbf/dbftable.go#L482-L488 |
137,623 | LindsayBradford/go-dbf | godbf/dbftable.go | RowIsDeleted | func (dt *DbfTable) RowIsDeleted(row int) bool {
offset := int(dt.numberOfBytesInHeader)
lengthOfRecord := int(dt.lengthOfEachRecord)
offset = offset + (row * lengthOfRecord)
return dt.dataStore[offset:(offset + 1)][0] == 0x2A
} | go | func (dt *DbfTable) RowIsDeleted(row int) bool {
offset := int(dt.numberOfBytesInHeader)
lengthOfRecord := int(dt.lengthOfEachRecord)
offset = offset + (row * lengthOfRecord)
return dt.dataStore[offset:(offset + 1)][0] == 0x2A
} | [
"func",
"(",
"dt",
"*",
"DbfTable",
")",
"RowIsDeleted",
"(",
"row",
"int",
")",
"bool",
"{",
"offset",
":=",
"int",
"(",
"dt",
".",
"numberOfBytesInHeader",
")",
"\n",
"lengthOfRecord",
":=",
"int",
"(",
"dt",
".",
"lengthOfEachRecord",
")",
"\n",
"offs... | //RowIsDeleted returns whether a row has marked as deleted | [
"RowIsDeleted",
"returns",
"whether",
"a",
"row",
"has",
"marked",
"as",
"deleted"
] | 5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f | https://github.com/LindsayBradford/go-dbf/blob/5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f/godbf/dbftable.go#L491-L496 |
137,624 | LindsayBradford/go-dbf | godbf/dbftable.go | GetRowAsSlice | func (dt *DbfTable) GetRowAsSlice(row int) []string {
s := make([]string, len(dt.Fields()))
for i := 0; i < len(dt.Fields()); i++ {
s[i] = dt.FieldValue(row, i)
}
return s
} | go | func (dt *DbfTable) GetRowAsSlice(row int) []string {
s := make([]string, len(dt.Fields()))
for i := 0; i < len(dt.Fields()); i++ {
s[i] = dt.FieldValue(row, i)
}
return s
} | [
"func",
"(",
"dt",
"*",
"DbfTable",
")",
"GetRowAsSlice",
"(",
"row",
"int",
")",
"[",
"]",
"string",
"{",
"s",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"dt",
".",
"Fields",
"(",
")",
")",
")",
"\n\n",
"for",
"i",
":=",
"0",
";... | // GetRowAsSlice return the record values for the row specified as a string slice | [
"GetRowAsSlice",
"return",
"the",
"record",
"values",
"for",
"the",
"row",
"specified",
"as",
"a",
"string",
"slice"
] | 5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f | https://github.com/LindsayBradford/go-dbf/blob/5f7a16f88561c4d09bd4e74d6c3d1f95e074de3f/godbf/dbftable.go#L499-L508 |
137,625 | sourcegraph/syntaxhighlight | highlight.go | Class | func (c HTMLConfig) Class(kind Kind) string {
switch kind {
case String:
return c.String
case Keyword:
return c.Keyword
case Comment:
return c.Comment
case Type:
return c.Type
case Literal:
return c.Literal
case Punctuation:
return c.Punctuation
case Plaintext:
return c.Plaintext
case Tag:
retu... | go | func (c HTMLConfig) Class(kind Kind) string {
switch kind {
case String:
return c.String
case Keyword:
return c.Keyword
case Comment:
return c.Comment
case Type:
return c.Type
case Literal:
return c.Literal
case Punctuation:
return c.Punctuation
case Plaintext:
return c.Plaintext
case Tag:
retu... | [
"func",
"(",
"c",
"HTMLConfig",
")",
"Class",
"(",
"kind",
"Kind",
")",
"string",
"{",
"switch",
"kind",
"{",
"case",
"String",
":",
"return",
"c",
".",
"String",
"\n",
"case",
"Keyword",
":",
"return",
"c",
".",
"Keyword",
"\n",
"case",
"Comment",
"... | // Class returns the set class for a given token Kind. | [
"Class",
"returns",
"the",
"set",
"class",
"for",
"a",
"given",
"token",
"Kind",
"."
] | bd320f5d308e1a3c4314c678d8227a0d72574ae7 | https://github.com/sourcegraph/syntaxhighlight/blob/bd320f5d308e1a3c4314c678d8227a0d72574ae7/highlight.go#L72-L100 |
137,626 | sourcegraph/syntaxhighlight | highlight.go | NewScannerReader | func NewScannerReader(src io.Reader) *scanner.Scanner {
var s scanner.Scanner
s.Init(src)
s.Error = func(_ *scanner.Scanner, _ string) {}
s.Whitespace = 0
s.Mode = s.Mode ^ scanner.SkipComments
return &s
} | go | func NewScannerReader(src io.Reader) *scanner.Scanner {
var s scanner.Scanner
s.Init(src)
s.Error = func(_ *scanner.Scanner, _ string) {}
s.Whitespace = 0
s.Mode = s.Mode ^ scanner.SkipComments
return &s
} | [
"func",
"NewScannerReader",
"(",
"src",
"io",
".",
"Reader",
")",
"*",
"scanner",
".",
"Scanner",
"{",
"var",
"s",
"scanner",
".",
"Scanner",
"\n",
"s",
".",
"Init",
"(",
"src",
")",
"\n",
"s",
".",
"Error",
"=",
"func",
"(",
"_",
"*",
"scanner",
... | // NewScannerReader takes a reader src and creates a Scanner. | [
"NewScannerReader",
"takes",
"a",
"reader",
"src",
"and",
"creates",
"a",
"Scanner",
"."
] | bd320f5d308e1a3c4314c678d8227a0d72574ae7 | https://github.com/sourcegraph/syntaxhighlight/blob/bd320f5d308e1a3c4314c678d8227a0d72574ae7/highlight.go#L265-L272 |
137,627 | istio/glog | glog.go | V | func V(level Level) Verbose {
return Verbose(zap.L().Core().Enabled(zap.DebugLevel))
} | go | func V(level Level) Verbose {
return Verbose(zap.L().Core().Enabled(zap.DebugLevel))
} | [
"func",
"V",
"(",
"level",
"Level",
")",
"Verbose",
"{",
"return",
"Verbose",
"(",
"zap",
".",
"L",
"(",
")",
".",
"Core",
"(",
")",
".",
"Enabled",
"(",
"zap",
".",
"DebugLevel",
")",
")",
"\n",
"}"
] | // V is a shim | [
"V",
"is",
"a",
"shim"
] | d7cfb6fa2ccda15565f68f204d68907c80a5c977 | https://github.com/istio/glog/blob/d7cfb6fa2ccda15565f68f204d68907c80a5c977/glog.go#L42-L44 |
137,628 | istio/glog | glog.go | Infof | func (v Verbose) Infof(format string, args ...interface{}) {
zap.S().Debugf(format, args...)
} | go | func (v Verbose) Infof(format string, args ...interface{}) {
zap.S().Debugf(format, args...)
} | [
"func",
"(",
"v",
"Verbose",
")",
"Infof",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"zap",
".",
"S",
"(",
")",
".",
"Debugf",
"(",
"format",
",",
"args",
"...",
")",
"\n",
"}"
] | // Infof is a shim | [
"Infof",
"is",
"a",
"shim"
] | d7cfb6fa2ccda15565f68f204d68907c80a5c977 | https://github.com/istio/glog/blob/d7cfb6fa2ccda15565f68f204d68907c80a5c977/glog.go#L58-L60 |
137,629 | istio/glog | glog.go | Warningln | func Warningln(args ...interface{}) {
s := fmt.Sprint(args)
zap.S().Warn(s, "\n")
} | go | func Warningln(args ...interface{}) {
s := fmt.Sprint(args)
zap.S().Warn(s, "\n")
} | [
"func",
"Warningln",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"s",
":=",
"fmt",
".",
"Sprint",
"(",
"args",
")",
"\n",
"zap",
".",
"S",
"(",
")",
".",
"Warn",
"(",
"s",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"}"
] | // Warningln is a shim | [
"Warningln",
"is",
"a",
"shim"
] | d7cfb6fa2ccda15565f68f204d68907c80a5c977 | https://github.com/istio/glog/blob/d7cfb6fa2ccda15565f68f204d68907c80a5c977/glog.go#L94-L97 |
137,630 | istio/glog | glog.go | Errorln | func Errorln(args ...interface{}) {
s := fmt.Sprint(args)
zap.S().Error(s, "\n")
} | go | func Errorln(args ...interface{}) {
s := fmt.Sprint(args)
zap.S().Error(s, "\n")
} | [
"func",
"Errorln",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"s",
":=",
"fmt",
".",
"Sprint",
"(",
"args",
")",
"\n",
"zap",
".",
"S",
"(",
")",
".",
"Error",
"(",
"s",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"}"
] | // Errorln is a shim | [
"Errorln",
"is",
"a",
"shim"
] | d7cfb6fa2ccda15565f68f204d68907c80a5c977 | https://github.com/istio/glog/blob/d7cfb6fa2ccda15565f68f204d68907c80a5c977/glog.go#L115-L118 |
137,631 | istio/glog | glog.go | ExitDepth | func ExitDepth(depth int, args ...interface{}) {
zap.S().Error(args...)
os.Exit(1)
} | go | func ExitDepth(depth int, args ...interface{}) {
zap.S().Error(args...)
os.Exit(1)
} | [
"func",
"ExitDepth",
"(",
"depth",
"int",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"zap",
".",
"S",
"(",
")",
".",
"Error",
"(",
"args",
"...",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}"
] | // ExitDepth is a shim | [
"ExitDepth",
"is",
"a",
"shim"
] | d7cfb6fa2ccda15565f68f204d68907c80a5c977 | https://github.com/istio/glog/blob/d7cfb6fa2ccda15565f68f204d68907c80a5c977/glog.go#L157-L160 |
137,632 | istio/glog | glog.go | Exitln | func Exitln(args ...interface{}) {
s := fmt.Sprint(args)
zap.S().Error(s, "\n")
os.Exit(1)
} | go | func Exitln(args ...interface{}) {
s := fmt.Sprint(args)
zap.S().Error(s, "\n")
os.Exit(1)
} | [
"func",
"Exitln",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"s",
":=",
"fmt",
".",
"Sprint",
"(",
"args",
")",
"\n",
"zap",
".",
"S",
"(",
")",
".",
"Error",
"(",
"s",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"os",
".",
"Exit",
"(",
"1... | // Exitln is a shim | [
"Exitln",
"is",
"a",
"shim"
] | d7cfb6fa2ccda15565f68f204d68907c80a5c977 | https://github.com/istio/glog/blob/d7cfb6fa2ccda15565f68f204d68907c80a5c977/glog.go#L163-L167 |
137,633 | istio/glog | glog.go | Exitf | func Exitf(format string, args ...interface{}) {
zap.S().Errorf(format, args...)
os.Exit(1)
} | go | func Exitf(format string, args ...interface{}) {
zap.S().Errorf(format, args...)
os.Exit(1)
} | [
"func",
"Exitf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"zap",
".",
"S",
"(",
")",
".",
"Errorf",
"(",
"format",
",",
"args",
"...",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}"
] | // Exitf is a shim | [
"Exitf",
"is",
"a",
"shim"
] | d7cfb6fa2ccda15565f68f204d68907c80a5c977 | https://github.com/istio/glog/blob/d7cfb6fa2ccda15565f68f204d68907c80a5c977/glog.go#L170-L173 |
137,634 | volatiletech/abcweb | abcsessions/redis.go | All | func (r *RedisStorer) All() ([]string, error) {
var sessions []string
iter := r.client.Scan(0, "", 0).Iterator()
for iter.Next() {
sessions = append(sessions, iter.Val())
}
err := iter.Err()
return sessions, errors.Wrap(err, "unable to iterate redis store")
} | go | func (r *RedisStorer) All() ([]string, error) {
var sessions []string
iter := r.client.Scan(0, "", 0).Iterator()
for iter.Next() {
sessions = append(sessions, iter.Val())
}
err := iter.Err()
return sessions, errors.Wrap(err, "unable to iterate redis store")
} | [
"func",
"(",
"r",
"*",
"RedisStorer",
")",
"All",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"sessions",
"[",
"]",
"string",
"\n\n",
"iter",
":=",
"r",
".",
"client",
".",
"Scan",
"(",
"0",
",",
"\"",
"\"",
",",
"0",
")... | // All keys in the redis store | [
"All",
"keys",
"in",
"the",
"redis",
"store"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/redis.go#L51-L60 |
137,635 | volatiletech/abcweb | abcsessions/cookie_overseer.go | NewCookieOverseer | func NewCookieOverseer(opts CookieOptions, secretKey []byte) *CookieOverseer {
if len(opts.Name) == 0 {
panic("cookie name must be provided")
}
block, err := aes.NewCipher(secretKey)
if err != nil {
panic(err)
}
gcm, err := cipher.NewGCM(block)
if err != nil {
panic(err)
}
o := &CookieOverseer{
optio... | go | func NewCookieOverseer(opts CookieOptions, secretKey []byte) *CookieOverseer {
if len(opts.Name) == 0 {
panic("cookie name must be provided")
}
block, err := aes.NewCipher(secretKey)
if err != nil {
panic(err)
}
gcm, err := cipher.NewGCM(block)
if err != nil {
panic(err)
}
o := &CookieOverseer{
optio... | [
"func",
"NewCookieOverseer",
"(",
"opts",
"CookieOptions",
",",
"secretKey",
"[",
"]",
"byte",
")",
"*",
"CookieOverseer",
"{",
"if",
"len",
"(",
"opts",
".",
"Name",
")",
"==",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"block",
","... | // NewCookieOverseer creates an overseer from cookie options and a secret key
// for use in encryption. Panic's on any errors that deal with cryptography. | [
"NewCookieOverseer",
"creates",
"an",
"overseer",
"from",
"cookie",
"options",
"and",
"a",
"secret",
"key",
"for",
"use",
"in",
"encryption",
".",
"Panic",
"s",
"on",
"any",
"errors",
"that",
"deal",
"with",
"cryptography",
"."
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/cookie_overseer.go#L27-L50 |
137,636 | volatiletech/abcweb | abcsessions/cookie_overseer.go | Get | func (c *CookieOverseer) Get(w http.ResponseWriter, r *http.Request) (string, error) {
val, err := c.options.getCookieValue(w, r)
if err != nil {
return "", errors.Wrap(err, "unable to get session value from cookie")
}
return c.decode(val)
} | go | func (c *CookieOverseer) Get(w http.ResponseWriter, r *http.Request) (string, error) {
val, err := c.options.getCookieValue(w, r)
if err != nil {
return "", errors.Wrap(err, "unable to get session value from cookie")
}
return c.decode(val)
} | [
"func",
"(",
"c",
"*",
"CookieOverseer",
")",
"Get",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"string",
",",
"error",
")",
"{",
"val",
",",
"err",
":=",
"c",
".",
"options",
".",
"getCookieValue",
"(... | // Get a value from the cookie overseer | [
"Get",
"a",
"value",
"from",
"the",
"cookie",
"overseer"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/cookie_overseer.go#L53-L60 |
137,637 | volatiletech/abcweb | abcsessions/cookie_overseer.go | Set | func (c *CookieOverseer) Set(w http.ResponseWriter, r *http.Request, value string) error {
ev, err := c.encode(value)
if err != nil {
return errors.Wrap(err, "unable to encode session value into cookie")
}
w.(cookieWriter).SetCookie(c.options.makeCookie(ev))
return nil
} | go | func (c *CookieOverseer) Set(w http.ResponseWriter, r *http.Request, value string) error {
ev, err := c.encode(value)
if err != nil {
return errors.Wrap(err, "unable to encode session value into cookie")
}
w.(cookieWriter).SetCookie(c.options.makeCookie(ev))
return nil
} | [
"func",
"(",
"c",
"*",
"CookieOverseer",
")",
"Set",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"value",
"string",
")",
"error",
"{",
"ev",
",",
"err",
":=",
"c",
".",
"encode",
"(",
"value",
")",
"\n",
"... | // Set a value into the cookie overseer | [
"Set",
"a",
"value",
"into",
"the",
"cookie",
"overseer"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/cookie_overseer.go#L63-L72 |
137,638 | volatiletech/abcweb | abcsessions/cookie_overseer.go | Del | func (c *CookieOverseer) Del(w http.ResponseWriter, r *http.Request) error {
c.options.deleteCookie(w)
return nil
} | go | func (c *CookieOverseer) Del(w http.ResponseWriter, r *http.Request) error {
c.options.deleteCookie(w)
return nil
} | [
"func",
"(",
"c",
"*",
"CookieOverseer",
")",
"Del",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"c",
".",
"options",
".",
"deleteCookie",
"(",
"w",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Del a value from the cookie overseer | [
"Del",
"a",
"value",
"from",
"the",
"cookie",
"overseer"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/cookie_overseer.go#L75-L78 |
137,639 | volatiletech/abcweb | abcsessions/cookie_overseer.go | Regenerate | func (c *CookieOverseer) Regenerate(w http.ResponseWriter, r *http.Request) error {
panic("cookie sessions do not use session ids")
} | go | func (c *CookieOverseer) Regenerate(w http.ResponseWriter, r *http.Request) error {
panic("cookie sessions do not use session ids")
} | [
"func",
"(",
"c",
"*",
"CookieOverseer",
")",
"Regenerate",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // Regenerate for the cookie overseer will panic because cookie sessions
// do not have session IDs, only values. | [
"Regenerate",
"for",
"the",
"cookie",
"overseer",
"will",
"panic",
"because",
"cookie",
"sessions",
"do",
"not",
"have",
"session",
"IDs",
"only",
"values",
"."
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/cookie_overseer.go#L82-L84 |
137,640 | volatiletech/abcweb | abcsessions/cookie_overseer.go | SessionID | func (c *CookieOverseer) SessionID(w http.ResponseWriter, r *http.Request) (string, error) {
panic("cookie sessions do not use session ids")
} | go | func (c *CookieOverseer) SessionID(w http.ResponseWriter, r *http.Request) (string, error) {
panic("cookie sessions do not use session ids")
} | [
"func",
"(",
"c",
"*",
"CookieOverseer",
")",
"SessionID",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"string",
",",
"error",
")",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // SessionID for the cookie overseer will panic because cookie sessions
// do not have session IDs, only values. | [
"SessionID",
"for",
"the",
"cookie",
"overseer",
"will",
"panic",
"because",
"cookie",
"sessions",
"do",
"not",
"have",
"session",
"IDs",
"only",
"values",
"."
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/cookie_overseer.go#L88-L90 |
137,641 | volatiletech/abcweb | abcsessions/cookie_overseer.go | encode | func (c *CookieOverseer) encode(plaintext string) (string, error) {
nonce := make([]byte, c.gcmBlockMode.NonceSize())
if _, err := rand.Read(nonce); err != nil {
return "", errors.Wrap(err, "failed to encode session cookie value")
}
// Append ciphertext to the end of nonce so we have the nonce for decrypt
ciphe... | go | func (c *CookieOverseer) encode(plaintext string) (string, error) {
nonce := make([]byte, c.gcmBlockMode.NonceSize())
if _, err := rand.Read(nonce); err != nil {
return "", errors.Wrap(err, "failed to encode session cookie value")
}
// Append ciphertext to the end of nonce so we have the nonce for decrypt
ciphe... | [
"func",
"(",
"c",
"*",
"CookieOverseer",
")",
"encode",
"(",
"plaintext",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"nonce",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"c",
".",
"gcmBlockMode",
".",
"NonceSize",
"(",
")",
")",
"\n",
"if"... | // encode into base64'd aes-gcm | [
"encode",
"into",
"base64",
"d",
"aes",
"-",
"gcm"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/cookie_overseer.go#L110-L119 |
137,642 | volatiletech/abcweb | abcsessions/cookie_overseer.go | decode | func (c *CookieOverseer) decode(ciphertext string) (string, error) {
ct, err := base64.StdEncoding.DecodeString(ciphertext)
if err != nil {
return "", nil
}
if len(ct) <= c.gcmBlockMode.NonceSize() {
return "", errors.New("failed to decode session cookie value")
}
// Nonce comes from the first n bytes (n = ... | go | func (c *CookieOverseer) decode(ciphertext string) (string, error) {
ct, err := base64.StdEncoding.DecodeString(ciphertext)
if err != nil {
return "", nil
}
if len(ct) <= c.gcmBlockMode.NonceSize() {
return "", errors.New("failed to decode session cookie value")
}
// Nonce comes from the first n bytes (n = ... | [
"func",
"(",
"c",
"*",
"CookieOverseer",
")",
"decode",
"(",
"ciphertext",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"ct",
",",
"err",
":=",
"base64",
".",
"StdEncoding",
".",
"DecodeString",
"(",
"ciphertext",
")",
"\n",
"if",
"err",
"!=",... | // decode base64'd aes-gcm | [
"decode",
"base64",
"d",
"aes",
"-",
"gcm"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/cookie_overseer.go#L122-L143 |
137,643 | volatiletech/abcweb | abcmiddleware/log.go | Zap | func (m Middleware) Zap(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
t := time.Now()
zw := &zapResponseWriter{ResponseWriter: w}
// Serve the request
next.ServeHTTP(zw, r)
// Write the request log line
writeZap(m.Log, r, t, zw.status, zw.size)
}
return http.Ha... | go | func (m Middleware) Zap(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
t := time.Now()
zw := &zapResponseWriter{ResponseWriter: w}
// Serve the request
next.ServeHTTP(zw, r)
// Write the request log line
writeZap(m.Log, r, t, zw.status, zw.size)
}
return http.Ha... | [
"func",
"(",
"m",
"Middleware",
")",
"Zap",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"fn",
":=",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"t",
":=",
"time",
".... | // Zap middleware handles web request logging using Zap | [
"Zap",
"middleware",
"handles",
"web",
"request",
"logging",
"using",
"Zap"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcmiddleware/log.go#L21-L34 |
137,644 | volatiletech/abcweb | abcmiddleware/log.go | RequestIDLogger | func (m Middleware) RequestIDLogger(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
requestID := chimiddleware.GetReqID(r.Context())
derivedLogger := m.Log.With(zap.String("request_id", requestID))
r = r.WithContext(context.WithValue(r.Context(), CtxLoggerKey, derivedLogger... | go | func (m Middleware) RequestIDLogger(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
requestID := chimiddleware.GetReqID(r.Context())
derivedLogger := m.Log.With(zap.String("request_id", requestID))
r = r.WithContext(context.WithValue(r.Context(), CtxLoggerKey, derivedLogger... | [
"func",
"(",
"m",
"Middleware",
")",
"RequestIDLogger",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"fn",
":=",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"requestID",
... | // RequestIDLogger middleware creates a derived logger to include logging of the
// Request ID, and inserts it into the context object | [
"RequestIDLogger",
"middleware",
"creates",
"a",
"derived",
"logger",
"to",
"include",
"logging",
"of",
"the",
"Request",
"ID",
"and",
"inserts",
"it",
"into",
"the",
"context",
"object"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcmiddleware/log.go#L38-L47 |
137,645 | volatiletech/abcweb | abcmiddleware/log.go | Log | func Log(r *http.Request) *zap.Logger {
v := r.Context().Value(CtxLoggerKey)
log, ok := v.(*zap.Logger)
if !ok {
panic("cannot get derived request id logger from context object")
}
return log
} | go | func Log(r *http.Request) *zap.Logger {
v := r.Context().Value(CtxLoggerKey)
log, ok := v.(*zap.Logger)
if !ok {
panic("cannot get derived request id logger from context object")
}
return log
} | [
"func",
"Log",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"*",
"zap",
".",
"Logger",
"{",
"v",
":=",
"r",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"CtxLoggerKey",
")",
"\n",
"log",
",",
"ok",
":=",
"v",
".",
"(",
"*",
"zap",
".",
"Logger... | // Log returns the Request ID scoped logger from the request Context
// and panics if it cannot be found. This function is only ever used
// by your controllers if your app uses the RequestID middlewares,
// otherwise you should use the controller's receiver logger directly. | [
"Log",
"returns",
"the",
"Request",
"ID",
"scoped",
"logger",
"from",
"the",
"request",
"Context",
"and",
"panics",
"if",
"it",
"cannot",
"be",
"found",
".",
"This",
"function",
"is",
"only",
"ever",
"used",
"by",
"your",
"controllers",
"if",
"your",
"app"... | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcmiddleware/log.go#L53-L60 |
137,646 | volatiletech/abcweb | abcmiddleware/recover.go | Recover | func (m Middleware) Recover(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
defer func() {
if err := recover(); err != nil {
var protocol string
if r.TLS == nil {
protocol = "http"
} else {
protocol = "https"
}
var log *zap.Logger
v := r.Co... | go | func (m Middleware) Recover(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
defer func() {
if err := recover(); err != nil {
var protocol string
if r.TLS == nil {
protocol = "http"
} else {
protocol = "https"
}
var log *zap.Logger
v := r.Co... | [
"func",
"(",
"m",
"Middleware",
")",
"Recover",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"fn",
":=",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"defer",
"func",
"(... | // Recover middleware recovers panics that occur and gracefully logs their error | [
"Recover",
"middleware",
"recovers",
"panics",
"that",
"occur",
"and",
"gracefully",
"logs",
"their",
"error"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcmiddleware/recover.go#L11-L63 |
137,647 | volatiletech/abcweb | cert/cert.go | Template | func Template(appName, commonName string) (*x509.Certificate, error) {
// generate a random serial number (a real cert authority would have some logic behind this)
serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
if err != nil {
return nil, er... | go | func Template(appName, commonName string) (*x509.Certificate, error) {
// generate a random serial number (a real cert authority would have some logic behind this)
serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
if err != nil {
return nil, er... | [
"func",
"Template",
"(",
"appName",
",",
"commonName",
"string",
")",
"(",
"*",
"x509",
".",
"Certificate",
",",
"error",
")",
"{",
"// generate a random serial number (a real cert authority would have some logic behind this)",
"serialNumberLimit",
":=",
"new",
"(",
"big"... | // Template is a helper function to create a cert template with a
// serial number and other required fields | [
"Template",
"is",
"a",
"helper",
"function",
"to",
"create",
"a",
"cert",
"template",
"with",
"a",
"serial",
"number",
"and",
"other",
"required",
"fields"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/cert/cert.go#L18-L41 |
137,648 | volatiletech/abcweb | cert/cert.go | WriteCertFile | func WriteCertFile(outFile afero.File, template *x509.Certificate, pub interface{}, priv interface{}) error {
certDER, err := x509.CreateCertificate(rand.Reader, template, template, pub, priv)
if err != nil {
return err
}
// PEM encode the certificate (this is a standard TLS encoding)
b := &pem.Block{
Type: ... | go | func WriteCertFile(outFile afero.File, template *x509.Certificate, pub interface{}, priv interface{}) error {
certDER, err := x509.CreateCertificate(rand.Reader, template, template, pub, priv)
if err != nil {
return err
}
// PEM encode the certificate (this is a standard TLS encoding)
b := &pem.Block{
Type: ... | [
"func",
"WriteCertFile",
"(",
"outFile",
"afero",
".",
"File",
",",
"template",
"*",
"x509",
".",
"Certificate",
",",
"pub",
"interface",
"{",
"}",
",",
"priv",
"interface",
"{",
"}",
")",
"error",
"{",
"certDER",
",",
"err",
":=",
"x509",
".",
"Create... | // WriteCertFile writes the cert.pem certificate file | [
"WriteCertFile",
"writes",
"the",
"cert",
".",
"pem",
"certificate",
"file"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/cert/cert.go#L44-L57 |
137,649 | volatiletech/abcweb | cert/cert.go | WritePrivateKey | func WritePrivateKey(outFile afero.File, key *rsa.PrivateKey) error {
b := &pem.Block{
Type: "RSA PRIVATE KEY",
Bytes: x509.MarshalPKCS1PrivateKey(key),
}
return pem.Encode(outFile, b)
} | go | func WritePrivateKey(outFile afero.File, key *rsa.PrivateKey) error {
b := &pem.Block{
Type: "RSA PRIVATE KEY",
Bytes: x509.MarshalPKCS1PrivateKey(key),
}
return pem.Encode(outFile, b)
} | [
"func",
"WritePrivateKey",
"(",
"outFile",
"afero",
".",
"File",
",",
"key",
"*",
"rsa",
".",
"PrivateKey",
")",
"error",
"{",
"b",
":=",
"&",
"pem",
".",
"Block",
"{",
"Type",
":",
"\"",
"\"",
",",
"Bytes",
":",
"x509",
".",
"MarshalPKCS1PrivateKey",
... | // WritePrivateKey writes the private.key private key file | [
"WritePrivateKey",
"writes",
"the",
"private",
".",
"key",
"private",
"key",
"file"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/cert/cert.go#L60-L67 |
137,650 | volatiletech/abcweb | abcserver/routes.go | NewNotFoundHandler | func NewNotFoundHandler(manifest map[string]string) *NotFound {
return &NotFound{
Templates: NotFoundTemplates{
NotFound: "errors/404",
InternalServerError: "errors/500",
},
AssetsManifest: manifest,
}
} | go | func NewNotFoundHandler(manifest map[string]string) *NotFound {
return &NotFound{
Templates: NotFoundTemplates{
NotFound: "errors/404",
InternalServerError: "errors/500",
},
AssetsManifest: manifest,
}
} | [
"func",
"NewNotFoundHandler",
"(",
"manifest",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"NotFound",
"{",
"return",
"&",
"NotFound",
"{",
"Templates",
":",
"NotFoundTemplates",
"{",
"NotFound",
":",
"\"",
"\"",
",",
"InternalServerError",
":",
"\"",
"\"... | // NewNotFoundHandler creates a new handler | [
"NewNotFoundHandler",
"creates",
"a",
"new",
"handler"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcserver/routes.go#L49-L57 |
137,651 | volatiletech/abcweb | abcserver/routes.go | Handler | func (m *MethodNotAllowed) Handler(render abcrender.Renderer) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Get the Request ID scoped logger
log := abcmiddleware.Log(r)
log.Warn("method not allowed",
zap.String("method", r.Method),
zap.String("uri", r.RequestURI),
zap.Bool... | go | func (m *MethodNotAllowed) Handler(render abcrender.Renderer) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Get the Request ID scoped logger
log := abcmiddleware.Log(r)
log.Warn("method not allowed",
zap.String("method", r.Method),
zap.String("uri", r.RequestURI),
zap.Bool... | [
"func",
"(",
"m",
"*",
"MethodNotAllowed",
")",
"Handler",
"(",
"render",
"abcrender",
".",
"Renderer",
")",
"http",
".",
"HandlerFunc",
"{",
"return",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"/... | // Handler is a wrapper around the MethodNotAllowed handler.
// The MethodNotAllowed handler is called when someone attempts an operation
// against a route that does not support that operation, for example
// attempting a POST against a route that only supports a GET. | [
"Handler",
"is",
"a",
"wrapper",
"around",
"the",
"MethodNotAllowed",
"handler",
".",
"The",
"MethodNotAllowed",
"handler",
"is",
"called",
"when",
"someone",
"attempts",
"an",
"operation",
"against",
"a",
"route",
"that",
"does",
"not",
"support",
"that",
"oper... | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcserver/routes.go#L168-L186 |
137,652 | volatiletech/abcweb | abcconfig/config.go | Bind | func (c *Config) Bind(flags *pflag.FlagSet, cfg interface{}) (*viper.Viper, error) {
v, err := c.NewSubViper(flags, cfg)
if err != nil {
return v, err
}
if err := UnmarshalAppConfig(cfg, v); err != nil {
return v, err
}
val := reflect.Indirect(reflect.ValueOf(cfg))
// Check if there's a DBConfig object in... | go | func (c *Config) Bind(flags *pflag.FlagSet, cfg interface{}) (*viper.Viper, error) {
v, err := c.NewSubViper(flags, cfg)
if err != nil {
return v, err
}
if err := UnmarshalAppConfig(cfg, v); err != nil {
return v, err
}
val := reflect.Indirect(reflect.ValueOf(cfg))
// Check if there's a DBConfig object in... | [
"func",
"(",
"c",
"*",
"Config",
")",
"Bind",
"(",
"flags",
"*",
"pflag",
".",
"FlagSet",
",",
"cfg",
"interface",
"{",
"}",
")",
"(",
"*",
"viper",
".",
"Viper",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"c",
".",
"NewSubViper",
"(",
"fla... | // Bind your passed in config flags to a new viper
// instance, retrieves the active environment section of your config file using
// that viper instance, and then loads your server and db config into
// the passed in cfg struct and validates the db config is set appropriately. | [
"Bind",
"your",
"passed",
"in",
"config",
"flags",
"to",
"a",
"new",
"viper",
"instance",
"retrieves",
"the",
"active",
"environment",
"section",
"of",
"your",
"config",
"file",
"using",
"that",
"viper",
"instance",
"and",
"then",
"loads",
"your",
"server",
... | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcconfig/config.go#L116-L142 |
137,653 | volatiletech/abcweb | abcconfig/config.go | NewSubViper | func (c *Config) NewSubViper(flags *pflag.FlagSet, cfg interface{}) (*viper.Viper, error) {
v := viper.New()
if flags != nil {
if err := v.BindPFlags(flags); err != nil {
return nil, err
}
}
if err := c.ConfigureViper(v); err != nil {
return nil, err
}
// Use the env from the config if it's not explic... | go | func (c *Config) NewSubViper(flags *pflag.FlagSet, cfg interface{}) (*viper.Viper, error) {
v := viper.New()
if flags != nil {
if err := v.BindPFlags(flags); err != nil {
return nil, err
}
}
if err := c.ConfigureViper(v); err != nil {
return nil, err
}
// Use the env from the config if it's not explic... | [
"func",
"(",
"c",
"*",
"Config",
")",
"NewSubViper",
"(",
"flags",
"*",
"pflag",
".",
"FlagSet",
",",
"cfg",
"interface",
"{",
"}",
")",
"(",
"*",
"viper",
".",
"Viper",
",",
"error",
")",
"{",
"v",
":=",
"viper",
".",
"New",
"(",
")",
"\n\n",
... | // NewSubViper returns a viper instance activated against the active environment
// configuration subsection and initialized with the config.toml
// configuration file and the environment variable prefix.
// It also takes in the configuration struct so that it can generate the env
// mappings. | [
"NewSubViper",
"returns",
"a",
"viper",
"instance",
"activated",
"against",
"the",
"active",
"environment",
"configuration",
"subsection",
"and",
"initialized",
"with",
"the",
"config",
".",
"toml",
"configuration",
"file",
"and",
"the",
"environment",
"variable",
"... | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcconfig/config.go#L149-L200 |
137,654 | volatiletech/abcweb | abcconfig/config.go | ConfigureViper | func (c *Config) ConfigureViper(v *viper.Viper) error {
v.SetConfigType("toml")
v.SetConfigFile(c.File)
v.SetEnvPrefix(c.EnvPrefix)
v.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
if err := v.ReadInConfig(); err != nil {
return err
}
v.AutomaticEnv()
return nil
} | go | func (c *Config) ConfigureViper(v *viper.Viper) error {
v.SetConfigType("toml")
v.SetConfigFile(c.File)
v.SetEnvPrefix(c.EnvPrefix)
v.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
if err := v.ReadInConfig(); err != nil {
return err
}
v.AutomaticEnv()
return nil
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"ConfigureViper",
"(",
"v",
"*",
"viper",
".",
"Viper",
")",
"error",
"{",
"v",
".",
"SetConfigType",
"(",
"\"",
"\"",
")",
"\n",
"v",
".",
"SetConfigFile",
"(",
"c",
".",
"File",
")",
"\n",
"v",
".",
"SetEnv... | // ConfigureViper sets the viper object to use the passed in config toml file
// and also configures the configuration environment variables. | [
"ConfigureViper",
"sets",
"the",
"viper",
"object",
"to",
"use",
"the",
"passed",
"in",
"config",
"toml",
"file",
"and",
"also",
"configures",
"the",
"configuration",
"environment",
"variables",
"."
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcconfig/config.go#L204-L215 |
137,655 | volatiletech/abcweb | abcconfig/config.go | UnmarshalAppConfig | func UnmarshalAppConfig(cfg interface{}, v *viper.Viper) error {
err := v.Unmarshal(cfg)
if err != nil {
return err
}
val := reflect.Indirect(reflect.ValueOf(cfg))
// if cfg has an imbedded AppConfig then we need to unmarshal
// directly into that and overwrite it in the parent struct,
// since its another l... | go | func UnmarshalAppConfig(cfg interface{}, v *viper.Viper) error {
err := v.Unmarshal(cfg)
if err != nil {
return err
}
val := reflect.Indirect(reflect.ValueOf(cfg))
// if cfg has an imbedded AppConfig then we need to unmarshal
// directly into that and overwrite it in the parent struct,
// since its another l... | [
"func",
"UnmarshalAppConfig",
"(",
"cfg",
"interface",
"{",
"}",
",",
"v",
"*",
"viper",
".",
"Viper",
")",
"error",
"{",
"err",
":=",
"v",
".",
"Unmarshal",
"(",
"cfg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
... | // UnmarshalAppConfig unmarshals the viper's configured config file
// into the passed in cfg object containing an AppConfig | [
"UnmarshalAppConfig",
"unmarshals",
"the",
"viper",
"s",
"configured",
"config",
"file",
"into",
"the",
"passed",
"in",
"cfg",
"object",
"containing",
"an",
"AppConfig"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcconfig/config.go#L219-L274 |
137,656 | volatiletech/abcweb | abcconfig/config.go | ValidateDBConfig | func ValidateDBConfig(cfg DBConfig) error {
err := vala.BeginValidation().Validate(
vala.StringNotEmpty(cfg.DB, "db"),
vala.StringNotEmpty(cfg.User, "user"),
vala.StringNotEmpty(cfg.Host, "host"),
vala.Not(vala.Equals(cfg.Port, 0, "port")),
vala.StringNotEmpty(cfg.DBName, "dbname"),
vala.StringNotEmpty(cfg... | go | func ValidateDBConfig(cfg DBConfig) error {
err := vala.BeginValidation().Validate(
vala.StringNotEmpty(cfg.DB, "db"),
vala.StringNotEmpty(cfg.User, "user"),
vala.StringNotEmpty(cfg.Host, "host"),
vala.Not(vala.Equals(cfg.Port, 0, "port")),
vala.StringNotEmpty(cfg.DBName, "dbname"),
vala.StringNotEmpty(cfg... | [
"func",
"ValidateDBConfig",
"(",
"cfg",
"DBConfig",
")",
"error",
"{",
"err",
":=",
"vala",
".",
"BeginValidation",
"(",
")",
".",
"Validate",
"(",
"vala",
".",
"StringNotEmpty",
"(",
"cfg",
".",
"DB",
",",
"\"",
"\"",
")",
",",
"vala",
".",
"StringNot... | // ValidateDBConfig returns an error if any of the required db config
// fields are not set to their appropriate values. | [
"ValidateDBConfig",
"returns",
"an",
"error",
"if",
"any",
"of",
"the",
"required",
"db",
"config",
"fields",
"are",
"not",
"set",
"to",
"their",
"appropriate",
"values",
"."
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcconfig/config.go#L278-L296 |
137,657 | volatiletech/abcweb | abcconfig/config.go | GetTagMappings | func GetTagMappings(cfg interface{}) (Mappings, error) {
return getTagMappingsRecursive("", reflect.Indirect(reflect.ValueOf(cfg)))
} | go | func GetTagMappings(cfg interface{}) (Mappings, error) {
return getTagMappingsRecursive("", reflect.Indirect(reflect.ValueOf(cfg)))
} | [
"func",
"GetTagMappings",
"(",
"cfg",
"interface",
"{",
"}",
")",
"(",
"Mappings",
",",
"error",
")",
"{",
"return",
"getTagMappingsRecursive",
"(",
"\"",
"\"",
",",
"reflect",
".",
"Indirect",
"(",
"reflect",
".",
"ValueOf",
"(",
"cfg",
")",
")",
")",
... | // GetTagMappings returns the viper .BindEnv mappings for an entire config
// struct. | [
"GetTagMappings",
"returns",
"the",
"viper",
".",
"BindEnv",
"mappings",
"for",
"an",
"entire",
"config",
"struct",
"."
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcconfig/config.go#L363-L365 |
137,658 | volatiletech/abcweb | abcdatabase/database.go | GetConnStr | func GetConnStr(cfg abcconfig.DBConfig) (string, error) {
if len(cfg.DB) == 0 {
return "", errors.New("db field in config.toml must be provided")
}
if cfg.DB == "postgres" {
return drivers.PostgresBuildQueryString(cfg.User, cfg.Pass, cfg.DBName, cfg.Host, cfg.Port, cfg.SSLMode), nil
} else if cfg.DB == "mysql"... | go | func GetConnStr(cfg abcconfig.DBConfig) (string, error) {
if len(cfg.DB) == 0 {
return "", errors.New("db field in config.toml must be provided")
}
if cfg.DB == "postgres" {
return drivers.PostgresBuildQueryString(cfg.User, cfg.Pass, cfg.DBName, cfg.Host, cfg.Port, cfg.SSLMode), nil
} else if cfg.DB == "mysql"... | [
"func",
"GetConnStr",
"(",
"cfg",
"abcconfig",
".",
"DBConfig",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"len",
"(",
"cfg",
".",
"DB",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}... | // GetConnStr returns a connection string for the database software used | [
"GetConnStr",
"returns",
"a",
"connection",
"string",
"for",
"the",
"database",
"software",
"used"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcdatabase/database.go#L34-L46 |
137,659 | volatiletech/abcweb | abcdatabase/database.go | SetupDBData | func SetupDBData(cfg abcconfig.DBConfig, testdata TestdataFunc) (int, error) {
var err error
appPath := git.GetAppPath()
err = createTestDB(cfg)
if err != nil {
return 0, err
}
count, err := RunMigrations(cfg, filepath.Join(appPath, "db", "migrations"))
if err != nil {
return count, errors.Wrap(err, "cann... | go | func SetupDBData(cfg abcconfig.DBConfig, testdata TestdataFunc) (int, error) {
var err error
appPath := git.GetAppPath()
err = createTestDB(cfg)
if err != nil {
return 0, err
}
count, err := RunMigrations(cfg, filepath.Join(appPath, "db", "migrations"))
if err != nil {
return count, errors.Wrap(err, "cann... | [
"func",
"SetupDBData",
"(",
"cfg",
"abcconfig",
".",
"DBConfig",
",",
"testdata",
"TestdataFunc",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"appPath",
":=",
"git",
".",
"GetAppPath",
"(",
")",
"\n\n",
"err",
"=",
"createTest... | // SetupDBData executes the migrations "up" against the passed in database
// and also inserts the test data defined in testdata.sql and executes
// the passed in TestdataFunc handler if present, and then returns the
// number of migrations run. | [
"SetupDBData",
"executes",
"the",
"migrations",
"up",
"against",
"the",
"passed",
"in",
"database",
"and",
"also",
"inserts",
"the",
"test",
"data",
"defined",
"in",
"testdata",
".",
"sql",
"and",
"executes",
"the",
"passed",
"in",
"TestdataFunc",
"handler",
"... | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcdatabase/database.go#L127-L146 |
137,660 | volatiletech/abcweb | abcdatabase/database.go | RunMigrations | func RunMigrations(cfg abcconfig.DBConfig, migrationsPath string) (int, error) {
connStr, err := GetConnStr(cfg)
if err != nil {
return 0, err
}
count, err := mig.Up(cfg.DB, connStr, migrationsPath)
if err != nil {
return count, err
}
return count, nil
} | go | func RunMigrations(cfg abcconfig.DBConfig, migrationsPath string) (int, error) {
connStr, err := GetConnStr(cfg)
if err != nil {
return 0, err
}
count, err := mig.Up(cfg.DB, connStr, migrationsPath)
if err != nil {
return count, err
}
return count, nil
} | [
"func",
"RunMigrations",
"(",
"cfg",
"abcconfig",
".",
"DBConfig",
",",
"migrationsPath",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"connStr",
",",
"err",
":=",
"GetConnStr",
"(",
"cfg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",... | // RunMigrations executes the migrations "up" against the passed in database
// and returns the number of migrations run. | [
"RunMigrations",
"executes",
"the",
"migrations",
"up",
"against",
"the",
"passed",
"in",
"database",
"and",
"returns",
"the",
"number",
"of",
"migrations",
"run",
"."
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcdatabase/database.go#L190-L202 |
137,661 | volatiletech/abcweb | abcdatabase/database.go | ExecuteScript | func ExecuteScript(cfg abcconfig.DBConfig, script []byte) error {
rdr := bytes.NewReader(script)
if cfg.DB == "postgres" {
passFilePath, err := pgPassFile(cfg)
if err != nil {
return err
}
defer os.Remove(passFilePath)
cmd := exec.Command("psql", cfg.DBName, "-v", "ON_ERROR_STOP=1")
cmd.Stdin = rdr
... | go | func ExecuteScript(cfg abcconfig.DBConfig, script []byte) error {
rdr := bytes.NewReader(script)
if cfg.DB == "postgres" {
passFilePath, err := pgPassFile(cfg)
if err != nil {
return err
}
defer os.Remove(passFilePath)
cmd := exec.Command("psql", cfg.DBName, "-v", "ON_ERROR_STOP=1")
cmd.Stdin = rdr
... | [
"func",
"ExecuteScript",
"(",
"cfg",
"abcconfig",
".",
"DBConfig",
",",
"script",
"[",
"]",
"byte",
")",
"error",
"{",
"rdr",
":=",
"bytes",
".",
"NewReader",
"(",
"script",
")",
"\n\n",
"if",
"cfg",
".",
"DB",
"==",
"\"",
"\"",
"{",
"passFilePath",
... | // ExecuteScript executes the passed in SQL script against the passed in db | [
"ExecuteScript",
"executes",
"the",
"passed",
"in",
"SQL",
"script",
"against",
"the",
"passed",
"in",
"db"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcdatabase/database.go#L244-L283 |
137,662 | volatiletech/abcweb | abcdatabase/database.go | pgEnv | func pgEnv(cfg abcconfig.DBConfig, passFilePath string) []string {
return []string{
fmt.Sprintf("PGHOST=%s", cfg.Host),
fmt.Sprintf("PGPORT=%d", cfg.Port),
fmt.Sprintf("PGUSER=%s", cfg.User),
fmt.Sprintf("PGPASSFILE=%s", passFilePath),
}
} | go | func pgEnv(cfg abcconfig.DBConfig, passFilePath string) []string {
return []string{
fmt.Sprintf("PGHOST=%s", cfg.Host),
fmt.Sprintf("PGPORT=%d", cfg.Port),
fmt.Sprintf("PGUSER=%s", cfg.User),
fmt.Sprintf("PGPASSFILE=%s", passFilePath),
}
} | [
"func",
"pgEnv",
"(",
"cfg",
"abcconfig",
".",
"DBConfig",
",",
"passFilePath",
"string",
")",
"[",
"]",
"string",
"{",
"return",
"[",
"]",
"string",
"{",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"cfg",
".",
"Host",
")",
",",
"fmt",
".",
"Sprin... | // pgEnv returns a slice of the connection related environment variables | [
"pgEnv",
"returns",
"a",
"slice",
"of",
"the",
"connection",
"related",
"environment",
"variables"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcdatabase/database.go#L332-L339 |
137,663 | volatiletech/abcweb | abcdatabase/database.go | pgPassFile | func pgPassFile(cfg abcconfig.DBConfig) (string, error) {
tmp, err := ioutil.TempFile("", "pgpass")
if err != nil {
return "", errors.New("failed to create postgres pass file")
}
defer tmp.Close()
fmt.Fprintf(tmp, "%s:%d:%s:%s", cfg.Host, cfg.Port, cfg.DBName, cfg.User)
if len(cfg.Pass) != 0 {
fmt.Fprintf(tm... | go | func pgPassFile(cfg abcconfig.DBConfig) (string, error) {
tmp, err := ioutil.TempFile("", "pgpass")
if err != nil {
return "", errors.New("failed to create postgres pass file")
}
defer tmp.Close()
fmt.Fprintf(tmp, "%s:%d:%s:%s", cfg.Host, cfg.Port, cfg.DBName, cfg.User)
if len(cfg.Pass) != 0 {
fmt.Fprintf(tm... | [
"func",
"pgPassFile",
"(",
"cfg",
"abcconfig",
".",
"DBConfig",
")",
"(",
"string",
",",
"error",
")",
"{",
"tmp",
",",
"err",
":=",
"ioutil",
".",
"TempFile",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // pgPassFile creates a file in the temp directory containing the connection
// details and password for the database to be passed into the mysql cmdline cmd | [
"pgPassFile",
"creates",
"a",
"file",
"in",
"the",
"temp",
"directory",
"containing",
"the",
"connection",
"details",
"and",
"password",
"for",
"the",
"database",
"to",
"be",
"passed",
"into",
"the",
"mysql",
"cmdline",
"cmd"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcdatabase/database.go#L343-L357 |
137,664 | volatiletech/abcweb | abcdatabase/database.go | mysqlPassFile | func mysqlPassFile(cfg abcconfig.DBConfig) (string, error) {
tmp, err := ioutil.TempFile("", "mysqlpass")
if err != nil {
return "", errors.Wrap(err, "failed to create mysql pass file")
}
defer tmp.Close()
fmt.Fprintln(tmp, "[client]")
fmt.Fprintf(tmp, "host=%s\n", cfg.Host)
fmt.Fprintf(tmp, "port=%d\n", cfg.... | go | func mysqlPassFile(cfg abcconfig.DBConfig) (string, error) {
tmp, err := ioutil.TempFile("", "mysqlpass")
if err != nil {
return "", errors.Wrap(err, "failed to create mysql pass file")
}
defer tmp.Close()
fmt.Fprintln(tmp, "[client]")
fmt.Fprintf(tmp, "host=%s\n", cfg.Host)
fmt.Fprintf(tmp, "port=%d\n", cfg.... | [
"func",
"mysqlPassFile",
"(",
"cfg",
"abcconfig",
".",
"DBConfig",
")",
"(",
"string",
",",
"error",
")",
"{",
"tmp",
",",
"err",
":=",
"ioutil",
".",
"TempFile",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",... | // mysqlPassFile creates a file in the temp directory containing the connection
// details and password for the database to be passed into the mysql cmdline cmd | [
"mysqlPassFile",
"creates",
"a",
"file",
"in",
"the",
"temp",
"directory",
"containing",
"the",
"connection",
"details",
"and",
"password",
"for",
"the",
"database",
"to",
"be",
"passed",
"into",
"the",
"mysql",
"cmdline",
"cmd"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcdatabase/database.go#L361-L387 |
137,665 | volatiletech/abcweb | config/config.go | Initialize | func Initialize(env *pflag.Flag) (*Configuration, error) {
c := &Configuration{}
path, err := getAppPath()
if err != nil {
return nil, err
}
c.AppPath = path
c.AppName = getAppName(c.AppPath)
c.AppEnvName = strmangle.EnvAppName(c.AppName)
c.ActiveEnv = getActiveEnv(c.AppPath, c.AppName)
// If ActiveEnv is ... | go | func Initialize(env *pflag.Flag) (*Configuration, error) {
c := &Configuration{}
path, err := getAppPath()
if err != nil {
return nil, err
}
c.AppPath = path
c.AppName = getAppName(c.AppPath)
c.AppEnvName = strmangle.EnvAppName(c.AppName)
c.ActiveEnv = getActiveEnv(c.AppPath, c.AppName)
// If ActiveEnv is ... | [
"func",
"Initialize",
"(",
"env",
"*",
"pflag",
".",
"Flag",
")",
"(",
"*",
"Configuration",
",",
"error",
")",
"{",
"c",
":=",
"&",
"Configuration",
"{",
"}",
"\n\n",
"path",
",",
"err",
":=",
"getAppPath",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil"... | // Initialize the config | [
"Initialize",
"the",
"config"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/config/config.go#L55-L76 |
137,666 | volatiletech/abcweb | config/config.go | InitializeP | func InitializeP(env *pflag.Flag) *Configuration {
c, err := Initialize(env)
if err != nil {
panic(err)
}
return c
} | go | func InitializeP(env *pflag.Flag) *Configuration {
c, err := Initialize(env)
if err != nil {
panic(err)
}
return c
} | [
"func",
"InitializeP",
"(",
"env",
"*",
"pflag",
".",
"Flag",
")",
"*",
"Configuration",
"{",
"c",
",",
"err",
":=",
"Initialize",
"(",
"env",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"c",
"... | // InitializeP the config but panic if anything goes wrong | [
"InitializeP",
"the",
"config",
"but",
"panic",
"if",
"anything",
"goes",
"wrong"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/config/config.go#L79-L86 |
137,667 | volatiletech/abcweb | config/config.go | getAppName | func getAppName(appPath string) string {
// Is "/" on both Windows and Linux
split := strings.Split(appPath, "/")
return split[len(split)-1]
} | go | func getAppName(appPath string) string {
// Is "/" on both Windows and Linux
split := strings.Split(appPath, "/")
return split[len(split)-1]
} | [
"func",
"getAppName",
"(",
"appPath",
"string",
")",
"string",
"{",
"// Is \"/\" on both Windows and Linux",
"split",
":=",
"strings",
".",
"Split",
"(",
"appPath",
",",
"\"",
"\"",
")",
"\n",
"return",
"split",
"[",
"len",
"(",
"split",
")",
"-",
"1",
"]"... | // getAppName gets the appname portion of a project path | [
"getAppName",
"gets",
"the",
"appname",
"portion",
"of",
"a",
"project",
"path"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/config/config.go#L201-L205 |
137,668 | volatiletech/abcweb | config/config.go | CheckEnv | func (c *Configuration) CheckEnv() error {
if c.ActiveEnv == "" {
return fmt.Errorf("No active environment chosen. Please choose an environment using the \"env\" flag in config.toml or the $%s_ENV environment variable", c.AppEnvName)
}
return nil
} | go | func (c *Configuration) CheckEnv() error {
if c.ActiveEnv == "" {
return fmt.Errorf("No active environment chosen. Please choose an environment using the \"env\" flag in config.toml or the $%s_ENV environment variable", c.AppEnvName)
}
return nil
} | [
"func",
"(",
"c",
"*",
"Configuration",
")",
"CheckEnv",
"(",
")",
"error",
"{",
"if",
"c",
".",
"ActiveEnv",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"c",
".",
"AppEnvName",
")",
"\n",
"}",
"\n... | // CheckEnv outputs an error if no ActiveEnv is found | [
"CheckEnv",
"outputs",
"an",
"error",
"if",
"no",
"ActiveEnv",
"is",
"found"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/config/config.go#L219-L224 |
137,669 | volatiletech/abcweb | abcmiddleware/errors.go | NewErrorManager | func NewErrorManager(render abcrender.Renderer) *errorManager {
return &errorManager{
render: render,
errors: []ErrorContainer{},
}
} | go | func NewErrorManager(render abcrender.Renderer) *errorManager {
return &errorManager{
render: render,
errors: []ErrorContainer{},
}
} | [
"func",
"NewErrorManager",
"(",
"render",
"abcrender",
".",
"Renderer",
")",
"*",
"errorManager",
"{",
"return",
"&",
"errorManager",
"{",
"render",
":",
"render",
",",
"errors",
":",
"[",
"]",
"ErrorContainer",
"{",
"}",
",",
"}",
"\n",
"}"
] | // NewErrorManager creates an error manager that can be used to
// create an error handler to wrap your controllers with | [
"NewErrorManager",
"creates",
"an",
"error",
"manager",
"that",
"can",
"be",
"used",
"to",
"create",
"an",
"error",
"handler",
"to",
"wrap",
"your",
"controllers",
"with"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcmiddleware/errors.go#L40-L45 |
137,670 | volatiletech/abcweb | abcmiddleware/errors.go | Remove | func (m *errorManager) Remove(e ErrorContainer) {
for i, v := range m.errors {
if reflect.DeepEqual(v, e) {
m.errors = append(m.errors[:i], m.errors[i+1:]...)
}
}
} | go | func (m *errorManager) Remove(e ErrorContainer) {
for i, v := range m.errors {
if reflect.DeepEqual(v, e) {
m.errors = append(m.errors[:i], m.errors[i+1:]...)
}
}
} | [
"func",
"(",
"m",
"*",
"errorManager",
")",
"Remove",
"(",
"e",
"ErrorContainer",
")",
"{",
"for",
"i",
",",
"v",
":=",
"range",
"m",
".",
"errors",
"{",
"if",
"reflect",
".",
"DeepEqual",
"(",
"v",
",",
"e",
")",
"{",
"m",
".",
"errors",
"=",
... | // Remove a ErrorContainer from the error manager | [
"Remove",
"a",
"ErrorContainer",
"from",
"the",
"error",
"manager"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcmiddleware/errors.go#L70-L76 |
137,671 | volatiletech/abcweb | abcmiddleware/errors.go | Add | func (m *errorManager) Add(e ErrorContainer) {
m.errors = append(m.errors, e)
} | go | func (m *errorManager) Add(e ErrorContainer) {
m.errors = append(m.errors, e)
} | [
"func",
"(",
"m",
"*",
"errorManager",
")",
"Add",
"(",
"e",
"ErrorContainer",
")",
"{",
"m",
".",
"errors",
"=",
"append",
"(",
"m",
".",
"errors",
",",
"e",
")",
"\n",
"}"
] | // Add a new ErrorContainer to the error manager | [
"Add",
"a",
"new",
"ErrorContainer",
"to",
"the",
"error",
"manager"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcmiddleware/errors.go#L79-L81 |
137,672 | volatiletech/abcweb | abcsessions/middleware.go | Write | func (s *sessionsResponseWriter) Write(buf []byte) (int, error) {
if !s.wroteHeader {
s.WriteHeader(http.StatusOK)
}
return s.ResponseWriter.Write(buf)
} | go | func (s *sessionsResponseWriter) Write(buf []byte) (int, error) {
if !s.wroteHeader {
s.WriteHeader(http.StatusOK)
}
return s.ResponseWriter.Write(buf)
} | [
"func",
"(",
"s",
"*",
"sessionsResponseWriter",
")",
"Write",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"!",
"s",
".",
"wroteHeader",
"{",
"s",
".",
"WriteHeader",
"(",
"http",
".",
"StatusOK",
")",
"\n",
"}",
... | // Write calls the underlying ResponseWriter Write func | [
"Write",
"calls",
"the",
"underlying",
"ResponseWriter",
"Write",
"func"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/middleware.go#L27-L32 |
137,673 | volatiletech/abcweb | abcsessions/middleware.go | WriteHeader | func (s *sessionsResponseWriter) WriteHeader(code int) {
s.wroteHeader = true
// Set all the cookies in the cookie buffer
if !s.wroteCookies {
s.wroteCookies = true
for _, c := range s.cookies {
http.SetCookie(s.ResponseWriter, c)
}
}
s.ResponseWriter.WriteHeader(code)
} | go | func (s *sessionsResponseWriter) WriteHeader(code int) {
s.wroteHeader = true
// Set all the cookies in the cookie buffer
if !s.wroteCookies {
s.wroteCookies = true
for _, c := range s.cookies {
http.SetCookie(s.ResponseWriter, c)
}
}
s.ResponseWriter.WriteHeader(code)
} | [
"func",
"(",
"s",
"*",
"sessionsResponseWriter",
")",
"WriteHeader",
"(",
"code",
"int",
")",
"{",
"s",
".",
"wroteHeader",
"=",
"true",
"\n\n",
"// Set all the cookies in the cookie buffer",
"if",
"!",
"s",
".",
"wroteCookies",
"{",
"s",
".",
"wroteCookies",
... | // WriteHeader sets all cookies in the buffer on the underlying ResponseWriter's
// headers and calls the underlying ResponseWriter WriteHeader func | [
"WriteHeader",
"sets",
"all",
"cookies",
"in",
"the",
"buffer",
"on",
"the",
"underlying",
"ResponseWriter",
"s",
"headers",
"and",
"calls",
"the",
"underlying",
"ResponseWriter",
"WriteHeader",
"func"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/middleware.go#L36-L48 |
137,674 | volatiletech/abcweb | abcsessions/middleware.go | MiddlewareWithReset | func (m resetExpiryMiddleware) MiddlewareWithReset(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Convert the response writer to a sessions response, so we can
// use its cookie buffering and writing capabilities
w = newSessionsResponseWriter(w)
err... | go | func (m resetExpiryMiddleware) MiddlewareWithReset(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Convert the response writer to a sessions response, so we can
// use its cookie buffering and writing capabilities
w = newSessionsResponseWriter(w)
err... | [
"func",
"(",
"m",
"resetExpiryMiddleware",
")",
"MiddlewareWithReset",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",... | // Middleware converts the ResponseWriter object to a sessionsResponseWriter
// for buffering cookies across session API requests.
// The sessionsResponseWriter implements cookieWriter.
//
// MiddlewareWithReset also resets the users session expiry on each request.
// If you do not want this added functionality use Mid... | [
"Middleware",
"converts",
"the",
"ResponseWriter",
"object",
"to",
"a",
"sessionsResponseWriter",
"for",
"buffering",
"cookies",
"across",
"session",
"API",
"requests",
".",
"The",
"sessionsResponseWriter",
"implements",
"cookieWriter",
".",
"MiddlewareWithReset",
"also",... | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/middleware.go#L92-L107 |
137,675 | volatiletech/abcweb | abcserver/server.go | Write | func (s serverErrLogger) Write(b []byte) (int, error) {
s.log.Debug(string(b))
return 0, nil
} | go | func (s serverErrLogger) Write(b []byte) (int, error) {
s.log.Debug(string(b))
return 0, nil
} | [
"func",
"(",
"s",
"serverErrLogger",
")",
"Write",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"s",
".",
"log",
".",
"Debug",
"(",
"string",
"(",
"b",
")",
")",
"\n",
"return",
"0",
",",
"nil",
"\n",
"}"
] | // Implement Write to log server errors using the zap logger | [
"Implement",
"Write",
"to",
"log",
"server",
"errors",
"using",
"the",
"zap",
"logger"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcserver/server.go#L26-L29 |
137,676 | volatiletech/abcweb | abcserver/server.go | StartServer | func StartServer(cfg abcconfig.ServerConfig, router http.Handler, logger *zap.Logger) error {
var err error
server := http.Server{
ReadTimeout: cfg.ReadTimeout,
WriteTimeout: cfg.WriteTimeout,
IdleTimeout: cfg.IdleTimeout,
ErrorLog: log.New(serverErrLogger{logger}, "", 0),
Handler: router,
}
s... | go | func StartServer(cfg abcconfig.ServerConfig, router http.Handler, logger *zap.Logger) error {
var err error
server := http.Server{
ReadTimeout: cfg.ReadTimeout,
WriteTimeout: cfg.WriteTimeout,
IdleTimeout: cfg.IdleTimeout,
ErrorLog: log.New(serverErrLogger{logger}, "", 0),
Handler: router,
}
s... | [
"func",
"StartServer",
"(",
"cfg",
"abcconfig",
".",
"ServerConfig",
",",
"router",
"http",
".",
"Handler",
",",
"logger",
"*",
"zap",
".",
"Logger",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"server",
":=",
"http",
".",
"Server",
"{",
"ReadTimeout... | // StartServer starts the web server on the specified port, and can be
// gracefully shut down by sending an os.Interrupt signal to the server.
// This is a blocking call. | [
"StartServer",
"starts",
"the",
"web",
"server",
"on",
"the",
"specified",
"port",
"and",
"can",
"be",
"gracefully",
"shut",
"down",
"by",
"sending",
"an",
"os",
".",
"Interrupt",
"signal",
"to",
"the",
"server",
".",
"This",
"is",
"a",
"blocking",
"call",... | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcserver/server.go#L34-L89 |
137,677 | volatiletech/abcweb | abcserver/server.go | Redirect | func Redirect(cfg abcconfig.ServerConfig, logger *zap.Logger) {
var err error
// Get https port from TLS Bind
_, httpsPort, err := net.SplitHostPort(cfg.TLSBind)
if err != nil {
log.Fatal("failed to get port from tls bind", zap.Error(err))
}
logger.Info("starting http -> https redirect listener", zap.String("... | go | func Redirect(cfg abcconfig.ServerConfig, logger *zap.Logger) {
var err error
// Get https port from TLS Bind
_, httpsPort, err := net.SplitHostPort(cfg.TLSBind)
if err != nil {
log.Fatal("failed to get port from tls bind", zap.Error(err))
}
logger.Info("starting http -> https redirect listener", zap.String("... | [
"func",
"Redirect",
"(",
"cfg",
"abcconfig",
".",
"ServerConfig",
",",
"logger",
"*",
"zap",
".",
"Logger",
")",
"{",
"var",
"err",
"error",
"\n\n",
"// Get https port from TLS Bind",
"_",
",",
"httpsPort",
",",
"err",
":=",
"net",
".",
"SplitHostPort",
"(",... | // Redirect listens on the non-https port, and redirects all requests to https | [
"Redirect",
"listens",
"on",
"the",
"non",
"-",
"https",
"port",
"and",
"redirects",
"all",
"requests",
"to",
"https"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcserver/server.go#L92-L138 |
137,678 | volatiletech/abcweb | abcsessions/memory.go | NewMemoryStorer | func NewMemoryStorer(maxAge, cleanInterval time.Duration) (*MemoryStorer, error) {
if (maxAge != 0 && cleanInterval == 0) || (cleanInterval != 0 && maxAge == 0) {
panic("if max age or clean interval is set, the other must also be set")
}
m := &MemoryStorer{
sessions: make(map[string]memorySession),
maxAg... | go | func NewMemoryStorer(maxAge, cleanInterval time.Duration) (*MemoryStorer, error) {
if (maxAge != 0 && cleanInterval == 0) || (cleanInterval != 0 && maxAge == 0) {
panic("if max age or clean interval is set, the other must also be set")
}
m := &MemoryStorer{
sessions: make(map[string]memorySession),
maxAg... | [
"func",
"NewMemoryStorer",
"(",
"maxAge",
",",
"cleanInterval",
"time",
".",
"Duration",
")",
"(",
"*",
"MemoryStorer",
",",
"error",
")",
"{",
"if",
"(",
"maxAge",
"!=",
"0",
"&&",
"cleanInterval",
"==",
"0",
")",
"||",
"(",
"cleanInterval",
"!=",
"0",
... | // NewMemoryStorer initializes and returns a new MemoryStorer object.
// It takes the maxAge of how long each session should live in memory,
// and a cleanInterval duration which defines how often the clean
// task should check for maxAge sessions to be removed from memory.
// Persistent storage can be attained by sett... | [
"NewMemoryStorer",
"initializes",
"and",
"returns",
"a",
"new",
"MemoryStorer",
"object",
".",
"It",
"takes",
"the",
"maxAge",
"of",
"how",
"long",
"each",
"session",
"should",
"live",
"in",
"memory",
"and",
"a",
"cleanInterval",
"duration",
"which",
"defines",
... | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/memory.go#L44-L56 |
137,679 | volatiletech/abcweb | abcsessions/memory.go | All | func (m *MemoryStorer) All() ([]string, error) {
m.mut.RLock()
defer m.mut.RUnlock()
sessions := make([]string, len(m.sessions))
i := 0
for id := range m.sessions {
sessions[i] = id
i++
}
return sessions, nil
} | go | func (m *MemoryStorer) All() ([]string, error) {
m.mut.RLock()
defer m.mut.RUnlock()
sessions := make([]string, len(m.sessions))
i := 0
for id := range m.sessions {
sessions[i] = id
i++
}
return sessions, nil
} | [
"func",
"(",
"m",
"*",
"MemoryStorer",
")",
"All",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"m",
".",
"mut",
".",
"RLock",
"(",
")",
"\n",
"defer",
"m",
".",
"mut",
".",
"RUnlock",
"(",
")",
"\n\n",
"sessions",
":=",
"make",
... | // All keys in the memory store | [
"All",
"keys",
"in",
"the",
"memory",
"store"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/memory.go#L59-L72 |
137,680 | volatiletech/abcweb | abcsessions/memory.go | Clean | func (m *MemoryStorer) Clean() {
t := time.Now().UTC()
m.mut.Lock()
for id, session := range m.sessions {
if t.After(session.expires) {
delete(m.sessions, id)
}
}
m.mut.Unlock()
} | go | func (m *MemoryStorer) Clean() {
t := time.Now().UTC()
m.mut.Lock()
for id, session := range m.sessions {
if t.After(session.expires) {
delete(m.sessions, id)
}
}
m.mut.Unlock()
} | [
"func",
"(",
"m",
"*",
"MemoryStorer",
")",
"Clean",
"(",
")",
"{",
"t",
":=",
"time",
".",
"Now",
"(",
")",
".",
"UTC",
"(",
")",
"\n",
"m",
".",
"mut",
".",
"Lock",
"(",
")",
"\n",
"for",
"id",
",",
"session",
":=",
"range",
"m",
".",
"se... | // Clean checks all sessions in memory to see if they are older than
// maxAge by checking their expiry. If it finds an expired session
// it will remove it from memory. | [
"Clean",
"checks",
"all",
"sessions",
"in",
"memory",
"to",
"see",
"if",
"they",
"are",
"older",
"than",
"maxAge",
"by",
"checking",
"their",
"expiry",
".",
"If",
"it",
"finds",
"an",
"expired",
"session",
"it",
"will",
"remove",
"it",
"from",
"memory",
... | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/memory.go#L125-L134 |
137,681 | volatiletech/abcweb | abcsessions/memory.go | StartCleaner | func (m *MemoryStorer) StartCleaner() {
if m.maxAge == 0 || m.cleanInterval == 0 {
panic("both max age and clean interval must be set to non-zero")
}
// init quit chan
m.quit = make(chan struct{})
m.wg.Add(1)
// Start the cleaner infinite loop go routine.
// StopCleaner() can be used to kill this go routine... | go | func (m *MemoryStorer) StartCleaner() {
if m.maxAge == 0 || m.cleanInterval == 0 {
panic("both max age and clean interval must be set to non-zero")
}
// init quit chan
m.quit = make(chan struct{})
m.wg.Add(1)
// Start the cleaner infinite loop go routine.
// StopCleaner() can be used to kill this go routine... | [
"func",
"(",
"m",
"*",
"MemoryStorer",
")",
"StartCleaner",
"(",
")",
"{",
"if",
"m",
".",
"maxAge",
"==",
"0",
"||",
"m",
".",
"cleanInterval",
"==",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// init quit chan",
"m",
".",
"quit"... | // StartCleaner starts the memory session cleaner go routine. This go routine
// will delete expired sessions from the memory map on the cleanInterval interval. | [
"StartCleaner",
"starts",
"the",
"memory",
"session",
"cleaner",
"go",
"routine",
".",
"This",
"go",
"routine",
"will",
"delete",
"expired",
"sessions",
"from",
"the",
"memory",
"map",
"on",
"the",
"cleanInterval",
"interval",
"."
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/memory.go#L138-L151 |
137,682 | volatiletech/abcweb | cmd/generate.go | modelsCmdPreRun | func modelsCmdPreRun(cmd *cobra.Command, args []string) error {
var err error
cnf, err = config.Initialize(cmd.Flags().Lookup("env"))
if err != nil {
return err
}
cnf.ModeViper.BindPFlags(modelsCmd.Flags())
err = cnf.CheckEnv()
if err != nil {
return err
}
return modelsCmdSetup(cmd, args)
} | go | func modelsCmdPreRun(cmd *cobra.Command, args []string) error {
var err error
cnf, err = config.Initialize(cmd.Flags().Lookup("env"))
if err != nil {
return err
}
cnf.ModeViper.BindPFlags(modelsCmd.Flags())
err = cnf.CheckEnv()
if err != nil {
return err
}
return modelsCmdSetup(cmd, args)
} | [
"func",
"modelsCmdPreRun",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"cnf",
",",
"err",
"=",
"config",
".",
"Initialize",
"(",
"cmd",
".",
"Flags",
"(",
")",
".",
"Loo... | // modelsCmdPreRun sets up the modelsCmdState and modelsCmdConfig objects | [
"modelsCmdPreRun",
"sets",
"up",
"the",
"modelsCmdState",
"and",
"modelsCmdConfig",
"objects"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/cmd/generate.go#L136-L151 |
137,683 | volatiletech/abcweb | strmangle/strmangle.go | replaceNonAlpha | func replaceNonAlpha(s string, replace byte) string {
byts := []byte(s)
newByts := make([]byte, len(byts))
for i := 0; i < len(byts); i++ {
if byts[i] < 'A' || (byts[i] > 'Z' && byts[i] < 'a') || byts[i] > 'z' {
newByts[i] = replace
} else {
newByts[i] = byts[i]
}
}
return string(newByts)
} | go | func replaceNonAlpha(s string, replace byte) string {
byts := []byte(s)
newByts := make([]byte, len(byts))
for i := 0; i < len(byts); i++ {
if byts[i] < 'A' || (byts[i] > 'Z' && byts[i] < 'a') || byts[i] > 'z' {
newByts[i] = replace
} else {
newByts[i] = byts[i]
}
}
return string(newByts)
} | [
"func",
"replaceNonAlpha",
"(",
"s",
"string",
",",
"replace",
"byte",
")",
"string",
"{",
"byts",
":=",
"[",
"]",
"byte",
"(",
"s",
")",
"\n",
"newByts",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(",
"byts",
")",
")",
"\n\n",
"for",
"i",... | // replaceNonAlpha replaces non alphabet characters with the replace byte. | [
"replaceNonAlpha",
"replaces",
"non",
"alphabet",
"characters",
"with",
"the",
"replace",
"byte",
"."
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/strmangle/strmangle.go#L43-L56 |
137,684 | volatiletech/abcweb | cmd/dev.go | startGulp | func startGulp(publicPathEnv string, ctx context.Context) error {
_, err := os.Stat(filepath.Join(cnf.AppPath, "gulpfile.js"))
if os.IsNotExist(err) {
fmt.Println("No gulpfile.js present, skipping gulp watch")
return nil
} else if err != nil {
return err
}
_, err = exec.LookPath("gulp")
if err != nil {
f... | go | func startGulp(publicPathEnv string, ctx context.Context) error {
_, err := os.Stat(filepath.Join(cnf.AppPath, "gulpfile.js"))
if os.IsNotExist(err) {
fmt.Println("No gulpfile.js present, skipping gulp watch")
return nil
} else if err != nil {
return err
}
_, err = exec.LookPath("gulp")
if err != nil {
f... | [
"func",
"startGulp",
"(",
"publicPathEnv",
"string",
",",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"filepath",
".",
"Join",
"(",
"cnf",
".",
"AppPath",
",",
"\"",
"\"",
")",
")",
"\n",
"if"... | // startGulp starts "gulp watch" if it can find gulpfile.js and the gulp command. | [
"startGulp",
"starts",
"gulp",
"watch",
"if",
"it",
"can",
"find",
"gulpfile",
".",
"js",
"and",
"the",
"gulp",
"command",
"."
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/cmd/dev.go#L118-L141 |
137,685 | volatiletech/abcweb | cmd/dev.go | startRefresh | func startRefresh(publicPathEnv string, ctx context.Context) (*refresh.Manager, error) {
cfgFile := filepath.Join(cnf.AppPath, "watch.toml")
_, err := os.Stat(cfgFile)
if err != nil && !os.IsNotExist(err) {
return nil, err
}
c := &refreshConfig{
AppRoot: ".",
IgnoredFolders: []string{"vendor... | go | func startRefresh(publicPathEnv string, ctx context.Context) (*refresh.Manager, error) {
cfgFile := filepath.Join(cnf.AppPath, "watch.toml")
_, err := os.Stat(cfgFile)
if err != nil && !os.IsNotExist(err) {
return nil, err
}
c := &refreshConfig{
AppRoot: ".",
IgnoredFolders: []string{"vendor... | [
"func",
"startRefresh",
"(",
"publicPathEnv",
"string",
",",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"refresh",
".",
"Manager",
",",
"error",
")",
"{",
"cfgFile",
":=",
"filepath",
".",
"Join",
"(",
"cnf",
".",
"AppPath",
",",
"\"",
"\"",
")",... | // startRefresh starts the refresh server to watch go files for recompilation. | [
"startRefresh",
"starts",
"the",
"refresh",
"server",
"to",
"watch",
"go",
"files",
"for",
"recompilation",
"."
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/cmd/dev.go#L159-L208 |
137,686 | volatiletech/abcweb | abcsessions/sessions.go | IsNoSessionError | func IsNoSessionError(err error) bool {
_, ok := err.(noSessionInterface)
if ok {
return ok
}
_, ok = errors.Cause(err).(noSessionInterface)
return ok
} | go | func IsNoSessionError(err error) bool {
_, ok := err.(noSessionInterface)
if ok {
return ok
}
_, ok = errors.Cause(err).(noSessionInterface)
return ok
} | [
"func",
"IsNoSessionError",
"(",
"err",
"error",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"err",
".",
"(",
"noSessionInterface",
")",
"\n",
"if",
"ok",
"{",
"return",
"ok",
"\n",
"}",
"\n\n",
"_",
",",
"ok",
"=",
"errors",
".",
"Cause",
"(",
"err",
... | // IsNoSessionError checks an error to see if it means that there was no session | [
"IsNoSessionError",
"checks",
"an",
"error",
"to",
"see",
"if",
"it",
"means",
"that",
"there",
"was",
"no",
"session"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/sessions.go#L85-L93 |
137,687 | volatiletech/abcweb | abcsessions/sessions.go | IsNoMapKeyError | func IsNoMapKeyError(err error) bool {
_, ok := err.(noMapKeyInterface)
if ok {
return ok
}
_, ok = errors.Cause(err).(noMapKeyInterface)
return ok
} | go | func IsNoMapKeyError(err error) bool {
_, ok := err.(noMapKeyInterface)
if ok {
return ok
}
_, ok = errors.Cause(err).(noMapKeyInterface)
return ok
} | [
"func",
"IsNoMapKeyError",
"(",
"err",
"error",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"err",
".",
"(",
"noMapKeyInterface",
")",
"\n",
"if",
"ok",
"{",
"return",
"ok",
"\n",
"}",
"\n\n",
"_",
",",
"ok",
"=",
"errors",
".",
"Cause",
"(",
"err",
... | // IsNoMapKeyError checks an error to see if it means that there was
// no session map key | [
"IsNoMapKeyError",
"checks",
"an",
"error",
"to",
"see",
"if",
"it",
"means",
"that",
"there",
"was",
"no",
"session",
"map",
"key"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/sessions.go#L97-L105 |
137,688 | volatiletech/abcweb | abcsessions/sessions.go | Set | func Set(overseer Overseer, w http.ResponseWriter, r *http.Request, key string, value string) error {
var sess session
sessMap := make(map[string]string)
val, err := overseer.Get(w, r)
if err != nil && !IsNoSessionError(err) {
return errors.Wrap(err, "unable to get session")
}
if !IsNoSessionError(err) {
er... | go | func Set(overseer Overseer, w http.ResponseWriter, r *http.Request, key string, value string) error {
var sess session
sessMap := make(map[string]string)
val, err := overseer.Get(w, r)
if err != nil && !IsNoSessionError(err) {
return errors.Wrap(err, "unable to get session")
}
if !IsNoSessionError(err) {
er... | [
"func",
"Set",
"(",
"overseer",
"Overseer",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"key",
"string",
",",
"value",
"string",
")",
"error",
"{",
"var",
"sess",
"session",
"\n",
"sessMap",
":=",
"make",
"(",
... | // Set is a JSON helper used for storing key-value session values.
// Set modifies the marshalled map stored in the session to include the key value pair passed in. | [
"Set",
"is",
"a",
"JSON",
"helper",
"used",
"for",
"storing",
"key",
"-",
"value",
"session",
"values",
".",
"Set",
"modifies",
"the",
"marshalled",
"map",
"stored",
"in",
"the",
"session",
"to",
"include",
"the",
"key",
"value",
"pair",
"passed",
"in",
... | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/sessions.go#L154-L191 |
137,689 | volatiletech/abcweb | abcsessions/sessions.go | Get | func Get(overseer Overseer, w http.ResponseWriter, r *http.Request, key string) (string, error) {
val, err := overseer.Get(w, r)
if err != nil {
return "", errors.Wrap(err, "unable to get session")
}
var sess session
err = json.Unmarshal([]byte(val), &sess)
if err != nil {
return "", errors.Wrap(err, "unable... | go | func Get(overseer Overseer, w http.ResponseWriter, r *http.Request, key string) (string, error) {
val, err := overseer.Get(w, r)
if err != nil {
return "", errors.Wrap(err, "unable to get session")
}
var sess session
err = json.Unmarshal([]byte(val), &sess)
if err != nil {
return "", errors.Wrap(err, "unable... | [
"func",
"Get",
"(",
"overseer",
"Overseer",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"val",
",",
"err",
":=",
"overseer",
".",
"Get",
"(",
"w",... | // Get is a JSON helper used for retrieving key-value session values.
// Get returns the value pointed to by the key of the marshalled map stored in the session. | [
"Get",
"is",
"a",
"JSON",
"helper",
"used",
"for",
"retrieving",
"key",
"-",
"value",
"session",
"values",
".",
"Get",
"returns",
"the",
"value",
"pointed",
"to",
"by",
"the",
"key",
"of",
"the",
"marshalled",
"map",
"stored",
"in",
"the",
"session",
"."... | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/sessions.go#L195-L219 |
137,690 | volatiletech/abcweb | abcsessions/sessions.go | GetObj | func GetObj(overseer Overseer, w http.ResponseWriter, r *http.Request, pointer interface{}) error {
val, err := overseer.Get(w, r)
if err != nil {
return errors.Wrap(err, "unable to get session")
}
var sess session
// json unmarshal the outter session struct
err = json.Unmarshal([]byte(val), &sess)
if err != ... | go | func GetObj(overseer Overseer, w http.ResponseWriter, r *http.Request, pointer interface{}) error {
val, err := overseer.Get(w, r)
if err != nil {
return errors.Wrap(err, "unable to get session")
}
var sess session
// json unmarshal the outter session struct
err = json.Unmarshal([]byte(val), &sess)
if err != ... | [
"func",
"GetObj",
"(",
"overseer",
"Overseer",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"pointer",
"interface",
"{",
"}",
")",
"error",
"{",
"val",
",",
"err",
":=",
"overseer",
".",
"Get",
"(",
"w",
",",
... | // GetObj is a JSON helper used for retrieving object or variable session values.
// GetObj unmarshals the session value into the pointer pointed to by pointer. | [
"GetObj",
"is",
"a",
"JSON",
"helper",
"used",
"for",
"retrieving",
"object",
"or",
"variable",
"session",
"values",
".",
"GetObj",
"unmarshals",
"the",
"session",
"value",
"into",
"the",
"pointer",
"pointed",
"to",
"by",
"pointer",
"."
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/sessions.go#L296-L312 |
137,691 | volatiletech/abcweb | abcsessions/sessions.go | GetFlash | func GetFlash(overseer Overseer, w http.ResponseWriter, r *http.Request, key string) (string, error) {
var sess session
val, err := overseer.Get(w, r)
if err != nil {
return "", errors.Wrap(err, "unable to get session")
}
err = json.Unmarshal([]byte(val), &sess)
if err != nil {
return "", errors.Wrap(err, "... | go | func GetFlash(overseer Overseer, w http.ResponseWriter, r *http.Request, key string) (string, error) {
var sess session
val, err := overseer.Get(w, r)
if err != nil {
return "", errors.Wrap(err, "unable to get session")
}
err = json.Unmarshal([]byte(val), &sess)
if err != nil {
return "", errors.Wrap(err, "... | [
"func",
"GetFlash",
"(",
"overseer",
"Overseer",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"sess",
"session",
"\n\n",
"val",
",",
"err",
":... | // GetFlash retrieves a flash message from the session then deletes it | [
"GetFlash",
"retrieves",
"a",
"flash",
"message",
"from",
"the",
"session",
"then",
"deletes",
"it"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/sessions.go#L347-L380 |
137,692 | volatiletech/abcweb | abcsessions/sessions.go | AddFlashObj | func AddFlashObj(overseer Overseer, w http.ResponseWriter, r *http.Request, key string, value interface{}) error {
mv, err := json.Marshal(value)
if err != nil {
return errors.Wrap(err, "unable to marshal flash value")
}
return AddFlash(overseer, w, r, key, string(mv))
} | go | func AddFlashObj(overseer Overseer, w http.ResponseWriter, r *http.Request, key string, value interface{}) error {
mv, err := json.Marshal(value)
if err != nil {
return errors.Wrap(err, "unable to marshal flash value")
}
return AddFlash(overseer, w, r, key, string(mv))
} | [
"func",
"AddFlashObj",
"(",
"overseer",
"Overseer",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"error",
"{",
"mv",
",",
"err",
":=",
"json",
".",
"Ma... | // AddFlashObj adds a flash message to the session that will be deleted when it is retrieved with GetFlash | [
"AddFlashObj",
"adds",
"a",
"flash",
"message",
"to",
"the",
"session",
"that",
"will",
"be",
"deleted",
"when",
"it",
"is",
"retrieved",
"with",
"GetFlash"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/sessions.go#L383-L390 |
137,693 | volatiletech/abcweb | abcsessions/sessions.go | GetFlashObj | func GetFlashObj(overseer Overseer, w http.ResponseWriter, r *http.Request, key string, pointer interface{}) error {
val, err := GetFlash(overseer, w, r, key)
if err != nil {
return errors.Wrap(err, "unable to get flash object")
}
return json.Unmarshal([]byte(val), pointer)
} | go | func GetFlashObj(overseer Overseer, w http.ResponseWriter, r *http.Request, key string, pointer interface{}) error {
val, err := GetFlash(overseer, w, r, key)
if err != nil {
return errors.Wrap(err, "unable to get flash object")
}
return json.Unmarshal([]byte(val), pointer)
} | [
"func",
"GetFlashObj",
"(",
"overseer",
"Overseer",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"key",
"string",
",",
"pointer",
"interface",
"{",
"}",
")",
"error",
"{",
"val",
",",
"err",
":=",
"GetFlash",
"("... | // GetFlashObj unmarshals a flash message from the session into the users pointer
// then deletes it from the session. | [
"GetFlashObj",
"unmarshals",
"a",
"flash",
"message",
"from",
"the",
"session",
"into",
"the",
"users",
"pointer",
"then",
"deletes",
"it",
"from",
"the",
"session",
"."
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/sessions.go#L394-L401 |
137,694 | volatiletech/abcweb | abcsessions/disk.go | NewDiskStorer | func NewDiskStorer(folderPath string, maxAge, cleanInterval time.Duration) (*DiskStorer, error) {
if (maxAge != 0 && cleanInterval == 0) || (cleanInterval != 0 && maxAge == 0) {
panic("if max age or clean interval is set, the other must also be set")
}
d := &DiskStorer{
folderPath: folderPath,
maxAge: ... | go | func NewDiskStorer(folderPath string, maxAge, cleanInterval time.Duration) (*DiskStorer, error) {
if (maxAge != 0 && cleanInterval == 0) || (cleanInterval != 0 && maxAge == 0) {
panic("if max age or clean interval is set, the other must also be set")
}
d := &DiskStorer{
folderPath: folderPath,
maxAge: ... | [
"func",
"NewDiskStorer",
"(",
"folderPath",
"string",
",",
"maxAge",
",",
"cleanInterval",
"time",
".",
"Duration",
")",
"(",
"*",
"DiskStorer",
",",
"error",
")",
"{",
"if",
"(",
"maxAge",
"!=",
"0",
"&&",
"cleanInterval",
"==",
"0",
")",
"||",
"(",
"... | // NewDiskStorer initializes and returns a new DiskStorer object.
// It takes the maxAge of how long each session should live on disk,
// and a cleanInterval duration which defines how often the clean
// task should check for maxAge expired sessions to be removed from disk.
// Persistent storage can be attained by sett... | [
"NewDiskStorer",
"initializes",
"and",
"returns",
"a",
"new",
"DiskStorer",
"object",
".",
"It",
"takes",
"the",
"maxAge",
"of",
"how",
"long",
"each",
"session",
"should",
"live",
"on",
"disk",
"and",
"a",
"cleanInterval",
"duration",
"which",
"defines",
"how... | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/disk.go#L48-L69 |
137,695 | volatiletech/abcweb | abcsessions/disk.go | All | func (d *DiskStorer) All() ([]string, error) {
files, err := ioutil.ReadDir(d.folderPath)
if err != nil {
return []string{}, errors.Wrapf(err, "unable to read directory: %s", d.folderPath)
}
sessions := make([]string, len(files))
for i := 0; i < len(files); i++ {
sessions[i] = files[i].Name()
}
return ses... | go | func (d *DiskStorer) All() ([]string, error) {
files, err := ioutil.ReadDir(d.folderPath)
if err != nil {
return []string{}, errors.Wrapf(err, "unable to read directory: %s", d.folderPath)
}
sessions := make([]string, len(files))
for i := 0; i < len(files); i++ {
sessions[i] = files[i].Name()
}
return ses... | [
"func",
"(",
"d",
"*",
"DiskStorer",
")",
"All",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"files",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"d",
".",
"folderPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"[... | // All keys in the disk store | [
"All",
"keys",
"in",
"the",
"disk",
"store"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/disk.go#L72-L85 |
137,696 | volatiletech/abcweb | abcsessions/disk.go | StartCleaner | func (d *DiskStorer) StartCleaner() {
if d.maxAge == 0 || d.cleanInterval == 0 {
panic("both max age and clean interval must be set to non-zero")
}
// init quit chan
d.quit = make(chan struct{})
d.wg.Add(1)
// Start the cleaner infinite loop go routine.
// StopCleaner() can be used to kill this go routine.
... | go | func (d *DiskStorer) StartCleaner() {
if d.maxAge == 0 || d.cleanInterval == 0 {
panic("both max age and clean interval must be set to non-zero")
}
// init quit chan
d.quit = make(chan struct{})
d.wg.Add(1)
// Start the cleaner infinite loop go routine.
// StopCleaner() can be used to kill this go routine.
... | [
"func",
"(",
"d",
"*",
"DiskStorer",
")",
"StartCleaner",
"(",
")",
"{",
"if",
"d",
".",
"maxAge",
"==",
"0",
"||",
"d",
".",
"cleanInterval",
"==",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// init quit chan",
"d",
".",
"quit",
... | // StartCleaner starts the disk session cleaner go routine. This go routine
// will delete expired disk sessions on the cleanInterval interval. | [
"StartCleaner",
"starts",
"the",
"disk",
"session",
"cleaner",
"go",
"routine",
".",
"This",
"go",
"routine",
"will",
"delete",
"expired",
"disk",
"sessions",
"on",
"the",
"cleanInterval",
"interval",
"."
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/disk.go#L167-L180 |
137,697 | volatiletech/abcweb | abcsessions/disk.go | Clean | func (d *DiskStorer) Clean() {
t := time.Now().UTC()
files, err := ioutil.ReadDir(d.folderPath)
if err != nil {
panic(err)
}
for _, file := range files {
tspec := times.Get(file)
// File is expired
if tspec.AccessTime().UTC().UTC().Add(d.maxAge).Before(t) {
filePath := path.Join(d.folderPath, file.N... | go | func (d *DiskStorer) Clean() {
t := time.Now().UTC()
files, err := ioutil.ReadDir(d.folderPath)
if err != nil {
panic(err)
}
for _, file := range files {
tspec := times.Get(file)
// File is expired
if tspec.AccessTime().UTC().UTC().Add(d.maxAge).Before(t) {
filePath := path.Join(d.folderPath, file.N... | [
"func",
"(",
"d",
"*",
"DiskStorer",
")",
"Clean",
"(",
")",
"{",
"t",
":=",
"time",
".",
"Now",
"(",
")",
".",
"UTC",
"(",
")",
"\n\n",
"files",
",",
"err",
":=",
"ioutil",
".",
"ReadDir",
"(",
"d",
".",
"folderPath",
")",
"\n\n",
"if",
"err",... | // Clean checks all session files on disk to see if they are older than
// maxAge by checking their access time. If it finds an expired session file
// it will remove it from disk. | [
"Clean",
"checks",
"all",
"session",
"files",
"on",
"disk",
"to",
"see",
"if",
"they",
"are",
"older",
"than",
"maxAge",
"by",
"checking",
"their",
"access",
"time",
".",
"If",
"it",
"finds",
"an",
"expired",
"session",
"file",
"it",
"will",
"remove",
"i... | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/disk.go#L202-L239 |
137,698 | volatiletech/abcweb | abcsessions/storage_overseer.go | NewStorageOverseer | func NewStorageOverseer(opts CookieOptions, storer Storer) *StorageOverseer {
if len(opts.Name) == 0 {
panic("cookie name must be provided")
}
o := &StorageOverseer{
Storer: storer,
options: opts,
}
o.resetExpiryMiddleware.resetter = o
return o
} | go | func NewStorageOverseer(opts CookieOptions, storer Storer) *StorageOverseer {
if len(opts.Name) == 0 {
panic("cookie name must be provided")
}
o := &StorageOverseer{
Storer: storer,
options: opts,
}
o.resetExpiryMiddleware.resetter = o
return o
} | [
"func",
"NewStorageOverseer",
"(",
"opts",
"CookieOptions",
",",
"storer",
"Storer",
")",
"*",
"StorageOverseer",
"{",
"if",
"len",
"(",
"opts",
".",
"Name",
")",
"==",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"o",
":=",
"&",
"Stor... | // NewStorageOverseer returns a new storage overseer | [
"NewStorageOverseer",
"returns",
"a",
"new",
"storage",
"overseer"
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/storage_overseer.go#L18-L31 |
137,699 | volatiletech/abcweb | abcsessions/storage_overseer.go | Get | func (s *StorageOverseer) Get(w http.ResponseWriter, r *http.Request) (value string, err error) {
sessID, err := s.options.getCookieValue(w, r)
if err != nil {
return "", errors.Wrap(err, "unable to get session id from cookie")
}
val, err := s.Storer.Get(sessID)
if err != nil {
return "", errors.Wrap(err, "un... | go | func (s *StorageOverseer) Get(w http.ResponseWriter, r *http.Request) (value string, err error) {
sessID, err := s.options.getCookieValue(w, r)
if err != nil {
return "", errors.Wrap(err, "unable to get session id from cookie")
}
val, err := s.Storer.Get(sessID)
if err != nil {
return "", errors.Wrap(err, "un... | [
"func",
"(",
"s",
"*",
"StorageOverseer",
")",
"Get",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"value",
"string",
",",
"err",
"error",
")",
"{",
"sessID",
",",
"err",
":=",
"s",
".",
"options",
".",
... | // Get looks in the cookie for the session ID and retrieves the value string stored in the session. | [
"Get",
"looks",
"in",
"the",
"cookie",
"for",
"the",
"session",
"ID",
"and",
"retrieves",
"the",
"value",
"string",
"stored",
"in",
"the",
"session",
"."
] | 9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66 | https://github.com/volatiletech/abcweb/blob/9e9ffe4fa86ed4e557dcc4b9d59ca5d3d91c6a66/abcsessions/storage_overseer.go#L34-L46 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.