From a53fb5fa3392e9c65de3b44de2f4ce99ea393e7f Mon Sep 17 00:00:00 2001 From: cappyzawa Date: Fri, 28 Dec 2018 21:42:08 +0900 Subject: [PATCH] fix based on golint --- lib/attack.go | 4 ++-- lib/attack_test.go | 4 ++-- lib/lttb/lttb_test.go | 2 +- lib/plot/timeseries.go | 2 +- lib/results_easyjson.go | 43 +++++++++++++++++++++-------------------- lib/targets_easyjson.go | 30 ++++++++++++++-------------- main.go | 6 +++++- 7 files changed, 48 insertions(+), 43 deletions(-) diff --git a/lib/attack.go b/lib/attack.go index 96c08793..9855a28e 100644 --- a/lib/attack.go +++ b/lib/attack.go @@ -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, diff --git a/lib/attack_test.go b/lib/attack_test.go index 72a6b5e7..aa344f3f 100644 --- a/lib/attack_test.go +++ b/lib/attack_test.go @@ -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, diff --git a/lib/lttb/lttb_test.go b/lib/lttb/lttb_test.go index 41b22654..39ebda1f 100644 --- a/lib/lttb/lttb_test.go +++ b/lib/lttb/lttb_test.go @@ -1,9 +1,9 @@ package lttb import ( - "sync" "fmt" "reflect" + "sync" "testing" "unsafe" diff --git a/lib/plot/timeseries.go b/lib/plot/timeseries.go index 02eaf4b5..19e662e7 100644 --- a/lib/plot/timeseries.go +++ b/lib/plot/timeseries.go @@ -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 { diff --git a/lib/results_easyjson.go b/lib/results_easyjson.go index b763ecb4..b1594bdc 100644 --- a/lib/results_easyjson.go +++ b/lib/results_easyjson.go @@ -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 ( @@ -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 { @@ -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() @@ -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 @@ -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\":" @@ -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\":" @@ -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\":" @@ -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\":" @@ -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\":" @@ -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\":" @@ -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\":" @@ -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\":" @@ -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('}') } diff --git a/lib/targets_easyjson.go b/lib/targets_easyjson.go index 2d14b1a5..f2e54244 100644 --- a/lib/targets_easyjson.go +++ b/lib/targets_easyjson.go @@ -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 { @@ -32,15 +32,15 @@ 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() { @@ -48,9 +48,9 @@ func (out *jsonTarget) decode(in *jlexer.Lexer) { } 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()) @@ -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('}') @@ -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 @@ -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\":" @@ -116,9 +116,9 @@ 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 @@ -126,9 +126,9 @@ func (in jsonTarget) encode(out *jwriter.Writer) { } 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 @@ -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 { diff --git a/main.go b/main.go index 69087ae2..8ebe9db9 100644 --- a/main.go +++ b/main.go @@ -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: