Staticcheck
Staticcheck is a state of the art linter for the Go programming language. Using static analysis, it finds bugs and performance issues, offers simplifications, and enforces style rules.
Tools
- staticcheck - Go static analysis, detecting bugs, performance issues, and much more.
- structlayout - Displays the layout (field sizes and padding) of structs.
- structlayout-optimize - Reorders struct fields to minimize the amount of padding.
- structlayout-pretty - Formats the output of structlayout with ASCII art.
Install
$GOPATH/bin에 설치된다. staticcheck 를 명령행에서 실행하면 된다.
Usage
그냥 Go 파일들 있는 위치 넣어주면 된다.
문제가 있다면 다음과 같이 에러가 출력된다:
run script example
하위 폴더를 재귀적으로 찾게 하기 위해 ./lib/... 처럼 입력하면 된다:
#!/usr/bin/env bash
ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" || exit; pwd)
if ! command -v go &> /dev/null; then
echo "Not found go command" 1>&2
exit 1
fi
staticcheck \
"$ROOT_DIR/lib/..." \
"$ROOT_DIR/cmd/..."
Warnings
출력되는 에러 또는 경고 목록에 대한 대응 방안 정리.
wrong type for method ProtoReflect
자세한 내용은 Protocol Buffers#wrong type for method ProtoReflect 항목 확인.