Skip to content

Commit

Permalink
fix based on golint
Browse files Browse the repository at this point in the history
  • Loading branch information
cappyzawa committed Dec 28, 2018
1 parent 9a3da3a commit a53fb5f
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 43 deletions.
4 changes: 2 additions & 2 deletions lib/attack.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ func NewAttacker(opts ...func(*Attacker)) *Attacker {

a.client = http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
Dial: a.dialer.Dial,
Proxy: http.ProxyFromEnvironment,
Dial: a.dialer.Dial,
ResponseHeaderTimeout: DefaultTimeout,
TLSClientConfig: DefaultTLSConfig,
TLSHandshakeTimeout: 10 * time.Second,
Expand Down
4 changes: 2 additions & 2 deletions lib/attack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ func TestClient(t *testing.T) {
client := &http.Client{
Timeout: time.Duration(1 * time.Nanosecond),
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
Dial: dialer.Dial,
Proxy: http.ProxyFromEnvironment,
Dial: dialer.Dial,
ResponseHeaderTimeout: DefaultTimeout,
TLSClientConfig: DefaultTLSConfig,
TLSHandshakeTimeout: 10 * time.Second,
Expand Down
2 changes: 1 addition & 1 deletion lib/lttb/lttb_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package lttb

import (
"sync"
"fmt"
"reflect"
"sync"
"testing"
"unsafe"

Expand Down
2 changes: 1 addition & 1 deletion lib/plot/timeseries.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func newTimeSeries(attack, label string) *timeSeries {
}
}

var errMonotonicTimestamp = errors.New("timeseries: non monotonically increasing timestamp.")
var errMonotonicTimestamp = errors.New("timeseries: non monotonically increasing timestamp")

func (ts *timeSeries) add(t uint64, v float64) error {
if ts.prev > t {
Expand Down
43 changes: 22 additions & 21 deletions lib/results_easyjson.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This file has been modified from the original generated code to make it work with
// type alias jsonResult so that the methods aren't exposed in Result.

package vegeta

import (
Expand All @@ -11,7 +12,7 @@ import (

type jsonResult Result

func (out *jsonResult) decode(in *jlexer.Lexer) {
func (r *jsonResult) decode(in *jlexer.Lexer) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
Expand All @@ -31,29 +32,29 @@ func (out *jsonResult) decode(in *jlexer.Lexer) {
}
switch key {
case "attack":
out.Attack = string(in.String())
r.Attack = string(in.String())
case "seq":
out.Seq = uint64(in.Uint64())
r.Seq = uint64(in.Uint64())
case "code":
out.Code = uint16(in.Uint16())
r.Code = uint16(in.Uint16())
case "timestamp":
if data := in.Raw(); in.Ok() {
in.AddError((out.Timestamp).UnmarshalJSON(data))
in.AddError((r.Timestamp).UnmarshalJSON(data))
}
case "latency":
out.Latency = time.Duration(in.Int64())
r.Latency = time.Duration(in.Int64())
case "bytes_out":
out.BytesOut = uint64(in.Uint64())
r.BytesOut = uint64(in.Uint64())
case "bytes_in":
out.BytesIn = uint64(in.Uint64())
r.BytesIn = uint64(in.Uint64())
case "error":
out.Error = string(in.String())
r.Error = string(in.String())
case "body":
if in.IsNull() {
in.Skip()
out.Body = nil
r.Body = nil
} else {
out.Body = in.Bytes()
r.Body = in.Bytes()
}
default:
in.SkipRecursive()
Expand All @@ -66,7 +67,7 @@ func (out *jsonResult) decode(in *jlexer.Lexer) {
}
}

func (in jsonResult) encode(out *jwriter.Writer) {
func (r jsonResult) encode(out *jwriter.Writer) {
out.RawByte('{')
first := true
_ = first
Expand All @@ -78,7 +79,7 @@ func (in jsonResult) encode(out *jwriter.Writer) {
} else {
out.RawString(prefix)
}
out.String(string(in.Attack))
out.String(string(r.Attack))
}
{
const prefix string = ",\"seq\":"
Expand All @@ -88,7 +89,7 @@ func (in jsonResult) encode(out *jwriter.Writer) {
} else {
out.RawString(prefix)
}
out.Uint64(uint64(in.Seq))
out.Uint64(uint64(r.Seq))
}
{
const prefix string = ",\"code\":"
Expand All @@ -98,7 +99,7 @@ func (in jsonResult) encode(out *jwriter.Writer) {
} else {
out.RawString(prefix)
}
out.Uint16(uint16(in.Code))
out.Uint16(uint16(r.Code))
}
{
const prefix string = ",\"timestamp\":"
Expand All @@ -108,7 +109,7 @@ func (in jsonResult) encode(out *jwriter.Writer) {
} else {
out.RawString(prefix)
}
out.Raw((in.Timestamp).MarshalJSON())
out.Raw((r.Timestamp).MarshalJSON())
}
{
const prefix string = ",\"latency\":"
Expand All @@ -118,7 +119,7 @@ func (in jsonResult) encode(out *jwriter.Writer) {
} else {
out.RawString(prefix)
}
out.Int64(int64(in.Latency))
out.Int64(int64(r.Latency))
}
{
const prefix string = ",\"bytes_out\":"
Expand All @@ -128,7 +129,7 @@ func (in jsonResult) encode(out *jwriter.Writer) {
} else {
out.RawString(prefix)
}
out.Uint64(uint64(in.BytesOut))
out.Uint64(uint64(r.BytesOut))
}
{
const prefix string = ",\"bytes_in\":"
Expand All @@ -138,7 +139,7 @@ func (in jsonResult) encode(out *jwriter.Writer) {
} else {
out.RawString(prefix)
}
out.Uint64(uint64(in.BytesIn))
out.Uint64(uint64(r.BytesIn))
}
{
const prefix string = ",\"error\":"
Expand All @@ -148,7 +149,7 @@ func (in jsonResult) encode(out *jwriter.Writer) {
} else {
out.RawString(prefix)
}
out.String(string(in.Error))
out.String(string(r.Error))
}
{
const prefix string = ",\"body\":"
Expand All @@ -158,7 +159,7 @@ func (in jsonResult) encode(out *jwriter.Writer) {
} else {
out.RawString(prefix)
}
out.Base64Bytes(in.Body)
out.Base64Bytes(r.Body)
}
out.RawByte('}')
}
30 changes: 15 additions & 15 deletions lib/targets_easyjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

type jsonTarget Target

func (out *jsonTarget) decode(in *jlexer.Lexer) {
func (t *jsonTarget) decode(in *jlexer.Lexer) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
Expand All @@ -32,25 +32,25 @@ func (out *jsonTarget) decode(in *jlexer.Lexer) {
}
switch key {
case "method":
out.Method = string(in.String())
t.Method = string(in.String())
case "url":
out.URL = string(in.String())
t.URL = string(in.String())
case "body":
if in.IsNull() {
in.Skip()
out.Body = nil
t.Body = nil
} else {
out.Body = in.Bytes()
t.Body = in.Bytes()
}
case "header":
if in.IsNull() {
in.Skip()
} else {
in.Delim('{')
if !in.IsDelim('}') {
out.Header = make(http.Header)
t.Header = make(http.Header)
} else {
out.Header = nil
t.Header = nil
}
for !in.IsDelim('}') {
key := string(in.String())
Expand Down Expand Up @@ -78,7 +78,7 @@ func (out *jsonTarget) decode(in *jlexer.Lexer) {
}
in.Delim(']')
}
(out.Header)[key] = v2
(t.Header)[key] = v2
in.WantComma()
}
in.Delim('}')
Expand All @@ -94,7 +94,7 @@ func (out *jsonTarget) decode(in *jlexer.Lexer) {
}
}

func (in jsonTarget) encode(out *jwriter.Writer) {
func (t jsonTarget) encode(out *jwriter.Writer) {
out.RawByte('{')
first := true
_ = first
Expand All @@ -106,7 +106,7 @@ func (in jsonTarget) encode(out *jwriter.Writer) {
} else {
out.RawString(prefix)
}
out.String(string(in.Method))
out.String(string(t.Method))
}
{
const prefix string = ",\"url\":"
Expand All @@ -116,19 +116,19 @@ func (in jsonTarget) encode(out *jwriter.Writer) {
} else {
out.RawString(prefix)
}
out.String(string(in.URL))
out.String(string(t.URL))
}
if len(in.Body) != 0 {
if len(t.Body) != 0 {
const prefix string = ",\"body\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
out.Base64Bytes(in.Body)
out.Base64Bytes(t.Body)
}
if len(in.Header) != 0 {
if len(t.Header) != 0 {
const prefix string = ",\"header\":"
if first {
first = false
Expand All @@ -139,7 +139,7 @@ func (in jsonTarget) encode(out *jwriter.Writer) {
{
out.RawByte('{')
v6First := true
for v6Name, v6Value := range in.Header {
for v6Name, v6Value := range t.Header {
if v6First {
v6First = false
} else {
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ func main() {
}

// Set at linking time
var Version, Commit, Date string
var (
Commit string
Date string
Version string
)

const examples = `
examples:
Expand Down

0 comments on commit a53fb5f

Please sign in to comment.