私はGoアプリケーションを開発するためにAtomを使用しています。 AtomのLinterは奇妙な警告を報告していますが、それがどのように問題であるかわかりません。私は永遠に警告を無視すべきか、あるいは私が実装できる別の方法がありますか?linterからのgoconst警告
私は、ファイル内の "app.go" のようなルートを持っている:、私の "routes_pages.go" ファイルで
a.Router.HandleFunc("/login", a.PageLogin)
a.Router.HandleFunc("/register", a.PageRegister)
a.Router.HandleFunc("/event/add", a.PageEventCreate)
私はそうのように定義されたのfuncsを持っている:
func (a *App) PageEventCreate(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case "GET":
// Serve the resource.
case "POST":
// Create a new record.
case "PUT":
// Update an existing record.
case "DELETE":
// Remove the record.
default:
// Give an error message.
}
}
func (a *App) PageLogin(res http.ResponseWriter, req *http.Request) {
switch r.Method {
case "GET":
// Serve the resource.
case "POST":
// Create a new record.
case "PUT":
// Update an existing record.
case "DELETE":
// Remove the record.
default:
// Give an error message.
}
}
私はこのように多くの機能を設定しています。 1つの場所でどのような場合(GET、POSTなど)でも簡単に作業できます。
AtomのLinterに問題があります。
Warning goconst 3 other occurrence(s) of "GET" found in: routes_pages.go:384:8 routes_pages.go:443:7 routes_pages.go:536:7 (goconst) 198:8
この警告は何度も表示されます。 GET、PUT、DELETEなどのスイッチ/ケースのインスタンスごとに1回。巨大なリスト。
それはあなたがしているだけの警告だ