Style: cleanup code

This commit is contained in:
Dreamacro
2021-03-24 01:00:21 +08:00
parent 807d53c1e7
commit d759d16944
9 changed files with 40 additions and 50 deletions

View File

@ -173,7 +173,7 @@ func (s *searcher) searchSocketPid(socket uint64) (uint32, error) {
}
func newSearcher(major int) *searcher {
var s *searcher = nil
var s *searcher
switch major {
case 11:
s = &searcher{

View File

@ -22,8 +22,8 @@ const (
)
var (
getExTcpTable uintptr
getExUdpTable uintptr
getExTCPTable uintptr
getExUDPTable uintptr
queryProcName uintptr
once sync.Once
@ -35,12 +35,12 @@ func initWin32API() error {
return fmt.Errorf("LoadLibrary iphlpapi.dll failed: %s", err.Error())
}
getExTcpTable, err = windows.GetProcAddress(h, tcpTableFunc)
getExTCPTable, err = windows.GetProcAddress(h, tcpTableFunc)
if err != nil {
return fmt.Errorf("GetProcAddress of %s failed: %s", tcpTableFunc, err.Error())
}
getExUdpTable, err = windows.GetProcAddress(h, udpTableFunc)
getExUDPTable, err = windows.GetProcAddress(h, udpTableFunc)
if err != nil {
return fmt.Errorf("GetProcAddress of %s failed: %s", udpTableFunc, err.Error())
}
@ -76,10 +76,10 @@ func findProcessName(network string, ip net.IP, srcPort int) (string, error) {
var fn uintptr
switch network {
case TCP:
fn = getExTcpTable
fn = getExTCPTable
class = tcpTablePidConn
case UDP:
fn = getExUdpTable
fn = getExUDPTable
class = udpTablePid
default:
return "", ErrInvalidNetwork

View File

@ -122,11 +122,7 @@ func (t *DomainTrie) search(node *Node, parts []string) *Node {
}
}
if c := node.getChild(dotWildcard); c != nil {
return c
}
return nil
return node.getChild(dotWildcard)
}
// New returns a new, empty Trie.

View File

@ -90,10 +90,7 @@ func (hc *h2Conn) Close() error {
if err := hc.ClientConn.Shutdown(hc.res.Request.Context()); err != nil {
return err
}
if err := hc.Conn.Close(); err != nil {
return err
}
return nil
return hc.Conn.Close()
}
func StreamH2Conn(conn net.Conn, cfg *H2Config) (net.Conn, error) {