You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
req52, _:=newRequestPkg(http.MethodPost, url, nil) // TODO: false negative `net/http\.NewRequest must not be called. use net/http\.NewRequestWithContext`
req121=req121.WithContext(context.WithValue(req121.Context(), struct{}{}, 0)) // want `\(\*net/http\.Request\)\.WithContext must not be called. use net/http\.NewRequestWithContext`
122
+
cli.Do(req121)
123
+
}
124
+
125
+
func_() {
126
+
consturl="http://example.com"
127
+
cli:=&http.Client{}
128
+
129
+
http.Get(url) // want `net/http\.Get must not be called. use net/http\.NewRequestWithContext and \(\*net/http.Client\)\.Do\(\*http.Request\)`
130
+
_=http.Get// OK
131
+
f:=http.Get// OK
132
+
f(url) // want `net/http\.Get must not be called. use net/http\.NewRequestWithContext and \(\*net/http.Client\)\.Do\(\*http.Request\)`
133
+
134
+
http.Head(url) // want `net/http\.Head must not be called. use net/http\.NewRequestWithContext and \(\*net/http.Client\)\.Do\(\*http.Request\)`
135
+
http.Post(url, "", nil) // want `net/http\.Post must not be called. use net/http\.NewRequestWithContext and \(\*net/http.Client\)\.Do\(\*http.Request\)`
136
+
http.PostForm(url, nil) // want `net/http\.PostForm must not be called. use net/http\.NewRequestWithContext and \(\*net/http.Client\)\.Do\(\*http.Request\)`
137
+
138
+
cli.Get(url) // want `\(\*net/http\.Client\)\.Get must not be called. use \(\*net/http.Client\)\.Do\(\*http.Request\)`
139
+
_=cli.Get// OK
140
+
m:=cli.Get// OK
141
+
m(url) // want `\(\*net/http\.Client\)\.Get must not be called. use \(\*net/http.Client\)\.Do\(\*http.Request\)`
142
+
143
+
cli.Head(url) // want `\(\*net/http\.Client\)\.Head must not be called. use \(\*net/http.Client\)\.Do\(\*http.Request\)`
144
+
cli.Post(url, "", nil) // want `\(\*net/http\.Client\)\.Post must not be called. use \(\*net/http.Client\)\.Do\(\*http.Request\)`
145
+
cli.PostForm(url, nil) // want `\(\*net/http\.Client\)\.PostForm must not be called. use \(\*net/http.Client\)\.Do\(\*http.Request\)`
133
146
}
134
147
148
+
func_() {
149
+
ctx:=context.Background()
150
+
151
+
db, _:=sql.Open("noctx", "noctx://")
152
+
153
+
db.Exec("select * from testdata") // want `\(\*database/sql\.DB\)\.Exec must not be called. use \(\*database/sql\.DB\)\.ExecContext`
154
+
db.ExecContext(ctx, "select * from testdata")
155
+
156
+
db.Ping() // want `\(\*database/sql\.DB\)\.Ping must not be called. use \(\*database/sql\.DB\)\.PingContext`
157
+
db.PingContext(ctx)
158
+
159
+
db.Prepare("select * from testdata") // want `\(\*database/sql\.DB\)\.Prepare must not be called. use \(\*database/sql\.DB\)\.PrepareContext`
160
+
db.PrepareContext(ctx, "select * from testdata")
161
+
162
+
db.Query("select * from testdata") // want `\(\*database/sql\.DB\)\.Query must not be called. use \(\*database/sql\.DB\)\.QueryContext`
163
+
db.QueryContext(ctx, "select * from testdata")
164
+
165
+
db.QueryRow("select * from testdata") // want `\(\*database/sql\.DB\)\.QueryRow must not be called. use \(\*database/sql\.DB\)\.QueryRowContext`
166
+
db.QueryRowContext(ctx, "select * from testdata")
167
+
168
+
// transactions
169
+
170
+
tx, _:=db.Begin()
171
+
tx.Exec("select * from testdata") // want `\(\*database/sql\.Tx\)\.Exec must not be called. use \(\*database/sql\.Tx\)\.ExecContext`
172
+
tx.ExecContext(ctx, "select * from testdata")
173
+
174
+
tx.Prepare("select * from testdata") // want `\(\*database/sql\.Tx\)\.Prepare must not be called. use \(\*database/sql\.Tx\)\.PrepareContext`
175
+
tx.PrepareContext(ctx, "select * from testdata")
176
+
177
+
tx.Query("select * from testdata") // want `\(\*database/sql\.Tx\)\.Query must not be called. use \(\*database/sql\.Tx\)\.QueryContext`
178
+
tx.QueryContext(ctx, "select * from testdata")
179
+
180
+
tx.QueryRow("select * from testdata") // want `\(\*database/sql\.Tx\)\.QueryRow must not be called. use \(\*database/sql\.Tx\)\.QueryRowContext`
0 commit comments