2
나는 Go 앱을 개발하기 위해 Atom을 사용하고 있습니다. Atom의 Linter는 이상한 경고를보고하고 있으며, 나는 그것이 어떻게 문제인지를 보지 못했습니다. 나는 경고를 영원히 무시해야합니까, 아니면 구현할 수있는 다른 방법이 있습니까?linter의 goconst 경고
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.
}
}
: 내 "routes_pages.go"파일에서
a.Router.HandleFunc("/login", a.PageLogin)
a.Router.HandleFunc("/register", a.PageRegister)
a.Router.HandleFunc("/event/add", a.PageEventCreate)
, 내가 그렇게 같이 정의 funcs 있습니다
나는 "app.go"파일에, 그래서 같은 경로를 가지고 나는 이런 식으로 많은 funcs 셋업을 가지고있다. 한 곳에서 어떤 경우 (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 등으로 스위치/케이스의 모든 인스턴스에 대해 한 번; 거대한 목록.