Skip to content

Commit

Permalink
all: simplify variable initialization
Browse files Browse the repository at this point in the history
If we assign the variable after declaring it, we can simplify it using
":=" operator or "= value".
The reader can still known the type of variable from the struct name or
variable type before assignment operator.
  • Loading branch information
shuLhan committed Jan 30, 2019
1 parent 7e00ec6 commit 07f0c88
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
8 changes: 2 additions & 6 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ func TestClientRedirectSameSchema(t *testing.T) {
return
}

var reqClient *HostClient

reqClient = &HostClient{
reqClient := &HostClient{
IsTLS: true,
Addr: urlParsed.Host,
TLSConfig: &tls.Config{
Expand Down Expand Up @@ -117,9 +115,7 @@ func TestClientRedirectChangingSchemaHttp2Https(t *testing.T) {
return
}

var reqClient *HostClient

reqClient = &HostClient{
reqClient := &HostClient{
Addr: urlParsed.Host,
TLSConfig: &tls.Config{
InsecureSkipVerify: true,
Expand Down
3 changes: 1 addition & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1986,8 +1986,7 @@ func (s *Server) serveConn(c net.Conn) error {
}

if hijackHandler != nil {
var hjr io.Reader
hjr = c
var hjr io.Reader = c
if br != nil {
hjr = br
br = nil
Expand Down

0 comments on commit 07f0c88

Please sign in to comment.