GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#9)
by zuochao
06:30
created

utils.Timeout   A

Complexity

Conditions 2

Size

Total Lines 6
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
dl 0
loc 6
rs 10
c 0
b 0
f 0
nop 1
1
package utils
2
3
import (
4
	"context"
5
	"net"
6
	"time"
7
)
8
9
// Runtime is for setting timeout, proxy and host
10
type Runtime struct {
11
	ReadTimeout    int
12
	ConnectTimeout int
13
	Proxy          string
14
	Host           string
15
}
16
17
// NewRuntime returns a Runtime
18
func NewRuntime(readTimeout, connectTimeout int, proxy string, host string) *Runtime {
19
	return &Runtime{
20
		ReadTimeout:    readTimeout,
21
		ConnectTimeout: connectTimeout,
22
		Proxy:          proxy,
23
		Host:           host,
24
	}
25
}
26
27
// Timeout is for connect Timeout
28
func Timeout(connectTimeout time.Duration) func(cxt context.Context, net, addr string) (c net.Conn, err error) {
29
	return func(ctx context.Context, network, address string) (net.Conn, error) {
30
		return (&net.Dialer{
31
			Timeout:   connectTimeout,
32
			DualStack: true,
33
		}).DialContext(ctx, network, address)
34
	}
35
}
36