Skip to content

Commit

Permalink
chore: template
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Dec 10, 2024
1 parent ef31ebd commit 01cc606
Show file tree
Hide file tree
Showing 32 changed files with 213 additions and 1,276 deletions.
46 changes: 46 additions & 0 deletions .air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = []
bin = "scc"
cmd = "make build"
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata", "ui"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = false

[screen]
clear_on_rebuild = false
keep_scroll = true
8 changes: 8 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

echo "Backend linting"
golangci-lint run
if [ $? -ne 0 ]; then
echo "golangci-lint failed. Please fix the errors before committing."
exit 1
fi
28 changes: 0 additions & 28 deletions .github/workflows/go.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: golangci-lint

on:
push:
branches:
- main
pull_request:

permissions:
contents: read
pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.23.1

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
12 changes: 12 additions & 0 deletions .github/workflows/sqlc-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: sqlc
on: [push]

jobs:
diff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: sqlc-dev/setup-sqlc@v3
with:
sqlc-version: '1.26.0'
- run: sqlc diff
22 changes: 13 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
# Test binary, built with "go test -c"
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
Expand All @@ -19,12 +16,19 @@

# Go workspace file
go.work
tmp/

tmp.go
# IDE specific files
.vscode
.idea

config.yaml
# .env file
.env
.env.*
!.env.example

# Binary
# Project build
scc
# Log file
scc.log

.data/
/public/
35 changes: 35 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
run:
timeout: 5m
modules-download-mode: readonly

linters:
enable:
- bodyclose # checks whether HTTP response body is closed successfully
- copyloopvar # detects copy loop variable
- errcheck # checks for unchecked errors in go programs
- errname # checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`
- gochecknoinits # checks that no init functions are present in Go code
- goimports # check import statements are formatted correctly
- gosimple # checks for code simplifications in Go code
- govet # runs the go vet tool
- importas # enforces consistent import aliases
- ineffassign # detects when assignments to existing variables are not used
- noctx # finds sending http request without context.Context
- paralleltest # detects missing usage of t.Parallel() method in go tests
- prealloc # finds slice declarations that could potentially be preallocated
- revive # checks for golang coding style
- rowserrcheck # checks whether Err of rows is checked successfully
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
- staticcheck # Applies static code analysis
- tenv # detects using os.Setenv instead of t.Setenv
- testpackage # makes you use a separate _test package
- thelper # detects golang test helpers without t.Helper() call and checks consistency of test helpers
- unconvert # removes unnecessary type conversions
- unparam # removes unused function parameters
- unused # finds unused variables
fast: true

issues:
exclude-use-default: false
max-issues-per-linter: 0
max-same-issues: 0
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
golang 1.22.0
golang 1.23.1
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
# Screen Cammie Chat

Go 1.22.0
Displays the cammie chat along with some other statistics.

- `go mod tidy`
## Development

- `go run .` of `go build .`
Check [.tool-versions](.tool-versions) for the current used version of golang

- Install pre-commit hooks `git config --local core.hooksPath .githooks/`.
- Install goose `go install github.com/pressly/goose/v3/cmd/goose@latest`.
- Install sqlc `go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest`
- Install air `go install github.com/air-verse/air@latest`

## Build

- `make`

## Run

- `make run`
41 changes: 0 additions & 41 deletions api/api.go

This file was deleted.

84 changes: 0 additions & 84 deletions api/cammie.go

This file was deleted.

Loading

0 comments on commit 01cc606

Please sign in to comment.