
* Initial commit * Fixed goimports * Update pkg/golinters/mnd.go Co-Authored-By: Bot from GolangCI <42910462+golangcibot@users.noreply.github.com> * Run goimports * Update pkg/golinters/mnd.go Co-Authored-By: Bot from GolangCI <42910462+golangcibot@users.noreply.github.com> * Add prefix for goimport local * Run make README.md * Incorporate review comments Add test cases * Update readme * Update the description * Removed subpath in local-prefixes * Update readme
37 lines
645 B
Go
37 lines
645 B
Go
//args: -Egomnd
|
|
package testdata
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
func UseMagicNumber() {
|
|
c := &http.Client{
|
|
Timeout: 1 * time.Second, // ERROR : "Magic number: 1, in <assign> detected"
|
|
}
|
|
|
|
res, err := c.Get("http://www.google.com")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
if res.StatusCode != 200 { // ERROR : "Magic number: 200, in <condition> detected"
|
|
log.Println("Something went wrong")
|
|
}
|
|
}
|
|
|
|
func UseNoMagicNumber() {
|
|
c := &http.Client{
|
|
Timeout: time.Second,
|
|
}
|
|
|
|
res, err := c.Get("http://www.google.com")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
if res.StatusCode != http.StatusOK {
|
|
log.Println("Something went wrong")
|
|
}
|
|
}
|