Skip to content

Commit cb3ff42

Browse files
authored
golang generate (#1)
1 parent c31f477 commit cb3ff42

File tree

24 files changed

+1111
-18
lines changed

24 files changed

+1111
-18
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
version: 2
3+
updates:
4+
- package-ecosystem: "gomod" # See documentation for possible values
5+
directory: "/" # Location of package manifests
6+
schedule:
7+
interval: "weekly"

.github/workflows/ci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
name: CI
3+
4+
on:
5+
push:
6+
branches: [ master ]
7+
pull_request:
8+
branches: [ master ]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
go: [ '1.23.6' ]
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Setup Go
20+
uses: actions/setup-go@v3
21+
with:
22+
go-version: ${{ matrix.go }}
23+
24+
- name: Run CI
25+
env:
26+
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
27+
run: make ci

.gitignore

100644100755
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
# If you prefer the allow list template instead of the deny list, see community template:
2-
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3-
#
4-
# Binaries for programs and plugins
1+
.tools/
2+
bin/
3+
vendor/
4+
.idea/
5+
.vscode/
6+
coverage.txt
7+
coverage.out
58
*.exe
69
*.exe~
710
*.dll
811
*.so
912
*.dylib
10-
11-
# Test binary, built with `go test -c`
13+
*.db
14+
*.db-journal
15+
*.mmdb
1216
*.test
13-
14-
# Output of the go coverage tool, specifically when used with LiteIDE
1517
*.out
16-
17-
# Dependency directories (remove the comment below to include it)
18-
# vendor/
19-
20-
# Go workspace file
21-
go.work
22-
go.work.sum
23-
24-
# env file
2518
.env
19+
20+
build/

.golangci.yml

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
2+
run:
3+
go: "1.22"
4+
concurrency: 4
5+
timeout: 5m
6+
tests: false
7+
issues-exit-code: 1
8+
modules-download-mode: readonly
9+
10+
issues:
11+
exclude-use-default: false
12+
max-issues-per-linter: 100
13+
max-same-issues: 4
14+
new: false
15+
exclude-files:
16+
- ".+_test.go"
17+
exclude-dirs:
18+
- "vendor$"
19+
20+
output:
21+
formats:
22+
- format: line-number
23+
sort-results: true
24+
25+
linters-settings:
26+
govet:
27+
check-shadowing: true
28+
enable:
29+
- asmdecl
30+
- assign
31+
- atomic
32+
- atomicalign
33+
- bools
34+
- buildtag
35+
- cgocall
36+
- composites
37+
- copylocks
38+
- deepequalerrors
39+
- errorsas
40+
- findcall
41+
- framepointer
42+
- httpresponse
43+
- ifaceassert
44+
- loopclosure
45+
- lostcancel
46+
- nilfunc
47+
- nilness
48+
- printf
49+
- reflectvaluecompare
50+
- shadow
51+
- shift
52+
- sigchanyzer
53+
- sortslice
54+
- stdmethods
55+
- stringintconv
56+
- structtag
57+
- testinggoroutine
58+
- tests
59+
- unmarshal
60+
- unreachable
61+
- unsafeptr
62+
- unusedresult
63+
- unusedwrite
64+
disable:
65+
- fieldalignment
66+
gofmt:
67+
simplify: true
68+
errcheck:
69+
check-type-assertions: true
70+
check-blank: true
71+
gocyclo:
72+
min-complexity: 30
73+
misspell:
74+
locale: US
75+
prealloc:
76+
simple: true
77+
range-loops: true
78+
for-loops: true
79+
unparam:
80+
check-exported: false
81+
gci:
82+
skip-generated: true
83+
custom-order: false
84+
gosec:
85+
includes:
86+
- G101 # Look for hard coded credentials
87+
- G102 # Bind to all interfaces
88+
- G103 # Audit the use of unsafe block
89+
- G104 # Audit errors not checked
90+
- G106 # Audit the use of ssh.InsecureIgnoreHostKey
91+
- G107 # Url provided to HTTP request as taint input
92+
- G108 # Profiling endpoint automatically exposed on /debug/pprof
93+
- G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32
94+
- G110 # Potential DoS vulnerability via decompression bomb
95+
- G111 # Potential directory traversal
96+
- G112 # Potential slowloris attack
97+
- G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772)
98+
- G114 # Use of net/http serve function that has no support for setting timeouts
99+
- G201 # SQL query construction using format string
100+
- G202 # SQL query construction using string concatenation
101+
- G203 # Use of unescaped data in HTML templates
102+
- G204 # Audit use of command execution
103+
- G301 # Poor file permissions used when creating a directory
104+
- G302 # Poor file permissions used with chmod
105+
- G303 # Creating tempfile using a predictable path
106+
- G304 # File path provided as taint input
107+
- G305 # File traversal when extracting zip/tar archive
108+
- G306 # Poor file permissions used when writing to a new file
109+
- G307 # Deferring a method which returns an error
110+
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
111+
- G402 # Look for bad TLS connection settings
112+
- G403 # Ensure minimum RSA key length of 2048 bits
113+
- G404 # Insecure random number source (rand)
114+
- G501 # Import blocklist: crypto/md5
115+
- G502 # Import blocklist: crypto/des
116+
- G503 # Import blocklist: crypto/rc4
117+
- G504 # Import blocklist: net/http/cgi
118+
- G505 # Import blocklist: crypto/sha1
119+
- G601 # Implicit memory aliasing of items from a range statement
120+
excludes:
121+
- G101 # Look for hard coded credentials
122+
- G102 # Bind to all interfaces
123+
- G103 # Audit the use of unsafe block
124+
- G104 # Audit errors not checked
125+
- G106 # Audit the use of ssh.InsecureIgnoreHostKey
126+
- G107 # Url provided to HTTP request as taint input
127+
- G108 # Profiling endpoint automatically exposed on /debug/pprof
128+
- G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32
129+
- G110 # Potential DoS vulnerability via decompression bomb
130+
- G111 # Potential directory traversal
131+
- G112 # Potential slowloris attack
132+
- G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772)
133+
- G114 # Use of net/http serve function that has no support for setting timeouts
134+
- G201 # SQL query construction using format string
135+
- G202 # SQL query construction using string concatenation
136+
- G203 # Use of unescaped data in HTML templates
137+
- G204 # Audit use of command execution
138+
- G301 # Poor file permissions used when creating a directory
139+
- G302 # Poor file permissions used with chmod
140+
- G303 # Creating tempfile using a predictable path
141+
- G304 # File path provided as taint input
142+
- G305 # File traversal when extracting zip/tar archive
143+
- G306 # Poor file permissions used when writing to a new file
144+
- G307 # Deferring a method which returns an error
145+
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
146+
- G402 # Look for bad TLS connection settings
147+
- G403 # Ensure minimum RSA key length of 2048 bits
148+
- G404 # Insecure random number source (rand)
149+
- G501 # Import blocklist: crypto/md5
150+
- G502 # Import blocklist: crypto/des
151+
- G503 # Import blocklist: crypto/rc4
152+
- G504 # Import blocklist: net/http/cgi
153+
- G505 # Import blocklist: crypto/sha1
154+
- G601 # Implicit memory aliasing of items from a range statement
155+
exclude-generated: true
156+
severity: medium
157+
confidence: medium
158+
concurrency: 12
159+
config:
160+
global:
161+
nosec: true
162+
"#nosec": "#my-custom-nosec"
163+
show-ignored: true
164+
audit: true
165+
G101:
166+
pattern: "(?i)passwd|pass|password|pwd|secret|token|pw|apiKey|bearer|cred"
167+
ignore_entropy: false
168+
entropy_threshold: "80.0"
169+
per_char_threshold: "3.0"
170+
truncate: "32"
171+
G104:
172+
fmt:
173+
- Fscanf
174+
G111:
175+
pattern: "http\\.Dir\\(\"\\/\"\\)|http\\.Dir\\('\\/'\\)"
176+
G301: "0750"
177+
G302: "0600"
178+
G306: "0600"
179+
180+
lll:
181+
line-length: 130
182+
tab-width: 1
183+
staticcheck:
184+
go: "1.15"
185+
# SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
186+
# Default: ["*"]
187+
checks: [ "*", "-SA1019" ]
188+
189+
linters:
190+
disable-all: true
191+
enable:
192+
- govet
193+
- gofmt
194+
- errcheck
195+
- misspell
196+
- gocyclo
197+
- ineffassign
198+
- goimports
199+
- nakedret
200+
- unparam
201+
- unused
202+
- prealloc
203+
- durationcheck
204+
- staticcheck
205+
- makezero
206+
- nilerr
207+
- errorlint
208+
- bodyclose
209+
- gosec
210+
- lll
211+
fast: false

.lic.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
author: Mikhail Knyazhev <markus621@yandex.com>
2+
lic_short: "BSD 3-Clause"
3+
lic_file: LICENSE

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2025, The OSSPkg Team
3+
Copyright (c) 2025, Mikhail Knyazhev <markus621@yandex.com>
44

55
Redistribution and use in source and binary forms, with or without
66
modification, are permitted provided that the following conditions are met:

Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
SHELL=/bin/bash
3+
4+
5+
.PHONY: install
6+
install:
7+
go install go.osspkg.com/goppy/v2/cmd/goppy@latest
8+
goppy setup-lib
9+
10+
.PHONY: lint
11+
lint:
12+
goppy lint
13+
14+
.PHONY: license
15+
license:
16+
goppy license
17+
18+
.PHONY: build
19+
build:
20+
goppy build --arch=amd64
21+
22+
.PHONY: tests
23+
tests:
24+
goppy test
25+
26+
.PHONY: pre-commit
27+
pre-commit: install license lint tests build
28+
29+
.PHONY: ci
30+
ci: pre-commit
31+

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module go.osspkg.com/gogen
2+
3+
go 1.23.6

go.sum

Whitespace-only changes.

golang/config.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2025 Mikhail Knyazhev <markus621@yandex.com>. All rights reserved.
3+
* Use of this source code is governed by a BSD 3-Clause license that can be found in the LICENSE file.
4+
*/
5+
6+
package golang
7+
8+
import (
9+
config2 "go.osspkg.com/gogen/internal/config"
10+
)
11+
12+
var _ config2.Config = (*config)(nil)
13+
14+
type config struct{}
15+
16+
func (c config) OperationAvailable(op string) bool {
17+
switch op {
18+
case "+", "-", "*", "/", "%", "&", "|", "^", "<<", ">>", "&^", "+=", "-=", "*=", "/=", "%=",
19+
"&=", "|=", "^=", "<<=", ">>=", "&^=", "&&", "||", "<-", "++", "--", "==", "<", ">", "=", "!", "~", "!=",
20+
"<=", ">=", ":=", "...", "(", ")", "[", "]", "{", "}", ",", ".", ";", ":":
21+
return true
22+
default:
23+
return false
24+
}
25+
}
26+
27+
func (config) CommentSingle() config2.OpenClose {
28+
return config2.OpenClose{
29+
Open: "//",
30+
Close: "\n",
31+
}
32+
}
33+
34+
func (config) CommentMulti() config2.OpenClose {
35+
return config2.OpenClose{
36+
Open: "/*\n",
37+
Close: "\n*/\n",
38+
}
39+
}

0 commit comments

Comments
 (0)