GoLand에서 부활 Go 린터 구성
Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. Revive provides a framework for development of custom rules, and lets you define a strict preset for enhancing your development & code review processes.
revive linter을 구성하고 GoLand에 구현해 보겠습니다. 먼저
go get
작업을 사용하여 패키지를 다운로드해야 합니다.go get -u github.com/mgechev/revive
그런 다음
$GOPATH/bin
로 이동하고 ./revive
를 실행하여 예상대로 작동하는지 확인합니다. 오류가 없어야 합니다.따라서 소생의 주요 이점은 쉽게 구성할 수 있다는 것입니다. 프로젝트 디렉토리로 이동하여 새 디렉토리를 추가하십시오. docs의 권장 구성으로
config.toml
파일을 생성합니다. 구문 강조에 관심이 있다면 Toml plugin을 설치하십시오.ignoreGeneratedHeader = false
severity = "warning"
confidence = 0.8
errorCode = 0
warningCode = 0
[rule.blank-imports]
[rule.context-as-argument]
[rule.context-keys-type]
[rule.dot-imports]
[rule.error-return]
[rule.error-strings]
[rule.error-naming]
[rule.exported]
[rule.if-return]
[rule.increment-decrement]
[rule.var-naming]
[rule.var-declaration]
[rule.package-comments]
[rule.range]
[rule.receiver-naming]
[rule.time-naming]
[rule.unexported-return]
[rule.indent-error-flow]
[rule.errorf]
[rule.empty-block]
[rule.superfluous-else]
[rule.unused-parameter]
[rule.unreachable-code]
[rule.redefines-builtin-id]
구성 및 설치 단계가 완료되었습니다. 이제 GoLand에서 File Watcher을 구성할 시간입니다.
File Watcher is a GoLand tool that allows you to automatically run a command-line tool like compilers, formatters, or linters when you change or save a file in the IDE.
IDE 설정(
Preferences / Settings | Tools | File Watchers
)으로 이동하여 새 파일 감시자를 추가하고 사용자 정의 템플릿을 선택합니다.
예를 들어 이름을 추가하십시오. linter를 부활시킨 다음 파일 유형을 Go 파일로 설정하십시오. 범위 옵션은 프로젝트 파일이어야 합니다. 다음 단계는 변경 사항에 따라 실행할 도구를 작성하는 것입니다.
$GOPATH/bin
), 예: /Users/user.name/go/bin/revive
. -config config.toml -formatter unix ./…
-config
이전에 만든 구성의 경로입니다. -formatter
포맷터 유형입니다. 저는 유닉스를 선호합니다. ./..
프로젝트 디렉토리 내의 모든 Go 파일을 확인합니다. $ProjectFileDir$
매크로. 고급 옵션을 확장하고 항상 콘솔 표시를 선택하고 필요한 경우 다른 확인란을 선택/선택 취소합니다. 구성 결과는 아래 스크린샷에 나와 있습니다.

그게 다야. 변경 사항을 저장한 다음 간단한 파일을 만들고 변경 사항을 저장해 보십시오. 축하해요! 🎉

Reference
이 문제에 관하여(GoLand에서 부활 Go 린터 구성), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/s0xzwasd/configure-revive-go-linter-in-goland-2ggl텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)