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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
133,900 | grpc-ecosystem/grpc-gateway | runtime/convert.go | Int32 | func Int32(val string) (int32, error) {
i, err := strconv.ParseInt(val, 0, 32)
if err != nil {
return 0, err
}
return int32(i), nil
} | go | func Int32(val string) (int32, error) {
i, err := strconv.ParseInt(val, 0, 32)
if err != nil {
return 0, err
}
return int32(i), nil
} | [
"func",
"Int32",
"(",
"val",
"string",
")",
"(",
"int32",
",",
"error",
")",
"{",
"i",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"val",
",",
"0",
",",
"32",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
"... | // Int32 converts the given string representation of an integer into int32. | [
"Int32",
"converts",
"the",
"given",
"string",
"representation",
"of",
"an",
"integer",
"into",
"int32",
"."
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L112-L118 |
133,901 | grpc-ecosystem/grpc-gateway | runtime/convert.go | Int32Slice | func Int32Slice(val, sep string) ([]int32, error) {
s := strings.Split(val, sep)
values := make([]int32, len(s))
for i, v := range s {
value, err := Int32(v)
if err != nil {
return values, err
}
values[i] = value
}
return values, nil
} | go | func Int32Slice(val, sep string) ([]int32, error) {
s := strings.Split(val, sep)
values := make([]int32, len(s))
for i, v := range s {
value, err := Int32(v)
if err != nil {
return values, err
}
values[i] = value
}
return values, nil
} | [
"func",
"Int32Slice",
"(",
"val",
",",
"sep",
"string",
")",
"(",
"[",
"]",
"int32",
",",
"error",
")",
"{",
"s",
":=",
"strings",
".",
"Split",
"(",
"val",
",",
"sep",
")",
"\n",
"values",
":=",
"make",
"(",
"[",
"]",
"int32",
",",
"len",
"(",... | // Int32Slice converts 'val' where individual integers are separated by
// 'sep' into a int32 slice. | [
"Int32Slice",
"converts",
"val",
"where",
"individual",
"integers",
"are",
"separated",
"by",
"sep",
"into",
"a",
"int32",
"slice",
"."
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L122-L133 |
133,902 | grpc-ecosystem/grpc-gateway | runtime/convert.go | Uint64Slice | func Uint64Slice(val, sep string) ([]uint64, error) {
s := strings.Split(val, sep)
values := make([]uint64, len(s))
for i, v := range s {
value, err := Uint64(v)
if err != nil {
return values, err
}
values[i] = value
}
return values, nil
} | go | func Uint64Slice(val, sep string) ([]uint64, error) {
s := strings.Split(val, sep)
values := make([]uint64, len(s))
for i, v := range s {
value, err := Uint64(v)
if err != nil {
return values, err
}
values[i] = value
}
return values, nil
} | [
"func",
"Uint64Slice",
"(",
"val",
",",
"sep",
"string",
")",
"(",
"[",
"]",
"uint64",
",",
"error",
")",
"{",
"s",
":=",
"strings",
".",
"Split",
"(",
"val",
",",
"sep",
")",
"\n",
"values",
":=",
"make",
"(",
"[",
"]",
"uint64",
",",
"len",
"... | // Uint64Slice converts 'val' where individual integers are separated by
// 'sep' into a uint64 slice. | [
"Uint64Slice",
"converts",
"val",
"where",
"individual",
"integers",
"are",
"separated",
"by",
"sep",
"into",
"a",
"uint64",
"slice",
"."
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L142-L153 |
133,903 | grpc-ecosystem/grpc-gateway | runtime/convert.go | Uint32 | func Uint32(val string) (uint32, error) {
i, err := strconv.ParseUint(val, 0, 32)
if err != nil {
return 0, err
}
return uint32(i), nil
} | go | func Uint32(val string) (uint32, error) {
i, err := strconv.ParseUint(val, 0, 32)
if err != nil {
return 0, err
}
return uint32(i), nil
} | [
"func",
"Uint32",
"(",
"val",
"string",
")",
"(",
"uint32",
",",
"error",
")",
"{",
"i",
",",
"err",
":=",
"strconv",
".",
"ParseUint",
"(",
"val",
",",
"0",
",",
"32",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
",",
"err",
"\n",
... | // Uint32 converts the given string representation of an integer into uint32. | [
"Uint32",
"converts",
"the",
"given",
"string",
"representation",
"of",
"an",
"integer",
"into",
"uint32",
"."
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L156-L162 |
133,904 | grpc-ecosystem/grpc-gateway | runtime/convert.go | Uint32Slice | func Uint32Slice(val, sep string) ([]uint32, error) {
s := strings.Split(val, sep)
values := make([]uint32, len(s))
for i, v := range s {
value, err := Uint32(v)
if err != nil {
return values, err
}
values[i] = value
}
return values, nil
} | go | func Uint32Slice(val, sep string) ([]uint32, error) {
s := strings.Split(val, sep)
values := make([]uint32, len(s))
for i, v := range s {
value, err := Uint32(v)
if err != nil {
return values, err
}
values[i] = value
}
return values, nil
} | [
"func",
"Uint32Slice",
"(",
"val",
",",
"sep",
"string",
")",
"(",
"[",
"]",
"uint32",
",",
"error",
")",
"{",
"s",
":=",
"strings",
".",
"Split",
"(",
"val",
",",
"sep",
")",
"\n",
"values",
":=",
"make",
"(",
"[",
"]",
"uint32",
",",
"len",
"... | // Uint32Slice converts 'val' where individual integers are separated by
// 'sep' into a uint32 slice. | [
"Uint32Slice",
"converts",
"val",
"where",
"individual",
"integers",
"are",
"separated",
"by",
"sep",
"into",
"a",
"uint32",
"slice",
"."
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L166-L177 |
133,905 | grpc-ecosystem/grpc-gateway | runtime/convert.go | Bytes | func Bytes(val string) ([]byte, error) {
b, err := base64.StdEncoding.DecodeString(val)
if err != nil {
b, err = base64.URLEncoding.DecodeString(val)
if err != nil {
return nil, err
}
}
return b, nil
} | go | func Bytes(val string) ([]byte, error) {
b, err := base64.StdEncoding.DecodeString(val)
if err != nil {
b, err = base64.URLEncoding.DecodeString(val)
if err != nil {
return nil, err
}
}
return b, nil
} | [
"func",
"Bytes",
"(",
"val",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"base64",
".",
"StdEncoding",
".",
"DecodeString",
"(",
"val",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"b",
",",
"err",
"=",
"ba... | // Bytes converts the given string representation of a byte sequence into a slice of bytes
// A bytes sequence is encoded in URL-safe base64 without padding | [
"Bytes",
"converts",
"the",
"given",
"string",
"representation",
"of",
"a",
"byte",
"sequence",
"into",
"a",
"slice",
"of",
"bytes",
"A",
"bytes",
"sequence",
"is",
"encoded",
"in",
"URL",
"-",
"safe",
"base64",
"without",
"padding"
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L181-L190 |
133,906 | grpc-ecosystem/grpc-gateway | runtime/convert.go | BytesSlice | func BytesSlice(val, sep string) ([][]byte, error) {
s := strings.Split(val, sep)
values := make([][]byte, len(s))
for i, v := range s {
value, err := Bytes(v)
if err != nil {
return values, err
}
values[i] = value
}
return values, nil
} | go | func BytesSlice(val, sep string) ([][]byte, error) {
s := strings.Split(val, sep)
values := make([][]byte, len(s))
for i, v := range s {
value, err := Bytes(v)
if err != nil {
return values, err
}
values[i] = value
}
return values, nil
} | [
"func",
"BytesSlice",
"(",
"val",
",",
"sep",
"string",
")",
"(",
"[",
"]",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"s",
":=",
"strings",
".",
"Split",
"(",
"val",
",",
"sep",
")",
"\n",
"values",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"byt... | // BytesSlice converts 'val' where individual bytes sequences, encoded in URL-safe
// base64 without padding, are separated by 'sep' into a slice of bytes slices slice. | [
"BytesSlice",
"converts",
"val",
"where",
"individual",
"bytes",
"sequences",
"encoded",
"in",
"URL",
"-",
"safe",
"base64",
"without",
"padding",
"are",
"separated",
"by",
"sep",
"into",
"a",
"slice",
"of",
"bytes",
"slices",
"slice",
"."
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L194-L205 |
133,907 | grpc-ecosystem/grpc-gateway | runtime/convert.go | Timestamp | func Timestamp(val string) (*timestamp.Timestamp, error) {
var r *timestamp.Timestamp
err := jsonpb.UnmarshalString(val, r)
return r, err
} | go | func Timestamp(val string) (*timestamp.Timestamp, error) {
var r *timestamp.Timestamp
err := jsonpb.UnmarshalString(val, r)
return r, err
} | [
"func",
"Timestamp",
"(",
"val",
"string",
")",
"(",
"*",
"timestamp",
".",
"Timestamp",
",",
"error",
")",
"{",
"var",
"r",
"*",
"timestamp",
".",
"Timestamp",
"\n",
"err",
":=",
"jsonpb",
".",
"UnmarshalString",
"(",
"val",
",",
"r",
")",
"\n",
"re... | // Timestamp converts the given RFC3339 formatted string into a timestamp.Timestamp. | [
"Timestamp",
"converts",
"the",
"given",
"RFC3339",
"formatted",
"string",
"into",
"a",
"timestamp",
".",
"Timestamp",
"."
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L208-L212 |
133,908 | grpc-ecosystem/grpc-gateway | runtime/convert.go | Duration | func Duration(val string) (*duration.Duration, error) {
var r *duration.Duration
err := jsonpb.UnmarshalString(val, r)
return r, err
} | go | func Duration(val string) (*duration.Duration, error) {
var r *duration.Duration
err := jsonpb.UnmarshalString(val, r)
return r, err
} | [
"func",
"Duration",
"(",
"val",
"string",
")",
"(",
"*",
"duration",
".",
"Duration",
",",
"error",
")",
"{",
"var",
"r",
"*",
"duration",
".",
"Duration",
"\n",
"err",
":=",
"jsonpb",
".",
"UnmarshalString",
"(",
"val",
",",
"r",
")",
"\n",
"return"... | // Duration converts the given string into a timestamp.Duration. | [
"Duration",
"converts",
"the",
"given",
"string",
"into",
"a",
"timestamp",
".",
"Duration",
"."
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L215-L219 |
133,909 | grpc-ecosystem/grpc-gateway | runtime/convert.go | Enum | func Enum(val string, enumValMap map[string]int32) (int32, error) {
e, ok := enumValMap[val]
if ok {
return e, nil
}
i, err := Int32(val)
if err != nil {
return 0, fmt.Errorf("%s is not valid", val)
}
for _, v := range enumValMap {
if v == i {
return i, nil
}
}
return 0, fmt.Errorf("%s is not valid... | go | func Enum(val string, enumValMap map[string]int32) (int32, error) {
e, ok := enumValMap[val]
if ok {
return e, nil
}
i, err := Int32(val)
if err != nil {
return 0, fmt.Errorf("%s is not valid", val)
}
for _, v := range enumValMap {
if v == i {
return i, nil
}
}
return 0, fmt.Errorf("%s is not valid... | [
"func",
"Enum",
"(",
"val",
"string",
",",
"enumValMap",
"map",
"[",
"string",
"]",
"int32",
")",
"(",
"int32",
",",
"error",
")",
"{",
"e",
",",
"ok",
":=",
"enumValMap",
"[",
"val",
"]",
"\n",
"if",
"ok",
"{",
"return",
"e",
",",
"nil",
"\n",
... | // Enum converts the given string into an int32 that should be type casted into the
// correct enum proto type. | [
"Enum",
"converts",
"the",
"given",
"string",
"into",
"an",
"int32",
"that",
"should",
"be",
"type",
"casted",
"into",
"the",
"correct",
"enum",
"proto",
"type",
"."
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L223-L239 |
133,910 | grpc-ecosystem/grpc-gateway | runtime/convert.go | EnumSlice | func EnumSlice(val, sep string, enumValMap map[string]int32) ([]int32, error) {
s := strings.Split(val, sep)
values := make([]int32, len(s))
for i, v := range s {
value, err := Enum(v, enumValMap)
if err != nil {
return values, err
}
values[i] = value
}
return values, nil
} | go | func EnumSlice(val, sep string, enumValMap map[string]int32) ([]int32, error) {
s := strings.Split(val, sep)
values := make([]int32, len(s))
for i, v := range s {
value, err := Enum(v, enumValMap)
if err != nil {
return values, err
}
values[i] = value
}
return values, nil
} | [
"func",
"EnumSlice",
"(",
"val",
",",
"sep",
"string",
",",
"enumValMap",
"map",
"[",
"string",
"]",
"int32",
")",
"(",
"[",
"]",
"int32",
",",
"error",
")",
"{",
"s",
":=",
"strings",
".",
"Split",
"(",
"val",
",",
"sep",
")",
"\n",
"values",
":... | // EnumSlice converts 'val' where individual enums are separated by 'sep'
// into a int32 slice. Each individual int32 should be type casted into the
// correct enum proto type. | [
"EnumSlice",
"converts",
"val",
"where",
"individual",
"enums",
"are",
"separated",
"by",
"sep",
"into",
"a",
"int32",
"slice",
".",
"Each",
"individual",
"int32",
"should",
"be",
"type",
"casted",
"into",
"the",
"correct",
"enum",
"proto",
"type",
"."
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L244-L255 |
133,911 | grpc-ecosystem/grpc-gateway | runtime/convert.go | FloatValue | func FloatValue(val string) (*wrappers.FloatValue, error) {
parsedVal, err := Float32(val)
return &wrappers.FloatValue{Value: parsedVal}, err
} | go | func FloatValue(val string) (*wrappers.FloatValue, error) {
parsedVal, err := Float32(val)
return &wrappers.FloatValue{Value: parsedVal}, err
} | [
"func",
"FloatValue",
"(",
"val",
"string",
")",
"(",
"*",
"wrappers",
".",
"FloatValue",
",",
"error",
")",
"{",
"parsedVal",
",",
"err",
":=",
"Float32",
"(",
"val",
")",
"\n",
"return",
"&",
"wrappers",
".",
"FloatValue",
"{",
"Value",
":",
"parsedV... | // FloatValue well-known type support as wrapper around float32 type | [
"FloatValue",
"well",
"-",
"known",
"type",
"support",
"as",
"wrapper",
"around",
"float32",
"type"
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L267-L270 |
133,912 | grpc-ecosystem/grpc-gateway | runtime/convert.go | DoubleValue | func DoubleValue(val string) (*wrappers.DoubleValue, error) {
parsedVal, err := Float64(val)
return &wrappers.DoubleValue{Value: parsedVal}, err
} | go | func DoubleValue(val string) (*wrappers.DoubleValue, error) {
parsedVal, err := Float64(val)
return &wrappers.DoubleValue{Value: parsedVal}, err
} | [
"func",
"DoubleValue",
"(",
"val",
"string",
")",
"(",
"*",
"wrappers",
".",
"DoubleValue",
",",
"error",
")",
"{",
"parsedVal",
",",
"err",
":=",
"Float64",
"(",
"val",
")",
"\n",
"return",
"&",
"wrappers",
".",
"DoubleValue",
"{",
"Value",
":",
"pars... | // DoubleValue well-known type support as wrapper around float64 type | [
"DoubleValue",
"well",
"-",
"known",
"type",
"support",
"as",
"wrapper",
"around",
"float64",
"type"
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L273-L276 |
133,913 | grpc-ecosystem/grpc-gateway | runtime/convert.go | BoolValue | func BoolValue(val string) (*wrappers.BoolValue, error) {
parsedVal, err := Bool(val)
return &wrappers.BoolValue{Value: parsedVal}, err
} | go | func BoolValue(val string) (*wrappers.BoolValue, error) {
parsedVal, err := Bool(val)
return &wrappers.BoolValue{Value: parsedVal}, err
} | [
"func",
"BoolValue",
"(",
"val",
"string",
")",
"(",
"*",
"wrappers",
".",
"BoolValue",
",",
"error",
")",
"{",
"parsedVal",
",",
"err",
":=",
"Bool",
"(",
"val",
")",
"\n",
"return",
"&",
"wrappers",
".",
"BoolValue",
"{",
"Value",
":",
"parsedVal",
... | // BoolValue well-known type support as wrapper around bool type | [
"BoolValue",
"well",
"-",
"known",
"type",
"support",
"as",
"wrapper",
"around",
"bool",
"type"
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L279-L282 |
133,914 | grpc-ecosystem/grpc-gateway | runtime/convert.go | Int32Value | func Int32Value(val string) (*wrappers.Int32Value, error) {
parsedVal, err := Int32(val)
return &wrappers.Int32Value{Value: parsedVal}, err
} | go | func Int32Value(val string) (*wrappers.Int32Value, error) {
parsedVal, err := Int32(val)
return &wrappers.Int32Value{Value: parsedVal}, err
} | [
"func",
"Int32Value",
"(",
"val",
"string",
")",
"(",
"*",
"wrappers",
".",
"Int32Value",
",",
"error",
")",
"{",
"parsedVal",
",",
"err",
":=",
"Int32",
"(",
"val",
")",
"\n",
"return",
"&",
"wrappers",
".",
"Int32Value",
"{",
"Value",
":",
"parsedVal... | // Int32Value well-known type support as wrapper around int32 type | [
"Int32Value",
"well",
"-",
"known",
"type",
"support",
"as",
"wrapper",
"around",
"int32",
"type"
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L285-L288 |
133,915 | grpc-ecosystem/grpc-gateway | runtime/convert.go | UInt32Value | func UInt32Value(val string) (*wrappers.UInt32Value, error) {
parsedVal, err := Uint32(val)
return &wrappers.UInt32Value{Value: parsedVal}, err
} | go | func UInt32Value(val string) (*wrappers.UInt32Value, error) {
parsedVal, err := Uint32(val)
return &wrappers.UInt32Value{Value: parsedVal}, err
} | [
"func",
"UInt32Value",
"(",
"val",
"string",
")",
"(",
"*",
"wrappers",
".",
"UInt32Value",
",",
"error",
")",
"{",
"parsedVal",
",",
"err",
":=",
"Uint32",
"(",
"val",
")",
"\n",
"return",
"&",
"wrappers",
".",
"UInt32Value",
"{",
"Value",
":",
"parse... | // UInt32Value well-known type support as wrapper around uint32 type | [
"UInt32Value",
"well",
"-",
"known",
"type",
"support",
"as",
"wrapper",
"around",
"uint32",
"type"
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L291-L294 |
133,916 | grpc-ecosystem/grpc-gateway | runtime/convert.go | Int64Value | func Int64Value(val string) (*wrappers.Int64Value, error) {
parsedVal, err := Int64(val)
return &wrappers.Int64Value{Value: parsedVal}, err
} | go | func Int64Value(val string) (*wrappers.Int64Value, error) {
parsedVal, err := Int64(val)
return &wrappers.Int64Value{Value: parsedVal}, err
} | [
"func",
"Int64Value",
"(",
"val",
"string",
")",
"(",
"*",
"wrappers",
".",
"Int64Value",
",",
"error",
")",
"{",
"parsedVal",
",",
"err",
":=",
"Int64",
"(",
"val",
")",
"\n",
"return",
"&",
"wrappers",
".",
"Int64Value",
"{",
"Value",
":",
"parsedVal... | // Int64Value well-known type support as wrapper around int64 type | [
"Int64Value",
"well",
"-",
"known",
"type",
"support",
"as",
"wrapper",
"around",
"int64",
"type"
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L297-L300 |
133,917 | grpc-ecosystem/grpc-gateway | runtime/convert.go | UInt64Value | func UInt64Value(val string) (*wrappers.UInt64Value, error) {
parsedVal, err := Uint64(val)
return &wrappers.UInt64Value{Value: parsedVal}, err
} | go | func UInt64Value(val string) (*wrappers.UInt64Value, error) {
parsedVal, err := Uint64(val)
return &wrappers.UInt64Value{Value: parsedVal}, err
} | [
"func",
"UInt64Value",
"(",
"val",
"string",
")",
"(",
"*",
"wrappers",
".",
"UInt64Value",
",",
"error",
")",
"{",
"parsedVal",
",",
"err",
":=",
"Uint64",
"(",
"val",
")",
"\n",
"return",
"&",
"wrappers",
".",
"UInt64Value",
"{",
"Value",
":",
"parse... | // UInt64Value well-known type support as wrapper around uint64 type | [
"UInt64Value",
"well",
"-",
"known",
"type",
"support",
"as",
"wrapper",
"around",
"uint64",
"type"
] | 52a539ec166cf7380660e9c7ebde5206169d385d | https://github.com/grpc-ecosystem/grpc-gateway/blob/52a539ec166cf7380660e9c7ebde5206169d385d/runtime/convert.go#L303-L306 |
133,918 | tsenart/vegeta | lib/results.go | Equal | func (r Result) Equal(other Result) bool {
return r.Attack == other.Attack &&
r.Seq == other.Seq &&
r.Code == other.Code &&
r.Timestamp.Equal(other.Timestamp) &&
r.Latency == other.Latency &&
r.BytesIn == other.BytesIn &&
r.BytesOut == other.BytesOut &&
r.Error == other.Error &&
bytes.Equal(r.Body, oth... | go | func (r Result) Equal(other Result) bool {
return r.Attack == other.Attack &&
r.Seq == other.Seq &&
r.Code == other.Code &&
r.Timestamp.Equal(other.Timestamp) &&
r.Latency == other.Latency &&
r.BytesIn == other.BytesIn &&
r.BytesOut == other.BytesOut &&
r.Error == other.Error &&
bytes.Equal(r.Body, oth... | [
"func",
"(",
"r",
"Result",
")",
"Equal",
"(",
"other",
"Result",
")",
"bool",
"{",
"return",
"r",
".",
"Attack",
"==",
"other",
".",
"Attack",
"&&",
"r",
".",
"Seq",
"==",
"other",
".",
"Seq",
"&&",
"r",
".",
"Code",
"==",
"other",
".",
"Code",
... | // Equal returns true if the given Result is equal to the receiver. | [
"Equal",
"returns",
"true",
"if",
"the",
"given",
"Result",
"is",
"equal",
"to",
"the",
"receiver",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/results.go#L39-L49 |
133,919 | tsenart/vegeta | lib/results.go | DecoderFor | func DecoderFor(r io.Reader) Decoder {
var buf bytes.Buffer
for _, dec := range []DecoderFactory{
NewDecoder,
NewJSONDecoder,
NewCSVDecoder,
} {
rd := io.MultiReader(bytes.NewReader(buf.Bytes()), io.TeeReader(r, &buf))
if err := dec(rd).Decode(&Result{}); err == nil {
return dec(io.MultiReader(&buf, r))... | go | func DecoderFor(r io.Reader) Decoder {
var buf bytes.Buffer
for _, dec := range []DecoderFactory{
NewDecoder,
NewJSONDecoder,
NewCSVDecoder,
} {
rd := io.MultiReader(bytes.NewReader(buf.Bytes()), io.TeeReader(r, &buf))
if err := dec(rd).Decode(&Result{}); err == nil {
return dec(io.MultiReader(&buf, r))... | [
"func",
"DecoderFor",
"(",
"r",
"io",
".",
"Reader",
")",
"Decoder",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"for",
"_",
",",
"dec",
":=",
"range",
"[",
"]",
"DecoderFactory",
"{",
"NewDecoder",
",",
"NewJSONDecoder",
",",
"NewCSVDecoder",
",",
... | // DecoderFor automatically detects the encoding of the first few bytes in
// the given io.Reader and then returns the corresponding Decoder or nil
// in case of failing to detect a supported encoding. | [
"DecoderFor",
"automatically",
"detects",
"the",
"encoding",
"of",
"the",
"first",
"few",
"bytes",
"in",
"the",
"given",
"io",
".",
"Reader",
"and",
"then",
"returns",
"the",
"corresponding",
"Decoder",
"or",
"nil",
"in",
"case",
"of",
"failing",
"to",
"dete... | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/results.go#L76-L89 |
133,920 | tsenart/vegeta | lib/results.go | NewRoundRobinDecoder | func NewRoundRobinDecoder(dec ...Decoder) Decoder {
// Optimization for single Decoder case.
if len(dec) == 1 {
return dec[0]
}
var seq uint64
return func(r *Result) (err error) {
for range dec {
robin := seq % uint64(len(dec))
seq++
if err = dec[robin].Decode(r); err != nil {
continue
}
re... | go | func NewRoundRobinDecoder(dec ...Decoder) Decoder {
// Optimization for single Decoder case.
if len(dec) == 1 {
return dec[0]
}
var seq uint64
return func(r *Result) (err error) {
for range dec {
robin := seq % uint64(len(dec))
seq++
if err = dec[robin].Decode(r); err != nil {
continue
}
re... | [
"func",
"NewRoundRobinDecoder",
"(",
"dec",
"...",
"Decoder",
")",
"Decoder",
"{",
"// Optimization for single Decoder case.",
"if",
"len",
"(",
"dec",
")",
"==",
"1",
"{",
"return",
"dec",
"[",
"0",
"]",
"\n",
"}",
"\n\n",
"var",
"seq",
"uint64",
"\n",
"r... | // NewRoundRobinDecoder returns a new Decoder that round robins across the
// given Decoders on every invocation or decoding error. | [
"NewRoundRobinDecoder",
"returns",
"a",
"new",
"Decoder",
"that",
"round",
"robins",
"across",
"the",
"given",
"Decoders",
"on",
"every",
"invocation",
"or",
"decoding",
"error",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/results.go#L93-L111 |
133,921 | tsenart/vegeta | lib/results.go | NewDecoder | func NewDecoder(rd io.Reader) Decoder {
dec := gob.NewDecoder(rd)
return func(r *Result) error { return dec.Decode(r) }
} | go | func NewDecoder(rd io.Reader) Decoder {
dec := gob.NewDecoder(rd)
return func(r *Result) error { return dec.Decode(r) }
} | [
"func",
"NewDecoder",
"(",
"rd",
"io",
".",
"Reader",
")",
"Decoder",
"{",
"dec",
":=",
"gob",
".",
"NewDecoder",
"(",
"rd",
")",
"\n",
"return",
"func",
"(",
"r",
"*",
"Result",
")",
"error",
"{",
"return",
"dec",
".",
"Decode",
"(",
"r",
")",
"... | // NewDecoder returns a new gob Decoder for the given io.Reader. | [
"NewDecoder",
"returns",
"a",
"new",
"gob",
"Decoder",
"for",
"the",
"given",
"io",
".",
"Reader",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/results.go#L114-L117 |
133,922 | tsenart/vegeta | lib/results.go | NewEncoder | func NewEncoder(r io.Writer) Encoder {
enc := gob.NewEncoder(r)
return func(r *Result) error { return enc.Encode(r) }
} | go | func NewEncoder(r io.Writer) Encoder {
enc := gob.NewEncoder(r)
return func(r *Result) error { return enc.Encode(r) }
} | [
"func",
"NewEncoder",
"(",
"r",
"io",
".",
"Writer",
")",
"Encoder",
"{",
"enc",
":=",
"gob",
".",
"NewEncoder",
"(",
"r",
")",
"\n",
"return",
"func",
"(",
"r",
"*",
"Result",
")",
"error",
"{",
"return",
"enc",
".",
"Encode",
"(",
"r",
")",
"}"... | // NewEncoder returns a new Result encoder closure for the given io.Writer | [
"NewEncoder",
"returns",
"a",
"new",
"Result",
"encoder",
"closure",
"for",
"the",
"given",
"io",
".",
"Writer"
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/results.go#L127-L130 |
133,923 | tsenart/vegeta | lib/results.go | NewCSVDecoder | func NewCSVDecoder(rd io.Reader) Decoder {
dec := csv.NewReader(rd)
dec.FieldsPerRecord = 9
dec.TrimLeadingSpace = true
return func(r *Result) error {
rec, err := dec.Read()
if err != nil {
return err
}
ts, err := strconv.ParseInt(rec[0], 10, 64)
if err != nil {
return err
}
r.Timestamp = time... | go | func NewCSVDecoder(rd io.Reader) Decoder {
dec := csv.NewReader(rd)
dec.FieldsPerRecord = 9
dec.TrimLeadingSpace = true
return func(r *Result) error {
rec, err := dec.Read()
if err != nil {
return err
}
ts, err := strconv.ParseInt(rec[0], 10, 64)
if err != nil {
return err
}
r.Timestamp = time... | [
"func",
"NewCSVDecoder",
"(",
"rd",
"io",
".",
"Reader",
")",
"Decoder",
"{",
"dec",
":=",
"csv",
".",
"NewReader",
"(",
"rd",
")",
"\n",
"dec",
".",
"FieldsPerRecord",
"=",
"9",
"\n",
"dec",
".",
"TrimLeadingSpace",
"=",
"true",
"\n\n",
"return",
"fun... | // NewCSVDecoder returns a Decoder that decodes CSV encoded Results. | [
"NewCSVDecoder",
"returns",
"a",
"Decoder",
"that",
"decodes",
"CSV",
"encoded",
"Results",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/results.go#L166-L213 |
133,924 | tsenart/vegeta | lib/results.go | NewJSONDecoder | func NewJSONDecoder(r io.Reader) Decoder {
rd := bufio.NewReader(r)
return func(r *Result) (err error) {
var jl jlexer.Lexer
if jl.Data, err = rd.ReadSlice('\n'); err != nil {
return err
}
(*jsonResult)(r).decode(&jl)
return jl.Error()
}
} | go | func NewJSONDecoder(r io.Reader) Decoder {
rd := bufio.NewReader(r)
return func(r *Result) (err error) {
var jl jlexer.Lexer
if jl.Data, err = rd.ReadSlice('\n'); err != nil {
return err
}
(*jsonResult)(r).decode(&jl)
return jl.Error()
}
} | [
"func",
"NewJSONDecoder",
"(",
"r",
"io",
".",
"Reader",
")",
"Decoder",
"{",
"rd",
":=",
"bufio",
".",
"NewReader",
"(",
"r",
")",
"\n",
"return",
"func",
"(",
"r",
"*",
"Result",
")",
"(",
"err",
"error",
")",
"{",
"var",
"jl",
"jlexer",
".",
"... | // NewJSONDecoder returns a Decoder that decodes JSON encoded Results. | [
"NewJSONDecoder",
"returns",
"a",
"Decoder",
"that",
"decodes",
"JSON",
"encoded",
"Results",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/results.go#L231-L241 |
133,925 | tsenart/vegeta | internal/resolver/resolver.go | dial | func (r *resolver) dial(ctx context.Context, network, _ string) (net.Conn, error) {
return r.dialer.DialContext(ctx, network, r.address())
} | go | func (r *resolver) dial(ctx context.Context, network, _ string) (net.Conn, error) {
return r.dialer.DialContext(ctx, network, r.address())
} | [
"func",
"(",
"r",
"*",
"resolver",
")",
"dial",
"(",
"ctx",
"context",
".",
"Context",
",",
"network",
",",
"_",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"return",
"r",
".",
"dialer",
".",
"DialContext",
"(",
"ctx",
",",
"n... | // ignore the third parameter, as this represents the dns server address that
// we are overriding. | [
"ignore",
"the",
"third",
"parameter",
"as",
"this",
"represents",
"the",
"dns",
"server",
"address",
"that",
"we",
"are",
"overriding",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/internal/resolver/resolver.go#L72-L74 |
133,926 | tsenart/vegeta | lib/targets.go | Equal | func (t *Target) Equal(other *Target) bool {
switch {
case t == other:
return true
case t == nil || other == nil:
return false
default:
equal := t.Method == other.Method &&
t.URL == other.URL &&
bytes.Equal(t.Body, other.Body) &&
len(t.Header) == len(other.Header)
if !equal {
return false
}
... | go | func (t *Target) Equal(other *Target) bool {
switch {
case t == other:
return true
case t == nil || other == nil:
return false
default:
equal := t.Method == other.Method &&
t.URL == other.URL &&
bytes.Equal(t.Body, other.Body) &&
len(t.Header) == len(other.Header)
if !equal {
return false
}
... | [
"func",
"(",
"t",
"*",
"Target",
")",
"Equal",
"(",
"other",
"*",
"Target",
")",
"bool",
"{",
"switch",
"{",
"case",
"t",
"==",
"other",
":",
"return",
"true",
"\n",
"case",
"t",
"==",
"nil",
"||",
"other",
"==",
"nil",
":",
"return",
"false",
"\... | // Equal returns true if the target is equal to the other given target. | [
"Equal",
"returns",
"true",
"if",
"the",
"target",
"is",
"equal",
"to",
"the",
"other",
"given",
"target",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/targets.go#L49-L79 |
133,927 | tsenart/vegeta | lib/targets.go | NewJSONTargetEncoder | func NewJSONTargetEncoder(w io.Writer) TargetEncoder {
var jw jwriter.Writer
return func(t *Target) error {
(*jsonTarget)(t).encode(&jw)
if jw.Error != nil {
return jw.Error
}
jw.RawByte('\n')
_, err := jw.DumpTo(w)
return err
}
} | go | func NewJSONTargetEncoder(w io.Writer) TargetEncoder {
var jw jwriter.Writer
return func(t *Target) error {
(*jsonTarget)(t).encode(&jw)
if jw.Error != nil {
return jw.Error
}
jw.RawByte('\n')
_, err := jw.DumpTo(w)
return err
}
} | [
"func",
"NewJSONTargetEncoder",
"(",
"w",
"io",
".",
"Writer",
")",
"TargetEncoder",
"{",
"var",
"jw",
"jwriter",
".",
"Writer",
"\n",
"return",
"func",
"(",
"t",
"*",
"Target",
")",
"error",
"{",
"(",
"*",
"jsonTarget",
")",
"(",
"t",
")",
".",
"enc... | // NewJSONTargetEncoder returns a TargetEncoder that encods Targets in the JSON format. | [
"NewJSONTargetEncoder",
"returns",
"a",
"TargetEncoder",
"that",
"encods",
"Targets",
"in",
"the",
"JSON",
"format",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/targets.go#L197-L208 |
133,928 | tsenart/vegeta | lib/targets.go | NewStaticTargeter | func NewStaticTargeter(tgts ...Target) Targeter {
i := int64(-1)
return func(tgt *Target) error {
if tgt == nil {
return ErrNilTarget
}
*tgt = tgts[atomic.AddInt64(&i, 1)%int64(len(tgts))]
return nil
}
} | go | func NewStaticTargeter(tgts ...Target) Targeter {
i := int64(-1)
return func(tgt *Target) error {
if tgt == nil {
return ErrNilTarget
}
*tgt = tgts[atomic.AddInt64(&i, 1)%int64(len(tgts))]
return nil
}
} | [
"func",
"NewStaticTargeter",
"(",
"tgts",
"...",
"Target",
")",
"Targeter",
"{",
"i",
":=",
"int64",
"(",
"-",
"1",
")",
"\n",
"return",
"func",
"(",
"tgt",
"*",
"Target",
")",
"error",
"{",
"if",
"tgt",
"==",
"nil",
"{",
"return",
"ErrNilTarget",
"\... | // NewStaticTargeter returns a Targeter which round-robins over the passed
// Targets. | [
"NewStaticTargeter",
"returns",
"a",
"Targeter",
"which",
"round",
"-",
"robins",
"over",
"the",
"passed",
"Targets",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/targets.go#L212-L221 |
133,929 | tsenart/vegeta | lib/targets.go | ReadAllTargets | func ReadAllTargets(t Targeter) (tgts []Target, err error) {
for {
var tgt Target
if err = t(&tgt); err == ErrNoTargets {
break
} else if err != nil {
return nil, err
}
tgts = append(tgts, tgt)
}
if len(tgts) == 0 {
return nil, ErrNoTargets
}
return tgts, nil
} | go | func ReadAllTargets(t Targeter) (tgts []Target, err error) {
for {
var tgt Target
if err = t(&tgt); err == ErrNoTargets {
break
} else if err != nil {
return nil, err
}
tgts = append(tgts, tgt)
}
if len(tgts) == 0 {
return nil, ErrNoTargets
}
return tgts, nil
} | [
"func",
"ReadAllTargets",
"(",
"t",
"Targeter",
")",
"(",
"tgts",
"[",
"]",
"Target",
",",
"err",
"error",
")",
"{",
"for",
"{",
"var",
"tgt",
"Target",
"\n",
"if",
"err",
"=",
"t",
"(",
"&",
"tgt",
")",
";",
"err",
"==",
"ErrNoTargets",
"{",
"br... | // ReadAllTargets eagerly reads all Targets out of the provided Targeter. | [
"ReadAllTargets",
"eagerly",
"reads",
"all",
"Targets",
"out",
"of",
"the",
"provided",
"Targeter",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/targets.go#L224-L240 |
133,930 | tsenart/vegeta | lib/histogram.go | Add | func (h *Histogram) Add(r *Result) {
if len(h.Counts) != len(h.Buckets) {
h.Counts = make([]uint64, len(h.Buckets))
}
var i int
for ; i < len(h.Buckets)-1; i++ {
if r.Latency >= h.Buckets[i] && r.Latency < h.Buckets[i+1] {
break
}
}
h.Total++
h.Counts[i]++
} | go | func (h *Histogram) Add(r *Result) {
if len(h.Counts) != len(h.Buckets) {
h.Counts = make([]uint64, len(h.Buckets))
}
var i int
for ; i < len(h.Buckets)-1; i++ {
if r.Latency >= h.Buckets[i] && r.Latency < h.Buckets[i+1] {
break
}
}
h.Total++
h.Counts[i]++
} | [
"func",
"(",
"h",
"*",
"Histogram",
")",
"Add",
"(",
"r",
"*",
"Result",
")",
"{",
"if",
"len",
"(",
"h",
".",
"Counts",
")",
"!=",
"len",
"(",
"h",
".",
"Buckets",
")",
"{",
"h",
".",
"Counts",
"=",
"make",
"(",
"[",
"]",
"uint64",
",",
"l... | // Add implements the Add method of the Report interface by finding the right
// Bucket for the given Result latency and increasing its count by one as well
// as the total count. | [
"Add",
"implements",
"the",
"Add",
"method",
"of",
"the",
"Report",
"interface",
"by",
"finding",
"the",
"right",
"Bucket",
"for",
"the",
"given",
"Result",
"latency",
"and",
"increasing",
"its",
"count",
"by",
"one",
"as",
"well",
"as",
"the",
"total",
"c... | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/histogram.go#L22-L36 |
133,931 | tsenart/vegeta | lib/histogram.go | Nth | func (bs Buckets) Nth(i int) (left, right string) {
if i >= len(bs)-1 {
return bs[i].String(), "+Inf"
}
return bs[i].String(), bs[i+1].String()
} | go | func (bs Buckets) Nth(i int) (left, right string) {
if i >= len(bs)-1 {
return bs[i].String(), "+Inf"
}
return bs[i].String(), bs[i+1].String()
} | [
"func",
"(",
"bs",
"Buckets",
")",
"Nth",
"(",
"i",
"int",
")",
"(",
"left",
",",
"right",
"string",
")",
"{",
"if",
"i",
">=",
"len",
"(",
"bs",
")",
"-",
"1",
"{",
"return",
"bs",
"[",
"i",
"]",
".",
"String",
"(",
")",
",",
"\"",
"\"",
... | // Nth returns the nth bucket represented as a string. | [
"Nth",
"returns",
"the",
"nth",
"bucket",
"represented",
"as",
"a",
"string",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/histogram.go#L39-L44 |
133,932 | tsenart/vegeta | lib/attack.go | NewAttacker | func NewAttacker(opts ...func(*Attacker)) *Attacker {
a := &Attacker{
stopch: make(chan struct{}),
workers: DefaultWorkers,
maxBody: DefaultMaxBody,
began: time.Now(),
}
a.dialer = &net.Dialer{
LocalAddr: &net.TCPAddr{IP: DefaultLocalAddr.IP, Zone: DefaultLocalAddr.Zone},
KeepAlive: 30 * time.Second,... | go | func NewAttacker(opts ...func(*Attacker)) *Attacker {
a := &Attacker{
stopch: make(chan struct{}),
workers: DefaultWorkers,
maxBody: DefaultMaxBody,
began: time.Now(),
}
a.dialer = &net.Dialer{
LocalAddr: &net.TCPAddr{IP: DefaultLocalAddr.IP, Zone: DefaultLocalAddr.Zone},
KeepAlive: 30 * time.Second,... | [
"func",
"NewAttacker",
"(",
"opts",
"...",
"func",
"(",
"*",
"Attacker",
")",
")",
"*",
"Attacker",
"{",
"a",
":=",
"&",
"Attacker",
"{",
"stopch",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
",",
"workers",
":",
"DefaultWorkers",
",",
"maxBod... | // NewAttacker returns a new Attacker with default options which are overridden
// by the optionally provided opts. | [
"NewAttacker",
"returns",
"a",
"new",
"Attacker",
"with",
"default",
"options",
"which",
"are",
"overridden",
"by",
"the",
"optionally",
"provided",
"opts",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/attack.go#L59-L87 |
133,933 | tsenart/vegeta | lib/attack.go | Connections | func Connections(n int) func(*Attacker) {
return func(a *Attacker) {
tr := a.client.Transport.(*http.Transport)
tr.MaxIdleConnsPerHost = n
}
} | go | func Connections(n int) func(*Attacker) {
return func(a *Attacker) {
tr := a.client.Transport.(*http.Transport)
tr.MaxIdleConnsPerHost = n
}
} | [
"func",
"Connections",
"(",
"n",
"int",
")",
"func",
"(",
"*",
"Attacker",
")",
"{",
"return",
"func",
"(",
"a",
"*",
"Attacker",
")",
"{",
"tr",
":=",
"a",
".",
"client",
".",
"Transport",
".",
"(",
"*",
"http",
".",
"Transport",
")",
"\n",
"tr"... | // Connections returns a functional option which sets the number of maximum idle
// open connections per target host. | [
"Connections",
"returns",
"a",
"functional",
"option",
"which",
"sets",
"the",
"number",
"of",
"maximum",
"idle",
"open",
"connections",
"per",
"target",
"host",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/attack.go#L98-L103 |
133,934 | tsenart/vegeta | lib/attack.go | Redirects | func Redirects(n int) func(*Attacker) {
return func(a *Attacker) {
a.redirects = n
a.client.CheckRedirect = func(_ *http.Request, via []*http.Request) error {
switch {
case n == NoFollow:
return http.ErrUseLastResponse
case n < len(via):
return fmt.Errorf("stopped after %d redirects", n)
defaul... | go | func Redirects(n int) func(*Attacker) {
return func(a *Attacker) {
a.redirects = n
a.client.CheckRedirect = func(_ *http.Request, via []*http.Request) error {
switch {
case n == NoFollow:
return http.ErrUseLastResponse
case n < len(via):
return fmt.Errorf("stopped after %d redirects", n)
defaul... | [
"func",
"Redirects",
"(",
"n",
"int",
")",
"func",
"(",
"*",
"Attacker",
")",
"{",
"return",
"func",
"(",
"a",
"*",
"Attacker",
")",
"{",
"a",
".",
"redirects",
"=",
"n",
"\n",
"a",
".",
"client",
".",
"CheckRedirect",
"=",
"func",
"(",
"_",
"*",... | // Redirects returns a functional option which sets the maximum
// number of redirects an Attacker will follow. | [
"Redirects",
"returns",
"a",
"functional",
"option",
"which",
"sets",
"the",
"maximum",
"number",
"of",
"redirects",
"an",
"Attacker",
"will",
"follow",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/attack.go#L107-L121 |
133,935 | tsenart/vegeta | lib/attack.go | Proxy | func Proxy(proxy func(*http.Request) (*url.URL, error)) func(*Attacker) {
return func(a *Attacker) {
tr := a.client.Transport.(*http.Transport)
tr.Proxy = proxy
}
} | go | func Proxy(proxy func(*http.Request) (*url.URL, error)) func(*Attacker) {
return func(a *Attacker) {
tr := a.client.Transport.(*http.Transport)
tr.Proxy = proxy
}
} | [
"func",
"Proxy",
"(",
"proxy",
"func",
"(",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"url",
".",
"URL",
",",
"error",
")",
")",
"func",
"(",
"*",
"Attacker",
")",
"{",
"return",
"func",
"(",
"a",
"*",
"Attacker",
")",
"{",
"tr",
":=",
"a",
... | // Proxy returns a functional option which sets the `Proxy` field on
// the http.Client's Transport | [
"Proxy",
"returns",
"a",
"functional",
"option",
"which",
"sets",
"the",
"Proxy",
"field",
"on",
"the",
"http",
".",
"Client",
"s",
"Transport"
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/attack.go#L125-L130 |
133,936 | tsenart/vegeta | lib/attack.go | Timeout | func Timeout(d time.Duration) func(*Attacker) {
return func(a *Attacker) {
a.client.Timeout = d
}
} | go | func Timeout(d time.Duration) func(*Attacker) {
return func(a *Attacker) {
a.client.Timeout = d
}
} | [
"func",
"Timeout",
"(",
"d",
"time",
".",
"Duration",
")",
"func",
"(",
"*",
"Attacker",
")",
"{",
"return",
"func",
"(",
"a",
"*",
"Attacker",
")",
"{",
"a",
".",
"client",
".",
"Timeout",
"=",
"d",
"\n",
"}",
"\n",
"}"
] | // Timeout returns a functional option which sets the maximum amount of time
// an Attacker will wait for a request to be responded to and completely read. | [
"Timeout",
"returns",
"a",
"functional",
"option",
"which",
"sets",
"the",
"maximum",
"amount",
"of",
"time",
"an",
"Attacker",
"will",
"wait",
"for",
"a",
"request",
"to",
"be",
"responded",
"to",
"and",
"completely",
"read",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/attack.go#L134-L138 |
133,937 | tsenart/vegeta | lib/attack.go | LocalAddr | func LocalAddr(addr net.IPAddr) func(*Attacker) {
return func(a *Attacker) {
tr := a.client.Transport.(*http.Transport)
a.dialer.LocalAddr = &net.TCPAddr{IP: addr.IP, Zone: addr.Zone}
tr.Dial = a.dialer.Dial
}
} | go | func LocalAddr(addr net.IPAddr) func(*Attacker) {
return func(a *Attacker) {
tr := a.client.Transport.(*http.Transport)
a.dialer.LocalAddr = &net.TCPAddr{IP: addr.IP, Zone: addr.Zone}
tr.Dial = a.dialer.Dial
}
} | [
"func",
"LocalAddr",
"(",
"addr",
"net",
".",
"IPAddr",
")",
"func",
"(",
"*",
"Attacker",
")",
"{",
"return",
"func",
"(",
"a",
"*",
"Attacker",
")",
"{",
"tr",
":=",
"a",
".",
"client",
".",
"Transport",
".",
"(",
"*",
"http",
".",
"Transport",
... | // LocalAddr returns a functional option which sets the local address
// an Attacker will use with its requests. | [
"LocalAddr",
"returns",
"a",
"functional",
"option",
"which",
"sets",
"the",
"local",
"address",
"an",
"Attacker",
"will",
"use",
"with",
"its",
"requests",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/attack.go#L142-L148 |
133,938 | tsenart/vegeta | lib/attack.go | KeepAlive | func KeepAlive(keepalive bool) func(*Attacker) {
return func(a *Attacker) {
tr := a.client.Transport.(*http.Transport)
tr.DisableKeepAlives = !keepalive
if !keepalive {
a.dialer.KeepAlive = 0
tr.Dial = a.dialer.Dial
}
}
} | go | func KeepAlive(keepalive bool) func(*Attacker) {
return func(a *Attacker) {
tr := a.client.Transport.(*http.Transport)
tr.DisableKeepAlives = !keepalive
if !keepalive {
a.dialer.KeepAlive = 0
tr.Dial = a.dialer.Dial
}
}
} | [
"func",
"KeepAlive",
"(",
"keepalive",
"bool",
")",
"func",
"(",
"*",
"Attacker",
")",
"{",
"return",
"func",
"(",
"a",
"*",
"Attacker",
")",
"{",
"tr",
":=",
"a",
".",
"client",
".",
"Transport",
".",
"(",
"*",
"http",
".",
"Transport",
")",
"\n",... | // KeepAlive returns a functional option which toggles KeepAlive
// connections on the dialer and transport. | [
"KeepAlive",
"returns",
"a",
"functional",
"option",
"which",
"toggles",
"KeepAlive",
"connections",
"on",
"the",
"dialer",
"and",
"transport",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/attack.go#L152-L161 |
133,939 | tsenart/vegeta | lib/attack.go | H2C | func H2C(enabled bool) func(*Attacker) {
return func(a *Attacker) {
if tr := a.client.Transport.(*http.Transport); enabled {
a.client.Transport = &http2.Transport{
AllowHTTP: true,
DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) {
return tr.Dial(network, addr)
},
}
}
... | go | func H2C(enabled bool) func(*Attacker) {
return func(a *Attacker) {
if tr := a.client.Transport.(*http.Transport); enabled {
a.client.Transport = &http2.Transport{
AllowHTTP: true,
DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) {
return tr.Dial(network, addr)
},
}
}
... | [
"func",
"H2C",
"(",
"enabled",
"bool",
")",
"func",
"(",
"*",
"Attacker",
")",
"{",
"return",
"func",
"(",
"a",
"*",
"Attacker",
")",
"{",
"if",
"tr",
":=",
"a",
".",
"client",
".",
"Transport",
".",
"(",
"*",
"http",
".",
"Transport",
")",
";",
... | // H2C returns a functional option which enables H2C support on requests
// performed by an Attacker | [
"H2C",
"returns",
"a",
"functional",
"option",
"which",
"enables",
"H2C",
"support",
"on",
"requests",
"performed",
"by",
"an",
"Attacker"
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/attack.go#L186-L197 |
133,940 | tsenart/vegeta | lib/attack.go | UnixSocket | func UnixSocket(socket string) func(*Attacker) {
return func(a *Attacker) {
if tr, ok := a.client.Transport.(*http.Transport); socket != "" && ok {
tr.DialContext = func(_ context.Context, _, _ string) (net.Conn, error) {
return net.Dial("unix", socket)
}
}
}
} | go | func UnixSocket(socket string) func(*Attacker) {
return func(a *Attacker) {
if tr, ok := a.client.Transport.(*http.Transport); socket != "" && ok {
tr.DialContext = func(_ context.Context, _, _ string) (net.Conn, error) {
return net.Dial("unix", socket)
}
}
}
} | [
"func",
"UnixSocket",
"(",
"socket",
"string",
")",
"func",
"(",
"*",
"Attacker",
")",
"{",
"return",
"func",
"(",
"a",
"*",
"Attacker",
")",
"{",
"if",
"tr",
",",
"ok",
":=",
"a",
".",
"client",
".",
"Transport",
".",
"(",
"*",
"http",
".",
"Tra... | // UnixSocket changes the dialer for the attacker to use the specified unix socket file | [
"UnixSocket",
"changes",
"the",
"dialer",
"for",
"the",
"attacker",
"to",
"use",
"the",
"specified",
"unix",
"socket",
"file"
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/attack.go#L206-L214 |
133,941 | tsenart/vegeta | lib/attack.go | Client | func Client(c *http.Client) func(*Attacker) {
return func(a *Attacker) { a.client = *c }
} | go | func Client(c *http.Client) func(*Attacker) {
return func(a *Attacker) { a.client = *c }
} | [
"func",
"Client",
"(",
"c",
"*",
"http",
".",
"Client",
")",
"func",
"(",
"*",
"Attacker",
")",
"{",
"return",
"func",
"(",
"a",
"*",
"Attacker",
")",
"{",
"a",
".",
"client",
"=",
"*",
"c",
"}",
"\n",
"}"
] | // Client returns a functional option that allows you to bring your own http.Client | [
"Client",
"returns",
"a",
"functional",
"option",
"that",
"allows",
"you",
"to",
"bring",
"your",
"own",
"http",
".",
"Client"
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/attack.go#L217-L219 |
133,942 | tsenart/vegeta | lib/attack.go | Attack | func (a *Attacker) Attack(tr Targeter, r Rate, du time.Duration, name string) <-chan *Result {
var workers sync.WaitGroup
results := make(chan *Result)
ticks := make(chan uint64)
for i := uint64(0); i < a.workers; i++ {
workers.Add(1)
go a.attack(tr, name, &workers, ticks, results)
}
go func() {
defer clos... | go | func (a *Attacker) Attack(tr Targeter, r Rate, du time.Duration, name string) <-chan *Result {
var workers sync.WaitGroup
results := make(chan *Result)
ticks := make(chan uint64)
for i := uint64(0); i < a.workers; i++ {
workers.Add(1)
go a.attack(tr, name, &workers, ticks, results)
}
go func() {
defer clos... | [
"func",
"(",
"a",
"*",
"Attacker",
")",
"Attack",
"(",
"tr",
"Targeter",
",",
"r",
"Rate",
",",
"du",
"time",
".",
"Duration",
",",
"name",
"string",
")",
"<-",
"chan",
"*",
"Result",
"{",
"var",
"workers",
"sync",
".",
"WaitGroup",
"\n",
"results",
... | // Attack reads its Targets from the passed Targeter and attacks them at
// the rate specified for the given duration. When the duration is zero the attack
// runs until Stop is called. Results are sent to the returned channel as soon
// as they arrive and will have their Attack field set to the given name. | [
"Attack",
"reads",
"its",
"Targets",
"from",
"the",
"passed",
"Targeter",
"and",
"attacks",
"them",
"at",
"the",
"rate",
"specified",
"for",
"the",
"given",
"duration",
".",
"When",
"the",
"duration",
"is",
"zero",
"the",
"attack",
"runs",
"until",
"Stop",
... | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/attack.go#L236-L270 |
133,943 | tsenart/vegeta | lib/metrics.go | Add | func (m *Metrics) Add(r *Result) {
m.init()
m.Requests++
m.StatusCodes[strconv.Itoa(int(r.Code))]++
m.BytesOut.Total += r.BytesOut
m.BytesIn.Total += r.BytesIn
m.Latencies.Add(r.Latency)
if m.Earliest.IsZero() || m.Earliest.After(r.Timestamp) {
m.Earliest = r.Timestamp
}
if r.Timestamp.After(m.Latest) {
... | go | func (m *Metrics) Add(r *Result) {
m.init()
m.Requests++
m.StatusCodes[strconv.Itoa(int(r.Code))]++
m.BytesOut.Total += r.BytesOut
m.BytesIn.Total += r.BytesIn
m.Latencies.Add(r.Latency)
if m.Earliest.IsZero() || m.Earliest.After(r.Timestamp) {
m.Earliest = r.Timestamp
}
if r.Timestamp.After(m.Latest) {
... | [
"func",
"(",
"m",
"*",
"Metrics",
")",
"Add",
"(",
"r",
"*",
"Result",
")",
"{",
"m",
".",
"init",
"(",
")",
"\n\n",
"m",
".",
"Requests",
"++",
"\n",
"m",
".",
"StatusCodes",
"[",
"strconv",
".",
"Itoa",
"(",
"int",
"(",
"r",
".",
"Code",
")... | // Add implements the Add method of the Report interface by adding the given
// Result to Metrics. | [
"Add",
"implements",
"the",
"Add",
"method",
"of",
"the",
"Report",
"interface",
"by",
"adding",
"the",
"given",
"Result",
"to",
"Metrics",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/metrics.go#L46-L78 |
133,944 | tsenart/vegeta | lib/metrics.go | Close | func (m *Metrics) Close() {
m.init()
m.Rate = float64(m.Requests)
m.Duration = m.Latest.Sub(m.Earliest)
if secs := m.Duration.Seconds(); secs > 0 {
m.Rate /= secs
}
m.Wait = m.End.Sub(m.Latest)
m.BytesIn.Mean = float64(m.BytesIn.Total) / float64(m.Requests)
m.BytesOut.Mean = float64(m.BytesOut.Total) / float6... | go | func (m *Metrics) Close() {
m.init()
m.Rate = float64(m.Requests)
m.Duration = m.Latest.Sub(m.Earliest)
if secs := m.Duration.Seconds(); secs > 0 {
m.Rate /= secs
}
m.Wait = m.End.Sub(m.Latest)
m.BytesIn.Mean = float64(m.BytesIn.Total) / float64(m.Requests)
m.BytesOut.Mean = float64(m.BytesOut.Total) / float6... | [
"func",
"(",
"m",
"*",
"Metrics",
")",
"Close",
"(",
")",
"{",
"m",
".",
"init",
"(",
")",
"\n",
"m",
".",
"Rate",
"=",
"float64",
"(",
"m",
".",
"Requests",
")",
"\n",
"m",
".",
"Duration",
"=",
"m",
".",
"Latest",
".",
"Sub",
"(",
"m",
".... | // Close implements the Close method of the Report interface by computing
// derived summary metrics which don't need to be run on every Add call. | [
"Close",
"implements",
"the",
"Close",
"method",
"of",
"the",
"Report",
"interface",
"by",
"computing",
"derived",
"summary",
"metrics",
"which",
"don",
"t",
"need",
"to",
"be",
"run",
"on",
"every",
"Add",
"call",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/metrics.go#L82-L97 |
133,945 | tsenart/vegeta | lib/metrics.go | Add | func (l *LatencyMetrics) Add(latency time.Duration) {
l.init()
if l.Total += latency; latency > l.Max {
l.Max = latency
}
l.estimator.Add(float64(latency))
} | go | func (l *LatencyMetrics) Add(latency time.Duration) {
l.init()
if l.Total += latency; latency > l.Max {
l.Max = latency
}
l.estimator.Add(float64(latency))
} | [
"func",
"(",
"l",
"*",
"LatencyMetrics",
")",
"Add",
"(",
"latency",
"time",
".",
"Duration",
")",
"{",
"l",
".",
"init",
"(",
")",
"\n",
"if",
"l",
".",
"Total",
"+=",
"latency",
";",
"latency",
">",
"l",
".",
"Max",
"{",
"l",
".",
"Max",
"=",... | // Add adds the given latency to the latency metrics. | [
"Add",
"adds",
"the",
"given",
"latency",
"to",
"the",
"latency",
"metrics",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/metrics.go#L132-L138 |
133,946 | tsenart/vegeta | lib/metrics.go | Quantile | func (l LatencyMetrics) Quantile(nth float64) time.Duration {
l.init()
return time.Duration(l.estimator.Get(nth))
} | go | func (l LatencyMetrics) Quantile(nth float64) time.Duration {
l.init()
return time.Duration(l.estimator.Get(nth))
} | [
"func",
"(",
"l",
"LatencyMetrics",
")",
"Quantile",
"(",
"nth",
"float64",
")",
"time",
".",
"Duration",
"{",
"l",
".",
"init",
"(",
")",
"\n",
"return",
"time",
".",
"Duration",
"(",
"l",
".",
"estimator",
".",
"Get",
"(",
"nth",
")",
")",
"\n",
... | // Quantile returns the nth quantile from the latency summary. | [
"Quantile",
"returns",
"the",
"nth",
"quantile",
"from",
"the",
"latency",
"summary",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/metrics.go#L141-L144 |
133,947 | tsenart/vegeta | lib/plot/plot.go | New | func New(opts ...Opt) *Plot {
p := &Plot{series: map[string]*labeledSeries{}}
for _, opt := range opts {
opt(p)
}
if p.label == nil {
p.label = ErrorLabeler
}
return p
} | go | func New(opts ...Opt) *Plot {
p := &Plot{series: map[string]*labeledSeries{}}
for _, opt := range opts {
opt(p)
}
if p.label == nil {
p.label = ErrorLabeler
}
return p
} | [
"func",
"New",
"(",
"opts",
"...",
"Opt",
")",
"*",
"Plot",
"{",
"p",
":=",
"&",
"Plot",
"{",
"series",
":",
"map",
"[",
"string",
"]",
"*",
"labeledSeries",
"{",
"}",
"}",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"opt",
"(",
... | // New returns a Plot with the given Opts applied.
// If no Label opt is given, ErrorLabeler will be used as default. | [
"New",
"returns",
"a",
"Plot",
"with",
"the",
"given",
"Opts",
"applied",
".",
"If",
"no",
"Label",
"opt",
"is",
"given",
"ErrorLabeler",
"will",
"be",
"used",
"as",
"default",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/plot/plot.go#L137-L148 |
133,948 | tsenart/vegeta | lib/plot/plot.go | Add | func (p *Plot) Add(r *vegeta.Result) error {
s, ok := p.series[r.Attack]
if !ok {
s = newLabeledSeries(p.label)
p.series[r.Attack] = s
}
return s.add(r)
} | go | func (p *Plot) Add(r *vegeta.Result) error {
s, ok := p.series[r.Attack]
if !ok {
s = newLabeledSeries(p.label)
p.series[r.Attack] = s
}
return s.add(r)
} | [
"func",
"(",
"p",
"*",
"Plot",
")",
"Add",
"(",
"r",
"*",
"vegeta",
".",
"Result",
")",
"error",
"{",
"s",
",",
"ok",
":=",
"p",
".",
"series",
"[",
"r",
".",
"Attack",
"]",
"\n",
"if",
"!",
"ok",
"{",
"s",
"=",
"newLabeledSeries",
"(",
"p",
... | // Add adds the given Result to the Plot time series. | [
"Add",
"adds",
"the",
"given",
"Result",
"to",
"the",
"Plot",
"time",
"series",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/plot/plot.go#L151-L158 |
133,949 | tsenart/vegeta | lib/plot/plot.go | Close | func (p *Plot) Close() {
for _, as := range p.series {
for _, ts := range as.series {
ts.data.Finish()
}
}
} | go | func (p *Plot) Close() {
for _, as := range p.series {
for _, ts := range as.series {
ts.data.Finish()
}
}
} | [
"func",
"(",
"p",
"*",
"Plot",
")",
"Close",
"(",
")",
"{",
"for",
"_",
",",
"as",
":=",
"range",
"p",
".",
"series",
"{",
"for",
"_",
",",
"ts",
":=",
"range",
"as",
".",
"series",
"{",
"ts",
".",
"data",
".",
"Finish",
"(",
")",
"\n",
"}"... | // Close closes the HTML plot for writing. | [
"Close",
"closes",
"the",
"HTML",
"plot",
"for",
"writing",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/plot/plot.go#L161-L167 |
133,950 | tsenart/vegeta | lib/plot/plot.go | WriteTo | func (p Plot) WriteTo(w io.Writer) (n int64, err error) {
type dygraphsOpts struct {
Title string `json:"title"`
Labels []string `json:"labels,omitempty"`
YLabel string `json:"ylabel"`
XLabel string `json:"xlabel"`
Colors []string `json:"colors,omitempty"`
Legend string... | go | func (p Plot) WriteTo(w io.Writer) (n int64, err error) {
type dygraphsOpts struct {
Title string `json:"title"`
Labels []string `json:"labels,omitempty"`
YLabel string `json:"ylabel"`
XLabel string `json:"xlabel"`
Colors []string `json:"colors,omitempty"`
Legend string... | [
"func",
"(",
"p",
"Plot",
")",
"WriteTo",
"(",
"w",
"io",
".",
"Writer",
")",
"(",
"n",
"int64",
",",
"err",
"error",
")",
"{",
"type",
"dygraphsOpts",
"struct",
"{",
"Title",
"string",
"`json:\"title\"`",
"\n",
"Labels",
"[",
"]",
"string",
"`json:\"l... | // WriteTo writes the HTML plot to the give io.Writer. | [
"WriteTo",
"writes",
"the",
"HTML",
"plot",
"to",
"the",
"give",
"io",
".",
"Writer",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/plot/plot.go#L170-L241 |
133,951 | tsenart/vegeta | lib/reporters.go | NewHistogramReporter | func NewHistogramReporter(h *Histogram) Reporter {
return func(w io.Writer) (err error) {
tw := tabwriter.NewWriter(w, 0, 8, 2, ' ', tabwriter.StripEscape)
if _, err = fmt.Fprintf(tw, "Bucket\t\t#\t%%\tHistogram\n"); err != nil {
return err
}
for i, count := range h.Counts {
ratio := float64(count) / fl... | go | func NewHistogramReporter(h *Histogram) Reporter {
return func(w io.Writer) (err error) {
tw := tabwriter.NewWriter(w, 0, 8, 2, ' ', tabwriter.StripEscape)
if _, err = fmt.Fprintf(tw, "Bucket\t\t#\t%%\tHistogram\n"); err != nil {
return err
}
for i, count := range h.Counts {
ratio := float64(count) / fl... | [
"func",
"NewHistogramReporter",
"(",
"h",
"*",
"Histogram",
")",
"Reporter",
"{",
"return",
"func",
"(",
"w",
"io",
".",
"Writer",
")",
"(",
"err",
"error",
")",
"{",
"tw",
":=",
"tabwriter",
".",
"NewWriter",
"(",
"w",
",",
"0",
",",
"8",
",",
"2"... | // NewHistogramReporter returns a Reporter that writes out a Histogram as
// aligned, formatted text. | [
"NewHistogramReporter",
"returns",
"a",
"Reporter",
"that",
"writes",
"out",
"a",
"Histogram",
"as",
"aligned",
"formatted",
"text",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/reporters.go#L33-L52 |
133,952 | tsenart/vegeta | lib/reporters.go | NewTextReporter | func NewTextReporter(m *Metrics) Reporter {
const fmtstr = "Requests\t[total, rate]\t%d, %.2f\n" +
"Duration\t[total, attack, wait]\t%s, %s, %s\n" +
"Latencies\t[mean, 50, 95, 99, max]\t%s, %s, %s, %s, %s\n" +
"Bytes In\t[total, mean]\t%d, %.2f\n" +
"Bytes Out\t[total, mean]\t%d, %.2f\n" +
"Success\t[ratio]\... | go | func NewTextReporter(m *Metrics) Reporter {
const fmtstr = "Requests\t[total, rate]\t%d, %.2f\n" +
"Duration\t[total, attack, wait]\t%s, %s, %s\n" +
"Latencies\t[mean, 50, 95, 99, max]\t%s, %s, %s, %s, %s\n" +
"Bytes In\t[total, mean]\t%d, %.2f\n" +
"Bytes Out\t[total, mean]\t%d, %.2f\n" +
"Success\t[ratio]\... | [
"func",
"NewTextReporter",
"(",
"m",
"*",
"Metrics",
")",
"Reporter",
"{",
"const",
"fmtstr",
"=",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
"+",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
"+",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
"+",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
... | // NewTextReporter returns a Reporter that writes out Metrics as aligned,
// formatted text. | [
"NewTextReporter",
"returns",
"a",
"Reporter",
"that",
"writes",
"out",
"Metrics",
"as",
"aligned",
"formatted",
"text",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/reporters.go#L56-L104 |
133,953 | tsenart/vegeta | lib/reporters.go | NewJSONReporter | func NewJSONReporter(m *Metrics) Reporter {
return func(w io.Writer) error {
return json.NewEncoder(w).Encode(m)
}
} | go | func NewJSONReporter(m *Metrics) Reporter {
return func(w io.Writer) error {
return json.NewEncoder(w).Encode(m)
}
} | [
"func",
"NewJSONReporter",
"(",
"m",
"*",
"Metrics",
")",
"Reporter",
"{",
"return",
"func",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"return",
"json",
".",
"NewEncoder",
"(",
"w",
")",
".",
"Encode",
"(",
"m",
")",
"\n",
"}",
"\n",
"}"
] | // NewJSONReporter returns a Reporter that writes out Metrics as JSON. | [
"NewJSONReporter",
"returns",
"a",
"Reporter",
"that",
"writes",
"out",
"Metrics",
"as",
"JSON",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/lib/reporters.go#L107-L111 |
133,954 | tsenart/vegeta | flags.go | Set | func (h headers) Set(value string) error {
parts := strings.SplitN(value, ":", 2)
if len(parts) != 2 {
return fmt.Errorf("header '%s' has a wrong format", value)
}
key, val := strings.TrimSpace(parts[0]), strings.TrimSpace(parts[1])
if key == "" || val == "" {
return fmt.Errorf("header '%s' has a wrong format"... | go | func (h headers) Set(value string) error {
parts := strings.SplitN(value, ":", 2)
if len(parts) != 2 {
return fmt.Errorf("header '%s' has a wrong format", value)
}
key, val := strings.TrimSpace(parts[0]), strings.TrimSpace(parts[1])
if key == "" || val == "" {
return fmt.Errorf("header '%s' has a wrong format"... | [
"func",
"(",
"h",
"headers",
")",
"Set",
"(",
"value",
"string",
")",
"error",
"{",
"parts",
":=",
"strings",
".",
"SplitN",
"(",
"value",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
"!=",
"2",
"{",
"return",
"fmt",
".... | // Set implements the flag.Value interface for a map of HTTP Headers. | [
"Set",
"implements",
"the",
"flag",
".",
"Value",
"interface",
"for",
"a",
"map",
"of",
"HTTP",
"Headers",
"."
] | e827e02858e8d5d581bac4d57b31fbd275da39c5 | https://github.com/tsenart/vegeta/blob/e827e02858e8d5d581bac4d57b31fbd275da39c5/flags.go#L32-L46 |
133,955 | henrylee2cn/pholcus | common/mahonia/euc-jp.go | init | func init() {
RegisterCharset(&Charset{
Name: "EUC-JP",
Aliases: []string{"extended_unix_code_packed_format_for_japanese", "cseucpkdfmtjapanese"},
NewDecoder: func() Decoder {
return decodeEucJP
},
NewEncoder: func() Encoder {
jis0208Table.Reverse()
jis0212Table.Reverse()
return encodeEucJP
... | go | func init() {
RegisterCharset(&Charset{
Name: "EUC-JP",
Aliases: []string{"extended_unix_code_packed_format_for_japanese", "cseucpkdfmtjapanese"},
NewDecoder: func() Decoder {
return decodeEucJP
},
NewEncoder: func() Encoder {
jis0208Table.Reverse()
jis0212Table.Reverse()
return encodeEucJP
... | [
"func",
"init",
"(",
")",
"{",
"RegisterCharset",
"(",
"&",
"Charset",
"{",
"Name",
":",
"\"",
"\"",
",",
"Aliases",
":",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
",",
"NewDecoder",
":",
"func",
"(",
")",
"Decoder",
"{",
"return... | // Converters for the EUC-JP encoding | [
"Converters",
"for",
"the",
"EUC",
"-",
"JP",
"encoding"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/mahonia/euc-jp.go#L9-L22 |
133,956 | henrylee2cn/pholcus | common/mahonia/gb18030.go | init | func init() {
RegisterCharset(&Charset{
Name: "GB18030",
NewDecoder: func() Decoder {
gb18030Once.Do(buildGB18030Tables)
return decodeGB18030Rune
},
NewEncoder: func() Encoder {
gb18030Once.Do(buildGB18030Tables)
return encodeGB18030Rune
},
})
} | go | func init() {
RegisterCharset(&Charset{
Name: "GB18030",
NewDecoder: func() Decoder {
gb18030Once.Do(buildGB18030Tables)
return decodeGB18030Rune
},
NewEncoder: func() Encoder {
gb18030Once.Do(buildGB18030Tables)
return encodeGB18030Rune
},
})
} | [
"func",
"init",
"(",
")",
"{",
"RegisterCharset",
"(",
"&",
"Charset",
"{",
"Name",
":",
"\"",
"\"",
",",
"NewDecoder",
":",
"func",
"(",
")",
"Decoder",
"{",
"gb18030Once",
".",
"Do",
"(",
"buildGB18030Tables",
")",
"\n",
"return",
"decodeGB18030Rune",
... | // Converters for GB18030 encoding. | [
"Converters",
"for",
"GB18030",
"encoding",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/mahonia/gb18030.go#L9-L21 |
133,957 | henrylee2cn/pholcus | gui/model/guispider.go | Value | func (m *SpiderMenu) Value(row, col int) interface{} {
item := m.items[row]
switch col {
case 0:
return item.Index
case 1:
return item.Title
case 2:
return item.Description
case 3:
return item.Spider
}
panic("unexpected col")
} | go | func (m *SpiderMenu) Value(row, col int) interface{} {
item := m.items[row]
switch col {
case 0:
return item.Index
case 1:
return item.Title
case 2:
return item.Description
case 3:
return item.Spider
}
panic("unexpected col")
} | [
"func",
"(",
"m",
"*",
"SpiderMenu",
")",
"Value",
"(",
"row",
",",
"col",
"int",
")",
"interface",
"{",
"}",
"{",
"item",
":=",
"m",
".",
"items",
"[",
"row",
"]",
"\n\n",
"switch",
"col",
"{",
"case",
"0",
":",
"return",
"item",
".",
"Index",
... | // Called by the TableView when it needs the text to display for a given cell. | [
"Called",
"by",
"the",
"TableView",
"when",
"it",
"needs",
"the",
"text",
"to",
"display",
"for",
"a",
"given",
"cell",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/gui/model/guispider.go#L63-L80 |
133,958 | henrylee2cn/pholcus | gui/model/guispider.go | Checked | func (m *SpiderMenu) Checked(row int) bool {
return m.items[row].checked
} | go | func (m *SpiderMenu) Checked(row int) bool {
return m.items[row].checked
} | [
"func",
"(",
"m",
"*",
"SpiderMenu",
")",
"Checked",
"(",
"row",
"int",
")",
"bool",
"{",
"return",
"m",
".",
"items",
"[",
"row",
"]",
".",
"checked",
"\n",
"}"
] | // Called by the TableView to retrieve if a given row is checked. | [
"Called",
"by",
"the",
"TableView",
"to",
"retrieve",
"if",
"a",
"given",
"row",
"is",
"checked",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/gui/model/guispider.go#L83-L85 |
133,959 | henrylee2cn/pholcus | gui/model/guispider.go | SetChecked | func (m *SpiderMenu) SetChecked(row int, checked bool) error {
m.items[row].checked = checked
return nil
} | go | func (m *SpiderMenu) SetChecked(row int, checked bool) error {
m.items[row].checked = checked
return nil
} | [
"func",
"(",
"m",
"*",
"SpiderMenu",
")",
"SetChecked",
"(",
"row",
"int",
",",
"checked",
"bool",
")",
"error",
"{",
"m",
".",
"items",
"[",
"row",
"]",
".",
"checked",
"=",
"checked",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Called by the TableView when the user toggled the check box of a given row. | [
"Called",
"by",
"the",
"TableView",
"when",
"the",
"user",
"toggled",
"the",
"check",
"box",
"of",
"a",
"given",
"row",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/gui/model/guispider.go#L88-L92 |
133,960 | henrylee2cn/pholcus | gui/model/guispider.go | Sort | func (m *SpiderMenu) Sort(col int, order walk.SortOrder) error {
m.sortColumn, m.sortOrder = col, order
sort.Sort(m)
return m.SorterBase.Sort(col, order)
} | go | func (m *SpiderMenu) Sort(col int, order walk.SortOrder) error {
m.sortColumn, m.sortOrder = col, order
sort.Sort(m)
return m.SorterBase.Sort(col, order)
} | [
"func",
"(",
"m",
"*",
"SpiderMenu",
")",
"Sort",
"(",
"col",
"int",
",",
"order",
"walk",
".",
"SortOrder",
")",
"error",
"{",
"m",
".",
"sortColumn",
",",
"m",
".",
"sortOrder",
"=",
"col",
",",
"order",
"\n\n",
"sort",
".",
"Sort",
"(",
"m",
"... | // Called by the TableView to sort the model. | [
"Called",
"by",
"the",
"TableView",
"to",
"sort",
"the",
"model",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/gui/model/guispider.go#L106-L112 |
133,961 | henrylee2cn/pholcus | common/xlsx/xmlWorkbook.go | worksheetFileForSheet | func worksheetFileForSheet(sheet xlsxSheet, worksheets map[string]*zip.File, sheetXMLMap map[string]string) *zip.File {
sheetName, ok := sheetXMLMap[sheet.Id]
if !ok {
if sheet.SheetId != "" {
sheetName = fmt.Sprintf("sheet%s", sheet.SheetId)
} else {
sheetName = fmt.Sprintf("sheet%s", sheet.Id)
}
}
ret... | go | func worksheetFileForSheet(sheet xlsxSheet, worksheets map[string]*zip.File, sheetXMLMap map[string]string) *zip.File {
sheetName, ok := sheetXMLMap[sheet.Id]
if !ok {
if sheet.SheetId != "" {
sheetName = fmt.Sprintf("sheet%s", sheet.SheetId)
} else {
sheetName = fmt.Sprintf("sheet%s", sheet.Id)
}
}
ret... | [
"func",
"worksheetFileForSheet",
"(",
"sheet",
"xlsxSheet",
",",
"worksheets",
"map",
"[",
"string",
"]",
"*",
"zip",
".",
"File",
",",
"sheetXMLMap",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"zip",
".",
"File",
"{",
"sheetName",
",",
"ok",
":=",
... | // Helper function to lookup the file corresponding to a xlsxSheet object in the worksheets map | [
"Helper",
"function",
"to",
"lookup",
"the",
"file",
"corresponding",
"to",
"a",
"xlsxSheet",
"object",
"in",
"the",
"worksheets",
"map"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/xlsx/xmlWorkbook.go#L152-L162 |
133,962 | henrylee2cn/pholcus | logs/logs/conn.go | Init | func (c *ConnWriter) Init(config map[string]interface{}) error {
conf, err := json.Marshal(config)
if err != nil {
return err
}
return json.Unmarshal(conf, c)
} | go | func (c *ConnWriter) Init(config map[string]interface{}) error {
conf, err := json.Marshal(config)
if err != nil {
return err
}
return json.Unmarshal(conf, c)
} | [
"func",
"(",
"c",
"*",
"ConnWriter",
")",
"Init",
"(",
"config",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"conf",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retu... | // init connection writer with json config.
// json config only need key "level". | [
"init",
"connection",
"writer",
"with",
"json",
"config",
".",
"json",
"config",
"only",
"need",
"key",
"level",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/logs/logs/conn.go#L45-L51 |
133,963 | henrylee2cn/pholcus | logs/logs/conn.go | WriteMsg | func (c *ConnWriter) WriteMsg(msg string, level int) error {
if level > c.Level {
return nil
}
if c.neddedConnectOnMsg() {
err := c.connect()
if err != nil {
return err
}
}
if c.ReconnectOnMsg {
defer c.innerWriter.Close()
}
c.lg.Println(msg)
return nil
} | go | func (c *ConnWriter) WriteMsg(msg string, level int) error {
if level > c.Level {
return nil
}
if c.neddedConnectOnMsg() {
err := c.connect()
if err != nil {
return err
}
}
if c.ReconnectOnMsg {
defer c.innerWriter.Close()
}
c.lg.Println(msg)
return nil
} | [
"func",
"(",
"c",
"*",
"ConnWriter",
")",
"WriteMsg",
"(",
"msg",
"string",
",",
"level",
"int",
")",
"error",
"{",
"if",
"level",
">",
"c",
".",
"Level",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"c",
".",
"neddedConnectOnMsg",
"(",
")",
"{",
... | // write message in connection.
// if connection is down, try to re-connect. | [
"write",
"message",
"in",
"connection",
".",
"if",
"connection",
"is",
"down",
"try",
"to",
"re",
"-",
"connect",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/logs/logs/conn.go#L55-L71 |
133,964 | henrylee2cn/pholcus | common/xlsx/sheet.go | AddRow | func (s *Sheet) AddRow() *Row {
row := &Row{Sheet: s}
s.Rows = append(s.Rows, row)
if len(s.Rows) > s.MaxRow {
s.MaxRow = len(s.Rows)
}
return row
} | go | func (s *Sheet) AddRow() *Row {
row := &Row{Sheet: s}
s.Rows = append(s.Rows, row)
if len(s.Rows) > s.MaxRow {
s.MaxRow = len(s.Rows)
}
return row
} | [
"func",
"(",
"s",
"*",
"Sheet",
")",
"AddRow",
"(",
")",
"*",
"Row",
"{",
"row",
":=",
"&",
"Row",
"{",
"Sheet",
":",
"s",
"}",
"\n",
"s",
".",
"Rows",
"=",
"append",
"(",
"s",
".",
"Rows",
",",
"row",
")",
"\n",
"if",
"len",
"(",
"s",
".... | // Add a new Row to a Sheet | [
"Add",
"a",
"new",
"Row",
"to",
"a",
"Sheet"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/xlsx/sheet.go#L41-L48 |
133,965 | henrylee2cn/pholcus | app/spider/common/form.go | serializeForm | func serializeForm(sel *goquery.Selection) (url.Values, url.Values) {
input := sel.Find("input,button,textarea")
if input.Length() == 0 {
return url.Values{}, url.Values{}
}
fields := make(url.Values)
buttons := make(url.Values)
input.Each(func(_ int, s *goquery.Selection) {
name, ok := s.Attr("name")
if o... | go | func serializeForm(sel *goquery.Selection) (url.Values, url.Values) {
input := sel.Find("input,button,textarea")
if input.Length() == 0 {
return url.Values{}, url.Values{}
}
fields := make(url.Values)
buttons := make(url.Values)
input.Each(func(_ int, s *goquery.Selection) {
name, ok := s.Attr("name")
if o... | [
"func",
"serializeForm",
"(",
"sel",
"*",
"goquery",
".",
"Selection",
")",
"(",
"url",
".",
"Values",
",",
"url",
".",
"Values",
")",
"{",
"input",
":=",
"sel",
".",
"Find",
"(",
"\"",
"\"",
")",
"\n",
"if",
"input",
".",
"Length",
"(",
")",
"==... | // Serialize converts the form fields into a url.Values type.
// Returns two url.Value types. The first is the form field values, and the
// second is the form button values. | [
"Serialize",
"converts",
"the",
"form",
"fields",
"into",
"a",
"url",
".",
"Values",
"type",
".",
"Returns",
"two",
"url",
".",
"Value",
"types",
".",
"The",
"first",
"is",
"the",
"form",
"field",
"values",
"and",
"the",
"second",
"is",
"the",
"form",
... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/app/spider/common/form.go#L147-L179 |
133,966 | henrylee2cn/pholcus | app/downloader/surfer/request.go | GetMethod | func (self *DefaultRequest) GetMethod() string {
self.once.Do(self.prepare)
return self.Method
} | go | func (self *DefaultRequest) GetMethod() string {
self.once.Do(self.prepare)
return self.Method
} | [
"func",
"(",
"self",
"*",
"DefaultRequest",
")",
"GetMethod",
"(",
")",
"string",
"{",
"self",
".",
"once",
".",
"Do",
"(",
"self",
".",
"prepare",
")",
"\n",
"return",
"self",
".",
"Method",
"\n",
"}"
] | // GET POST POST-M HEAD | [
"GET",
"POST",
"POST",
"-",
"M",
"HEAD"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/app/downloader/surfer/request.go#L141-L144 |
133,967 | henrylee2cn/pholcus | app/downloader/surfer/request.go | GetEnableCookie | func (self *DefaultRequest) GetEnableCookie() bool {
self.once.Do(self.prepare)
return self.EnableCookie
} | go | func (self *DefaultRequest) GetEnableCookie() bool {
self.once.Do(self.prepare)
return self.EnableCookie
} | [
"func",
"(",
"self",
"*",
"DefaultRequest",
")",
"GetEnableCookie",
"(",
")",
"bool",
"{",
"self",
".",
"once",
".",
"Do",
"(",
"self",
".",
"prepare",
")",
"\n",
"return",
"self",
".",
"EnableCookie",
"\n",
"}"
] | // enable http cookies | [
"enable",
"http",
"cookies"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/app/downloader/surfer/request.go#L159-L162 |
133,968 | henrylee2cn/pholcus | app/downloader/surfer/request.go | GetTryTimes | func (self *DefaultRequest) GetTryTimes() int {
self.once.Do(self.prepare)
return self.TryTimes
} | go | func (self *DefaultRequest) GetTryTimes() int {
self.once.Do(self.prepare)
return self.TryTimes
} | [
"func",
"(",
"self",
"*",
"DefaultRequest",
")",
"GetTryTimes",
"(",
")",
"int",
"{",
"self",
".",
"once",
".",
"Do",
"(",
"self",
".",
"prepare",
")",
"\n",
"return",
"self",
".",
"TryTimes",
"\n",
"}"
] | // the max times of download | [
"the",
"max",
"times",
"of",
"download"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/app/downloader/surfer/request.go#L177-L180 |
133,969 | henrylee2cn/pholcus | app/downloader/surfer/request.go | GetRetryPause | func (self *DefaultRequest) GetRetryPause() time.Duration {
self.once.Do(self.prepare)
return self.RetryPause
} | go | func (self *DefaultRequest) GetRetryPause() time.Duration {
self.once.Do(self.prepare)
return self.RetryPause
} | [
"func",
"(",
"self",
"*",
"DefaultRequest",
")",
"GetRetryPause",
"(",
")",
"time",
".",
"Duration",
"{",
"self",
".",
"once",
".",
"Do",
"(",
"self",
".",
"prepare",
")",
"\n",
"return",
"self",
".",
"RetryPause",
"\n",
"}"
] | // the pause time of retry | [
"the",
"pause",
"time",
"of",
"retry"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/app/downloader/surfer/request.go#L183-L186 |
133,970 | henrylee2cn/pholcus | app/downloader/surfer/request.go | GetProxy | func (self *DefaultRequest) GetProxy() string {
self.once.Do(self.prepare)
return self.Proxy
} | go | func (self *DefaultRequest) GetProxy() string {
self.once.Do(self.prepare)
return self.Proxy
} | [
"func",
"(",
"self",
"*",
"DefaultRequest",
")",
"GetProxy",
"(",
")",
"string",
"{",
"self",
".",
"once",
".",
"Do",
"(",
"self",
".",
"prepare",
")",
"\n",
"return",
"self",
".",
"Proxy",
"\n",
"}"
] | // the download ProxyHost | [
"the",
"download",
"ProxyHost"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/app/downloader/surfer/request.go#L189-L192 |
133,971 | henrylee2cn/pholcus | app/downloader/surfer/request.go | GetRedirectTimes | func (self *DefaultRequest) GetRedirectTimes() int {
self.once.Do(self.prepare)
return self.RedirectTimes
} | go | func (self *DefaultRequest) GetRedirectTimes() int {
self.once.Do(self.prepare)
return self.RedirectTimes
} | [
"func",
"(",
"self",
"*",
"DefaultRequest",
")",
"GetRedirectTimes",
"(",
")",
"int",
"{",
"self",
".",
"once",
".",
"Do",
"(",
"self",
".",
"prepare",
")",
"\n",
"return",
"self",
".",
"RedirectTimes",
"\n",
"}"
] | // max redirect times | [
"max",
"redirect",
"times"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/app/downloader/surfer/request.go#L195-L198 |
133,972 | henrylee2cn/pholcus | app/downloader/surfer/request.go | GetDownloaderID | func (self *DefaultRequest) GetDownloaderID() int {
self.once.Do(self.prepare)
return self.DownloaderID
} | go | func (self *DefaultRequest) GetDownloaderID() int {
self.once.Do(self.prepare)
return self.DownloaderID
} | [
"func",
"(",
"self",
"*",
"DefaultRequest",
")",
"GetDownloaderID",
"(",
")",
"int",
"{",
"self",
".",
"once",
".",
"Do",
"(",
"self",
".",
"prepare",
")",
"\n",
"return",
"self",
".",
"DownloaderID",
"\n",
"}"
] | // select Surf ro PhomtomJS | [
"select",
"Surf",
"ro",
"PhomtomJS"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/app/downloader/surfer/request.go#L201-L204 |
133,973 | henrylee2cn/pholcus | common/websocket/hybi.go | newHybiConn | func newHybiConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) *Conn {
if buf == nil {
br := bufio.NewReader(rwc)
bw := bufio.NewWriter(rwc)
buf = bufio.NewReadWriter(br, bw)
}
ws := &Conn{config: config, request: request, buf: buf, rwc: rwc,
frameReaderFactory: hybiFr... | go | func newHybiConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) *Conn {
if buf == nil {
br := bufio.NewReader(rwc)
bw := bufio.NewWriter(rwc)
buf = bufio.NewReadWriter(br, bw)
}
ws := &Conn{config: config, request: request, buf: buf, rwc: rwc,
frameReaderFactory: hybiFr... | [
"func",
"newHybiConn",
"(",
"config",
"*",
"Config",
",",
"buf",
"*",
"bufio",
".",
"ReadWriter",
",",
"rwc",
"io",
".",
"ReadWriteCloser",
",",
"request",
"*",
"http",
".",
"Request",
")",
"*",
"Conn",
"{",
"if",
"buf",
"==",
"nil",
"{",
"br",
":=",... | // newHybiConn creates a new WebSocket connection speaking hybi draft protocol. | [
"newHybiConn",
"creates",
"a",
"new",
"WebSocket",
"connection",
"speaking",
"hybi",
"draft",
"protocol",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/websocket/hybi.go#L336-L350 |
133,974 | henrylee2cn/pholcus | common/websocket/hybi.go | generateMaskingKey | func generateMaskingKey() (maskingKey []byte, err error) {
maskingKey = make([]byte, 4)
if _, err = io.ReadFull(rand.Reader, maskingKey); err != nil {
return
}
return
} | go | func generateMaskingKey() (maskingKey []byte, err error) {
maskingKey = make([]byte, 4)
if _, err = io.ReadFull(rand.Reader, maskingKey); err != nil {
return
}
return
} | [
"func",
"generateMaskingKey",
"(",
")",
"(",
"maskingKey",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"maskingKey",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"4",
")",
"\n",
"if",
"_",
",",
"err",
"=",
"io",
".",
"ReadFull",
"(",
"rand",
"."... | // generateMaskingKey generates a masking key for a frame. | [
"generateMaskingKey",
"generates",
"a",
"masking",
"key",
"for",
"a",
"frame",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/websocket/hybi.go#L353-L359 |
133,975 | henrylee2cn/pholcus | common/websocket/hybi.go | generateNonce | func generateNonce() (nonce []byte) {
key := make([]byte, 16)
if _, err := io.ReadFull(rand.Reader, key); err != nil {
panic(err)
}
nonce = make([]byte, 24)
base64.StdEncoding.Encode(nonce, key)
return
} | go | func generateNonce() (nonce []byte) {
key := make([]byte, 16)
if _, err := io.ReadFull(rand.Reader, key); err != nil {
panic(err)
}
nonce = make([]byte, 24)
base64.StdEncoding.Encode(nonce, key)
return
} | [
"func",
"generateNonce",
"(",
")",
"(",
"nonce",
"[",
"]",
"byte",
")",
"{",
"key",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"16",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"io",
".",
"ReadFull",
"(",
"rand",
".",
"Reader",
",",
"key",
")",
";... | // generateNonce generates a nonce consisting of a randomly selected 16-byte
// value that has been base64-encoded. | [
"generateNonce",
"generates",
"a",
"nonce",
"consisting",
"of",
"a",
"randomly",
"selected",
"16",
"-",
"byte",
"value",
"that",
"has",
"been",
"base64",
"-",
"encoded",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/websocket/hybi.go#L363-L371 |
133,976 | henrylee2cn/pholcus | common/websocket/hybi.go | hybiClientHandshake | func hybiClientHandshake(config *Config, br *bufio.Reader, bw *bufio.Writer) (err error) {
bw.WriteString("GET " + config.Location.RequestURI() + " HTTP/1.1\r\n")
bw.WriteString("Host: " + config.Location.Host + "\r\n")
bw.WriteString("Upgrade: websocket\r\n")
bw.WriteString("Connection: Upgrade\r\n")
nonce := ge... | go | func hybiClientHandshake(config *Config, br *bufio.Reader, bw *bufio.Writer) (err error) {
bw.WriteString("GET " + config.Location.RequestURI() + " HTTP/1.1\r\n")
bw.WriteString("Host: " + config.Location.Host + "\r\n")
bw.WriteString("Upgrade: websocket\r\n")
bw.WriteString("Connection: Upgrade\r\n")
nonce := ge... | [
"func",
"hybiClientHandshake",
"(",
"config",
"*",
"Config",
",",
"br",
"*",
"bufio",
".",
"Reader",
",",
"bw",
"*",
"bufio",
".",
"Writer",
")",
"(",
"err",
"error",
")",
"{",
"bw",
".",
"WriteString",
"(",
"\"",
"\"",
"+",
"config",
".",
"Location"... | // Client handshake described in draft-ietf-hybi-thewebsocket-protocol-17 | [
"Client",
"handshake",
"described",
"in",
"draft",
"-",
"ietf",
"-",
"hybi",
"-",
"thewebsocket",
"-",
"protocol",
"-",
"17"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/websocket/hybi.go#L389-L458 |
133,977 | henrylee2cn/pholcus | common/websocket/hybi.go | newHybiClientConn | func newHybiClientConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCloser) *Conn {
return newHybiConn(config, buf, rwc, nil)
} | go | func newHybiClientConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCloser) *Conn {
return newHybiConn(config, buf, rwc, nil)
} | [
"func",
"newHybiClientConn",
"(",
"config",
"*",
"Config",
",",
"buf",
"*",
"bufio",
".",
"ReadWriter",
",",
"rwc",
"io",
".",
"ReadWriteCloser",
")",
"*",
"Conn",
"{",
"return",
"newHybiConn",
"(",
"config",
",",
"buf",
",",
"rwc",
",",
"nil",
")",
"\... | // newHybiClientConn creates a client WebSocket connection after handshake. | [
"newHybiClientConn",
"creates",
"a",
"client",
"WebSocket",
"connection",
"after",
"handshake",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/websocket/hybi.go#L461-L463 |
133,978 | henrylee2cn/pholcus | common/websocket/hybi.go | newHybiServerConn | func newHybiServerConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) *Conn {
return newHybiConn(config, buf, rwc, request)
} | go | func newHybiServerConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) *Conn {
return newHybiConn(config, buf, rwc, request)
} | [
"func",
"newHybiServerConn",
"(",
"config",
"*",
"Config",
",",
"buf",
"*",
"bufio",
".",
"ReadWriter",
",",
"rwc",
"io",
".",
"ReadWriteCloser",
",",
"request",
"*",
"http",
".",
"Request",
")",
"*",
"Conn",
"{",
"return",
"newHybiConn",
"(",
"config",
... | // newHybiServerConn returns a new WebSocket connection speaking hybi draft protocol. | [
"newHybiServerConn",
"returns",
"a",
"new",
"WebSocket",
"connection",
"speaking",
"hybi",
"draft",
"protocol",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/websocket/hybi.go#L562-L564 |
133,979 | henrylee2cn/pholcus | common/session/sess_cookie.go | Set | func (st *CookieSessionStore) Set(key, value interface{}) {
st.lock.Lock()
defer st.lock.Unlock()
st.values[key] = value
} | go | func (st *CookieSessionStore) Set(key, value interface{}) {
st.lock.Lock()
defer st.lock.Unlock()
st.values[key] = value
} | [
"func",
"(",
"st",
"*",
"CookieSessionStore",
")",
"Set",
"(",
"key",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"st",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"st",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"st",
".",
"values",
... | // Set value to cookie session.
// the value are encoded as gob with hash block string. | [
"Set",
"value",
"to",
"cookie",
"session",
".",
"the",
"value",
"are",
"encoded",
"as",
"gob",
"with",
"hash",
"block",
"string",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_cookie.go#L37-L41 |
133,980 | henrylee2cn/pholcus | common/session/sess_cookie.go | Get | func (st *CookieSessionStore) Get(key interface{}) interface{} {
st.lock.RLock()
defer st.lock.RUnlock()
if v, ok := st.values[key]; ok {
return v
}
return nil
} | go | func (st *CookieSessionStore) Get(key interface{}) interface{} {
st.lock.RLock()
defer st.lock.RUnlock()
if v, ok := st.values[key]; ok {
return v
}
return nil
} | [
"func",
"(",
"st",
"*",
"CookieSessionStore",
")",
"Get",
"(",
"key",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"st",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"st",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"v",
... | // Get value from cookie session | [
"Get",
"value",
"from",
"cookie",
"session"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_cookie.go#L44-L51 |
133,981 | henrylee2cn/pholcus | common/session/sess_cookie.go | Delete | func (st *CookieSessionStore) Delete(key interface{}) {
st.lock.Lock()
defer st.lock.Unlock()
delete(st.values, key)
} | go | func (st *CookieSessionStore) Delete(key interface{}) {
st.lock.Lock()
defer st.lock.Unlock()
delete(st.values, key)
} | [
"func",
"(",
"st",
"*",
"CookieSessionStore",
")",
"Delete",
"(",
"key",
"interface",
"{",
"}",
")",
"{",
"st",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"st",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"st",
".",
"values... | // Delete value in cookie session | [
"Delete",
"value",
"in",
"cookie",
"session"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_cookie.go#L54-L58 |
133,982 | henrylee2cn/pholcus | common/session/sess_cookie.go | Flush | func (st *CookieSessionStore) Flush() {
st.lock.Lock()
defer st.lock.Unlock()
st.values = make(map[interface{}]interface{})
} | go | func (st *CookieSessionStore) Flush() {
st.lock.Lock()
defer st.lock.Unlock()
st.values = make(map[interface{}]interface{})
} | [
"func",
"(",
"st",
"*",
"CookieSessionStore",
")",
"Flush",
"(",
")",
"{",
"st",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"st",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"st",
".",
"values",
"=",
"make",
"(",
"map",
"[",
"interface",
... | // Flush Clean all values in cookie session | [
"Flush",
"Clean",
"all",
"values",
"in",
"cookie",
"session"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_cookie.go#L61-L65 |
133,983 | henrylee2cn/pholcus | common/session/sess_cookie.go | SessionRelease | func (st *CookieSessionStore) SessionRelease(w http.ResponseWriter) {
str, err := encodeCookie(cookiepder.block,
cookiepder.config.SecurityKey,
cookiepder.config.SecurityName,
st.values)
if err != nil {
return
}
cookie := &http.Cookie{Name: CookieName,
Value: url.QueryEscape(str),
Path: "/",
Ht... | go | func (st *CookieSessionStore) SessionRelease(w http.ResponseWriter) {
str, err := encodeCookie(cookiepder.block,
cookiepder.config.SecurityKey,
cookiepder.config.SecurityName,
st.values)
if err != nil {
return
}
cookie := &http.Cookie{Name: CookieName,
Value: url.QueryEscape(str),
Path: "/",
Ht... | [
"func",
"(",
"st",
"*",
"CookieSessionStore",
")",
"SessionRelease",
"(",
"w",
"http",
".",
"ResponseWriter",
")",
"{",
"str",
",",
"err",
":=",
"encodeCookie",
"(",
"cookiepder",
".",
"block",
",",
"cookiepder",
".",
"config",
".",
"SecurityKey",
",",
"co... | // SessionRelease Write cookie session to http response cookie | [
"SessionRelease",
"Write",
"cookie",
"session",
"to",
"http",
"response",
"cookie"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_cookie.go#L73-L89 |
133,984 | henrylee2cn/pholcus | common/session/sess_cookie.go | SessionRead | func (pder *CookieProvider) SessionRead(sid string) (Store, error) {
maps, _ := decodeCookie(pder.block,
pder.config.SecurityKey,
pder.config.SecurityName,
sid, pder.maxlifetime)
if maps == nil {
maps = make(map[interface{}]interface{})
}
rs := &CookieSessionStore{sid: sid, values: maps}
return rs, nil
} | go | func (pder *CookieProvider) SessionRead(sid string) (Store, error) {
maps, _ := decodeCookie(pder.block,
pder.config.SecurityKey,
pder.config.SecurityName,
sid, pder.maxlifetime)
if maps == nil {
maps = make(map[interface{}]interface{})
}
rs := &CookieSessionStore{sid: sid, values: maps}
return rs, nil
} | [
"func",
"(",
"pder",
"*",
"CookieProvider",
")",
"SessionRead",
"(",
"sid",
"string",
")",
"(",
"Store",
",",
"error",
")",
"{",
"maps",
",",
"_",
":=",
"decodeCookie",
"(",
"pder",
".",
"block",
",",
"pder",
".",
"config",
".",
"SecurityKey",
",",
"... | // SessionRead Get SessionStore in cooke.
// decode cooke string to map and put into SessionStore with sid. | [
"SessionRead",
"Get",
"SessionStore",
"in",
"cooke",
".",
"decode",
"cooke",
"string",
"to",
"map",
"and",
"put",
"into",
"SessionStore",
"with",
"sid",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_cookie.go#L138-L148 |
133,985 | henrylee2cn/pholcus | common/session/sess_cookie.go | SessionRegenerate | func (pder *CookieProvider) SessionRegenerate(oldsid, sid string) (Store, error) {
return nil, nil
} | go | func (pder *CookieProvider) SessionRegenerate(oldsid, sid string) (Store, error) {
return nil, nil
} | [
"func",
"(",
"pder",
"*",
"CookieProvider",
")",
"SessionRegenerate",
"(",
"oldsid",
",",
"sid",
"string",
")",
"(",
"Store",
",",
"error",
")",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}"
] | // SessionRegenerate Implement method, no used. | [
"SessionRegenerate",
"Implement",
"method",
"no",
"used",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_cookie.go#L156-L158 |
133,986 | henrylee2cn/pholcus | logs/logs/file.go | WriteMsg | func (w *FileLogWriter) WriteMsg(msg string, level int) error {
if level > w.Level {
return nil
}
n := 24 + len(msg) // 24 stand for the length "2013/06/23 21:00:22 [T] "
w.docheck(n)
w.Logger.Println(msg)
return nil
} | go | func (w *FileLogWriter) WriteMsg(msg string, level int) error {
if level > w.Level {
return nil
}
n := 24 + len(msg) // 24 stand for the length "2013/06/23 21:00:22 [T] "
w.docheck(n)
w.Logger.Println(msg)
return nil
} | [
"func",
"(",
"w",
"*",
"FileLogWriter",
")",
"WriteMsg",
"(",
"msg",
"string",
",",
"level",
"int",
")",
"error",
"{",
"if",
"level",
">",
"w",
".",
"Level",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"n",
":=",
"24",
"+",
"len",
"(",
"msg",
")",
"... | // write logger message into file. | [
"write",
"logger",
"message",
"into",
"file",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/logs/logs/file.go#L151-L159 |
133,987 | henrylee2cn/pholcus | common/xlsx/hsl.go | RGBA | func (c HSL) RGBA() (uint32, uint32, uint32, uint32) {
r, g, b := HSLToRGB(c.H, c.S, c.L)
return uint32(r) * 0x101, uint32(g) * 0x101, uint32(b) * 0x101, 0xffff
} | go | func (c HSL) RGBA() (uint32, uint32, uint32, uint32) {
r, g, b := HSLToRGB(c.H, c.S, c.L)
return uint32(r) * 0x101, uint32(g) * 0x101, uint32(b) * 0x101, 0xffff
} | [
"func",
"(",
"c",
"HSL",
")",
"RGBA",
"(",
")",
"(",
"uint32",
",",
"uint32",
",",
"uint32",
",",
"uint32",
")",
"{",
"r",
",",
"g",
",",
"b",
":=",
"HSLToRGB",
"(",
"c",
".",
"H",
",",
"c",
".",
"S",
",",
"c",
".",
"L",
")",
"\n",
"retur... | // RGBA returns the alpha-premultiplied red, green, blue and alpha values
// for the HSL. | [
"RGBA",
"returns",
"the",
"alpha",
"-",
"premultiplied",
"red",
"green",
"blue",
"and",
"alpha",
"values",
"for",
"the",
"HSL",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/xlsx/hsl.go#L50-L53 |
133,988 | henrylee2cn/pholcus | common/xlsx/hsl.go | hslModel | func hslModel(c color.Color) color.Color {
if _, ok := c.(HSL); ok {
return c
}
r, g, b, _ := c.RGBA()
h, s, l := RGBToHSL(uint8(r>>8), uint8(g>>8), uint8(b>>8))
return HSL{h, s, l}
} | go | func hslModel(c color.Color) color.Color {
if _, ok := c.(HSL); ok {
return c
}
r, g, b, _ := c.RGBA()
h, s, l := RGBToHSL(uint8(r>>8), uint8(g>>8), uint8(b>>8))
return HSL{h, s, l}
} | [
"func",
"hslModel",
"(",
"c",
"color",
".",
"Color",
")",
"color",
".",
"Color",
"{",
"if",
"_",
",",
"ok",
":=",
"c",
".",
"(",
"HSL",
")",
";",
"ok",
"{",
"return",
"c",
"\n",
"}",
"\n",
"r",
",",
"g",
",",
"b",
",",
"_",
":=",
"c",
"."... | // hslModel converts a color.Color to HSL. | [
"hslModel",
"converts",
"a",
"color",
".",
"Color",
"to",
"HSL",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/xlsx/hsl.go#L56-L63 |
133,989 | henrylee2cn/pholcus | common/xlsx/file.go | Save | func (f *File) Save(path string) (err error) {
var target *os.File
target, err = os.Create(path)
if err != nil {
return
}
err = f.Write(target)
if err != nil {
return
}
return target.Close()
} | go | func (f *File) Save(path string) (err error) {
var target *os.File
target, err = os.Create(path)
if err != nil {
return
}
err = f.Write(target)
if err != nil {
return
}
return target.Close()
} | [
"func",
"(",
"f",
"*",
"File",
")",
"Save",
"(",
"path",
"string",
")",
"(",
"err",
"error",
")",
"{",
"var",
"target",
"*",
"os",
".",
"File",
"\n\n",
"target",
",",
"err",
"=",
"os",
".",
"Create",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
... | // Save the File to an xlsx file at the provided path. | [
"Save",
"the",
"File",
"to",
"an",
"xlsx",
"file",
"at",
"the",
"provided",
"path",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/xlsx/file.go#L89-L103 |
133,990 | henrylee2cn/pholcus | common/xlsx/file.go | Write | func (f *File) Write(writer io.Writer) (err error) {
var parts map[string]string
var zipWriter *zip.Writer
parts, err = f.MarshallParts()
if err != nil {
return
}
zipWriter = zip.NewWriter(writer)
for partName, part := range parts {
var writer io.Writer
writer, err = zipWriter.Create(partName)
if err ... | go | func (f *File) Write(writer io.Writer) (err error) {
var parts map[string]string
var zipWriter *zip.Writer
parts, err = f.MarshallParts()
if err != nil {
return
}
zipWriter = zip.NewWriter(writer)
for partName, part := range parts {
var writer io.Writer
writer, err = zipWriter.Create(partName)
if err ... | [
"func",
"(",
"f",
"*",
"File",
")",
"Write",
"(",
"writer",
"io",
".",
"Writer",
")",
"(",
"err",
"error",
")",
"{",
"var",
"parts",
"map",
"[",
"string",
"]",
"string",
"\n",
"var",
"zipWriter",
"*",
"zip",
".",
"Writer",
"\n\n",
"parts",
",",
"... | // Write the File to io.Writer as xlsx | [
"Write",
"the",
"File",
"to",
"io",
".",
"Writer",
"as",
"xlsx"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/xlsx/file.go#L106-L132 |
133,991 | henrylee2cn/pholcus | common/xlsx/file.go | AddSheet | func (f *File) AddSheet(sheetName string) (sheet *Sheet, err error) {
if _, exists := f.Sheet[sheetName]; exists {
return nil, fmt.Errorf("Duplicate sheet name '%s'.", sheetName)
}
sheet = &Sheet{Name: sheetName, File: f}
if len(f.Sheets) == 0 {
sheet.Selected = true
}
f.Sheet[sheetName] = sheet
f.Sheets = a... | go | func (f *File) AddSheet(sheetName string) (sheet *Sheet, err error) {
if _, exists := f.Sheet[sheetName]; exists {
return nil, fmt.Errorf("Duplicate sheet name '%s'.", sheetName)
}
sheet = &Sheet{Name: sheetName, File: f}
if len(f.Sheets) == 0 {
sheet.Selected = true
}
f.Sheet[sheetName] = sheet
f.Sheets = a... | [
"func",
"(",
"f",
"*",
"File",
")",
"AddSheet",
"(",
"sheetName",
"string",
")",
"(",
"sheet",
"*",
"Sheet",
",",
"err",
"error",
")",
"{",
"if",
"_",
",",
"exists",
":=",
"f",
".",
"Sheet",
"[",
"sheetName",
"]",
";",
"exists",
"{",
"return",
"n... | // Add a new Sheet, with the provided name, to a File | [
"Add",
"a",
"new",
"Sheet",
"with",
"the",
"provided",
"name",
"to",
"a",
"File"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/xlsx/file.go#L135-L146 |
133,992 | henrylee2cn/pholcus | common/xlsx/file.go | replaceRelationshipsNameSpace | func replaceRelationshipsNameSpace(workbookMarshal string) string {
newWorkbook := strings.Replace(workbookMarshal, `xmlns:relationships="http://schemas.openxmlformats.org/officeDocument/2006/relationships" relationships:id`, `r:id`, -1)
// Dirty hack to fix issues #63 and #91; encoding/xml currently
// "doesn't all... | go | func replaceRelationshipsNameSpace(workbookMarshal string) string {
newWorkbook := strings.Replace(workbookMarshal, `xmlns:relationships="http://schemas.openxmlformats.org/officeDocument/2006/relationships" relationships:id`, `r:id`, -1)
// Dirty hack to fix issues #63 and #91; encoding/xml currently
// "doesn't all... | [
"func",
"replaceRelationshipsNameSpace",
"(",
"workbookMarshal",
"string",
")",
"string",
"{",
"newWorkbook",
":=",
"strings",
".",
"Replace",
"(",
"workbookMarshal",
",",
"`xmlns:relationships=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" relationships:id`"... | // Some tools that read XLSX files have very strict requirements about
// the structure of the input XML. In particular both Numbers on the Mac
// and SAS dislike inline XML namespace declarations, or namespace
// prefixes that don't match the ones that Excel itself uses. This is a
// problem because the Go XML libra... | [
"Some",
"tools",
"that",
"read",
"XLSX",
"files",
"have",
"very",
"strict",
"requirements",
"about",
"the",
"structure",
"of",
"the",
"input",
"XML",
".",
"In",
"particular",
"both",
"Numbers",
"on",
"the",
"Mac",
"and",
"SAS",
"dislike",
"inline",
"XML",
... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/xlsx/file.go#L185-L194 |
133,993 | henrylee2cn/pholcus | common/ping/ping.go | Marshal | func (m *icmpMessage) Marshal() ([]byte, error) {
b := []byte{byte(m.Type), byte(m.Code), 0, 0}
if m.Body != nil && m.Body.Len() != 0 {
mb, err := m.Body.Marshal()
if err != nil {
return nil, err
}
b = append(b, mb...)
}
switch m.Type {
case icmpv6EchoRequest, icmpv6EchoReply:
return b, nil
}
csumcv... | go | func (m *icmpMessage) Marshal() ([]byte, error) {
b := []byte{byte(m.Type), byte(m.Code), 0, 0}
if m.Body != nil && m.Body.Len() != 0 {
mb, err := m.Body.Marshal()
if err != nil {
return nil, err
}
b = append(b, mb...)
}
switch m.Type {
case icmpv6EchoRequest, icmpv6EchoReply:
return b, nil
}
csumcv... | [
"func",
"(",
"m",
"*",
"icmpMessage",
")",
"Marshal",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"b",
":=",
"[",
"]",
"byte",
"{",
"byte",
"(",
"m",
".",
"Type",
")",
",",
"byte",
"(",
"m",
".",
"Code",
")",
",",
"0",
",",
"... | // Marshal returns the binary enconding of the ICMP echo request or
// reply message m. | [
"Marshal",
"returns",
"the",
"binary",
"enconding",
"of",
"the",
"ICMP",
"echo",
"request",
"or",
"reply",
"message",
"m",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/ping/ping.go#L39-L67 |
133,994 | henrylee2cn/pholcus | common/ping/ping.go | parseICMPMessage | func parseICMPMessage(b []byte) (*icmpMessage, error) {
msglen := len(b)
if msglen < 4 {
return nil, errors.New("message too short")
}
m := &icmpMessage{Type: int(b[0]), Code: int(b[1]), Checksum: int(b[2])<<8 | int(b[3])}
if msglen > 4 {
var err error
switch m.Type {
case icmpv4EchoRequest, icmpv4EchoRepl... | go | func parseICMPMessage(b []byte) (*icmpMessage, error) {
msglen := len(b)
if msglen < 4 {
return nil, errors.New("message too short")
}
m := &icmpMessage{Type: int(b[0]), Code: int(b[1]), Checksum: int(b[2])<<8 | int(b[3])}
if msglen > 4 {
var err error
switch m.Type {
case icmpv4EchoRequest, icmpv4EchoRepl... | [
"func",
"parseICMPMessage",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"*",
"icmpMessage",
",",
"error",
")",
"{",
"msglen",
":=",
"len",
"(",
"b",
")",
"\n",
"if",
"msglen",
"<",
"4",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
... | // parseICMPMessage parses b as an ICMP message. | [
"parseICMPMessage",
"parses",
"b",
"as",
"an",
"ICMP",
"message",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/ping/ping.go#L70-L87 |
133,995 | henrylee2cn/pholcus | common/ping/ping.go | Marshal | func (p *icmpEcho) Marshal() ([]byte, error) {
b := make([]byte, 4+len(p.Data))
b[0], b[1] = byte(p.ID>>8), byte(p.ID&0xff)
b[2], b[3] = byte(p.Seq>>8), byte(p.Seq&0xff)
copy(b[4:], p.Data)
return b, nil
} | go | func (p *icmpEcho) Marshal() ([]byte, error) {
b := make([]byte, 4+len(p.Data))
b[0], b[1] = byte(p.ID>>8), byte(p.ID&0xff)
b[2], b[3] = byte(p.Seq>>8), byte(p.Seq&0xff)
copy(b[4:], p.Data)
return b, nil
} | [
"func",
"(",
"p",
"*",
"icmpEcho",
")",
"Marshal",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"4",
"+",
"len",
"(",
"p",
".",
"Data",
")",
")",
"\n",
"b",
"[",
"0",
"]",
",",
... | // Marshal returns the binary enconding of the ICMP echo request or
// reply message body p. | [
"Marshal",
"returns",
"the",
"binary",
"enconding",
"of",
"the",
"ICMP",
"echo",
"request",
"or",
"reply",
"message",
"body",
"p",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/ping/ping.go#L105-L111 |
133,996 | henrylee2cn/pholcus | common/ping/ping.go | parseICMPEcho | func parseICMPEcho(b []byte) (*icmpEcho, error) {
bodylen := len(b)
p := &icmpEcho{ID: int(b[0])<<8 | int(b[1]), Seq: int(b[2])<<8 | int(b[3])}
if bodylen > 4 {
p.Data = make([]byte, bodylen-4)
copy(p.Data, b[4:])
}
return p, nil
} | go | func parseICMPEcho(b []byte) (*icmpEcho, error) {
bodylen := len(b)
p := &icmpEcho{ID: int(b[0])<<8 | int(b[1]), Seq: int(b[2])<<8 | int(b[3])}
if bodylen > 4 {
p.Data = make([]byte, bodylen-4)
copy(p.Data, b[4:])
}
return p, nil
} | [
"func",
"parseICMPEcho",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"*",
"icmpEcho",
",",
"error",
")",
"{",
"bodylen",
":=",
"len",
"(",
"b",
")",
"\n",
"p",
":=",
"&",
"icmpEcho",
"{",
"ID",
":",
"int",
"(",
"b",
"[",
"0",
"]",
")",
"<<",
"8",
... | // parseICMPEcho parses b as an ICMP echo request or reply message body. | [
"parseICMPEcho",
"parses",
"b",
"as",
"an",
"ICMP",
"echo",
"request",
"or",
"reply",
"message",
"body",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/ping/ping.go#L114-L122 |
133,997 | henrylee2cn/pholcus | app/downloader/surfer/surf.go | Reg | func (d *DnsCache) Reg(addr, ipPort string) {
d.ipPortLib.Store(addr, ipPort)
} | go | func (d *DnsCache) Reg(addr, ipPort string) {
d.ipPortLib.Store(addr, ipPort)
} | [
"func",
"(",
"d",
"*",
"DnsCache",
")",
"Reg",
"(",
"addr",
",",
"ipPort",
"string",
")",
"{",
"d",
".",
"ipPortLib",
".",
"Store",
"(",
"addr",
",",
"ipPort",
")",
"\n",
"}"
] | // Reg registers ipPort to DNS cache. | [
"Reg",
"registers",
"ipPort",
"to",
"DNS",
"cache",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/app/downloader/surfer/surf.go#L94-L96 |
133,998 | henrylee2cn/pholcus | app/downloader/surfer/surf.go | Query | func (d *DnsCache) Query(addr string) (string, bool) {
ipPort, ok := d.ipPortLib.Load(addr)
if !ok {
return "", false
}
return ipPort.(string), true
} | go | func (d *DnsCache) Query(addr string) (string, bool) {
ipPort, ok := d.ipPortLib.Load(addr)
if !ok {
return "", false
}
return ipPort.(string), true
} | [
"func",
"(",
"d",
"*",
"DnsCache",
")",
"Query",
"(",
"addr",
"string",
")",
"(",
"string",
",",
"bool",
")",
"{",
"ipPort",
",",
"ok",
":=",
"d",
".",
"ipPortLib",
".",
"Load",
"(",
"addr",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\""... | // Query queries ipPort from DNS cache. | [
"Query",
"queries",
"ipPort",
"from",
"DNS",
"cache",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/app/downloader/surfer/surf.go#L104-L110 |
133,999 | henrylee2cn/pholcus | common/session/sess_mem.go | Set | func (st *MemSessionStore) Set(key, value interface{}) {
st.lock.Lock()
defer st.lock.Unlock()
st.value[key] = value
} | go | func (st *MemSessionStore) Set(key, value interface{}) {
st.lock.Lock()
defer st.lock.Unlock()
st.value[key] = value
} | [
"func",
"(",
"st",
"*",
"MemSessionStore",
")",
"Set",
"(",
"key",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"st",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"st",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"st",
".",
"value",
"["... | // Set value to memory session | [
"Set",
"value",
"to",
"memory",
"session"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_mem.go#L36-L40 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.