go-linter-configuration
Configure and troubleshoot golangci-lint for Go projects. Handle import resolution issues, type-checking problems, and optimize configurations for both local and CI environments.
- License 许可
- MIT
- 最近更新
- 2026-08-23
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- go-linter-configuration
- metadata
- { "openclaw": { "emoji": "?", "install": [ { "id": "golang", "bins": [ "go" ], "kind": "script", "label": "Install Go", "script": "curl -L https://golang.org/dl/go1.21.5.linux-amd64.tar.gz | tar -C /usr/local -xzf -" }, { "id": "golangci", "bins": [ "golangci-lint" ], "kind": "script", "label": "Install golangci-lint", "script": "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.1" } ], "requires": { "bins": [ "go", "golangci-lint" ] } } }
- description
- Configure and troubleshoot golangci-lint for Go projects. Handle import resolution issues, type-checking problems, and optimize configurations for both local and CI environments.
02 资源文件 1
- 参考文档_meta.json300 B
03 SKILL.md 正文
Go Linter Configuration Skill
Configure and troubleshoot golangci-lint for Go projects. This skill helps handle import resolution issues, type-checking problems, and optimize configurations for both local and CI environments.
Installation
Install golangci-lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
Or use the official installation script:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.1
Basic Usage
Run linter on entire project:
golangci-lint run ./...
Run with specific configuration:
golangci-lint run --config .golangci.yml ./...
Configuration File (.golangci.yml)
Minimal Configuration (for CI environments with import issues)
run:
timeout: 5m
tests: false
build-tags: []
linters:
disable-all: true
enable:
- gofmt # Format checking only
linters-settings:
gofmt:
simplify: true
issues:
exclude-use-default: false
max-issues-per-linter: 50
max-same-issues: 3
output:
format: tab
Standard Configuration (for local development)
run:
timeout: 5m
tests: true
build-tags: []
linters:
enable:
- gofmt
- govet
- errcheck
- staticcheck
- unused
- gosimple
- ineffassign
linters-settings:
govet:
enable:
- shadow
errcheck:
check-type-assertions: true
staticcheck:
checks: ["all"]
issues:
exclude-use-default: false
max-issues-per-linter: 50
max-same-issues: 3
output:
format: tab
Troubleshooting Common Issues
"undefined: package" Errors
Problem: Linter reports undefined references to imported packages
Solution: Use minimal configuration with disable-all: true and only enable basic linters like gofmt
Import Resolution Problems
Problem: CI environment cannot resolve dependencies properly Solution:
- Ensure go.mod and go.sum are up to date
- Use
go mod downloadbefore running linter in CI - Consider using simpler linters in CI environment
Type-Checking Failures
Problem: Linter fails during type checking phase Solution:
- Temporarily disable complex linters that require type checking
- Use
--fastflag for quicker, less intensive checks - Verify all imports are properly declared
CI/CD Optimization
For GitHub Actions workflow:
name: Code Quality
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
cache: true
- name: Download dependencies
run: go mod download
- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.1
- name: Lint
run: golangci-lint run --config .golangci.yml ./...
Linter Selection Guidelines
- gofmt: For formatting consistency
- govet: For semantic errors
- errcheck: For unchecked errors
- staticcheck: For static analysis
- unused: For dead code detection
- gosimple: For simplification suggestions
- ineffassign: For ineffective assignments
Choose linters based on project needs and CI performance requirements.
04 同仓库更多 Skills
crowd-prompting
A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.
dilemm-ai
Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).
arxiv-paper-reviews
Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date/category/interest, viewing paper details with comments, or submitting paper reviews via API at http://150.158.152.82:8000.
arxiv-paper-reviews
Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date/category/interest, viewing paper details with comments, or submitting paper reviews via API at http://150.158.152.82:8000.
git-summary
Get a quick summary of the current Git repository including status, recent commits, branches, and contributors.
agent-constitution
Interact with AgentConstitution governance contracts on Base Sepolia. Check compliance, read rules, log actions, query governance state.