goflyway icon indicating copy to clipboard operation
goflyway copied to clipboard

proxy: fix case order in a type switch

Open quasilyte opened this issue 5 years ago • 0 comments

Type switch executes its clauses sequentially until the first match. The *tcpmux.Stream type implements net.Conn, so if net.Conn goes before *tcpmux.Stream case, it will catch *tcpmux.Stream values and will never let case *tcpmux.Stream` to execute. The solution is simple, move specific type case before the interface it implements.

Found using gocritic linter, caseOrder checker.

quasilyte avatar Dec 10 '18 23:12 quasilyte