-
Notifications
You must be signed in to change notification settings - Fork 17
/
argument.go
82 lines (64 loc) · 1.18 KB
/
argument.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package argument
import (
"context"
"math"
"net/http"
"os"
"strings"
"sync"
"time"
)
var MyValue = float32(20) // want "Magic number: 20"
const MyConstantValue = float32(20)
const (
FooBlockTypeConversion = int64(512)
BarBlockTypeConversion = uint8(2)
)
func example() {
math.Abs(9.5) // want "Magic number: 9.5"
}
func example2() {
strings.ToUpper("foo")
}
type s struct {
count int
}
func (s *s) Add(count int) {
s.count += count
}
func example3() {
s := &s{}
s.Add(10) // want "Magic number: 10"
}
func example4() {
ctx, cancelFunc := context.WithTimeout(context.Background(), 5*time.Second) // want "Magic number: 5"
defer cancelFunc()
ctx.Value("foo")
}
func example5() {
http.StatusText(200) // want "Magic number: 200"
}
func example6() string {
t := time.Date(2017, time.September, 26, 12, 13, 14, 0, time.UTC)
return t.String()
}
func example7() {
c := make(chan int, 1)
c <- 1
}
func example8() {
c := make(chan int, 2) // want "Magic number: 2"
c <- 1
}
func example9() {
os.Exit(1)
}
func example10() {
var wg sync.WaitGroup
wg.Add(1)
go func() {
duration := 500 * time.Millisecond // want "Magic number: 500"
time.Sleep(duration)
wg.Done()
}()
}