Skip to content

Commit 90018a4

Browse files
committed
fixes
1 parent 9715e2d commit 90018a4

5 files changed

Lines changed: 40 additions & 27 deletions

File tree

.golangci.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ run:
66
timeout: 5m
77
issues-exit-code: 1
88
tests: true
9-
skip-dirs:
10-
- vendor
11-
- testdata
12-
- examples
13-
skip-files:
14-
- ".*_test.go"
159

1610
output:
17-
format: colored-line-number
11+
formats:
12+
- format: colored-line-number
1813
print-issued-lines: true
1914
print-linter-name: true
2015
unique-by-line: true
@@ -27,7 +22,7 @@ linters:
2722
- dupl
2823
- errcheck
2924
- exhaustive
30-
- exportloopref
25+
- copyloopvar
3126
- gci
3227
- gochecknoinits
3328
- gocognit
@@ -57,17 +52,12 @@ linters:
5752
- whitespace
5853

5954
disable:
60-
- deadcode
6155
- exhaustruct
6256
- funlen
6357
- gochecknoglobals
6458
- godox
65-
- gomnd
6659
- lll
6760
- nlreturn
68-
- scopelint
69-
- structcheck
70-
- varcheck
7161
- wsl
7262

7363
linters-settings:
@@ -119,7 +109,6 @@ linters-settings:
119109
confidence: medium
120110

121111
govet:
122-
check-shadowing: true
123112
enable-all: true
124113

125114
misspell:
@@ -157,7 +146,6 @@ linters-settings:
157146
- name: errorf
158147

159148
stylecheck:
160-
go: "1.23"
161149
checks: ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022"]
162150
dot-import-whitelist:
163151
- fmt
@@ -170,7 +158,16 @@ linters-settings:
170158
check-exported: false
171159

172160
issues:
161+
exclude-dirs:
162+
- vendor
163+
- testdata
164+
- examples
165+
exclude-files:
166+
- ".*_test.go"
173167
exclude-rules:
168+
- path: sharedlib/
169+
linters:
170+
- gci
174171
- path: _test\.go
175172
linters:
176173
- gocyclo

cmd/example/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package main implements the example CLI application.
12
package main
23

34
import (
@@ -8,8 +9,11 @@ import (
89
)
910

1011
var (
11-
Version = "dev"
12+
// Version is the application version.
13+
Version = "dev"
14+
// GitCommit is the git commit hash.
1215
GitCommit = "unknown"
16+
// BuildDate is the build date.
1317
BuildDate = "unknown"
1418
)
1519

@@ -51,4 +55,4 @@ func printVersion() {
5155
fmt.Printf("Version: %s\n", Version)
5256
fmt.Printf("Git Commit: %s\n", GitCommit)
5357
fmt.Printf("Build Date: %s\n", BuildDate)
54-
}
58+
}

internal/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ func String() string {
4747
info.GoVersion,
4848
info.Platform,
4949
)
50-
}
50+
}

pkg/example/example.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ func (c *Client) Process(input string) (string, error) {
5050
}
5151

5252
result := fmt.Sprintf("Processed by %s: %s", c.config.Name, input)
53-
53+
5454
if c.config.Verbose {
5555
fmt.Printf("[DEBUG] %s\n", result)
5656
}
5757

5858
return result, nil
59-
}
59+
}

sharedlib/sharedlib.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
// Package main provides a shared library for signing and verification.
12
package main
23

34
// #include <stdlib.h>
45
import "C"
6+
57
import (
68
"crypto/sha256"
79
"encoding/hex"
@@ -10,52 +12,62 @@ import (
1012
"unsafe"
1113
)
1214

15+
// GetVersion returns the version string.
16+
//
1317
//export GetVersion
1418
func GetVersion() *C.char {
1519
return C.CString("1.0.0")
1620
}
1721

22+
// GetPlatform returns the platform string.
23+
//
1824
//export GetPlatform
1925
func GetPlatform() *C.char {
2026
return C.CString(fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH))
2127
}
2228

29+
// Sign creates a signature for the given data.
30+
//
2331
//export Sign
2432
func Sign(data *C.char) *C.char {
2533
if data == nil {
2634
return C.CString("")
2735
}
28-
36+
2937
goData := C.GoString(data)
3038
hash := sha256.Sum256([]byte(goData))
3139
signature := hex.EncodeToString(hash[:])
32-
40+
3341
return C.CString(signature)
3442
}
3543

44+
// Verify checks if the signature matches the data.
45+
//
3646
//export Verify
37-
func Verify(data *C.char, signature *C.char) C.int {
47+
func Verify(data, signature *C.char) C.int {
3848
if data == nil || signature == nil {
3949
return 0
4050
}
41-
51+
4252
goData := C.GoString(data)
4353
goSignature := C.GoString(signature)
44-
54+
4555
hash := sha256.Sum256([]byte(goData))
4656
expectedSignature := hex.EncodeToString(hash[:])
47-
57+
4858
if expectedSignature == goSignature {
4959
return 1
5060
}
5161
return 0
5262
}
5363

64+
// FreeString frees a C string allocated by the library.
65+
//
5466
//export FreeString
5567
func FreeString(str *C.char) {
5668
C.free(unsafe.Pointer(str))
5769
}
5870

5971
func main() {
6072
// Required for building shared library
61-
}
73+
}

0 commit comments

Comments
 (0)