Skip to content

Commit 98d9cb7

Browse files
committed
Merge main branch and restore user's linter config
2 parents 712e16e + b76d146 commit 98d9cb7

8 files changed

Lines changed: 32 additions & 18 deletions

File tree

.github/workflows/cicd.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
steps:
2222
- name: Checkout code into go module directory
23-
uses: actions/checkout@v4
23+
uses: actions/checkout@v6
2424
with:
2525
fetch-depth: 0
2626

@@ -48,21 +48,21 @@ jobs:
4848
echo $codeCoverage:
4949
5050
code_quality:
51-
name: 🎖Code Quality️
51+
name: 🎖 Code Quality
5252
runs-on: ubuntu-latest
5353
steps:
5454
- name: Checkout code
55-
uses: actions/checkout@v4
55+
uses: actions/checkout@v6
5656

5757
- name: Set up Go 1.22
5858
uses: actions/setup-go@v5
5959
with:
6060
go-version: 1.22
6161

6262
- name: Install golangci-lint
63-
uses: golangci/golangci-lint-action@v6
63+
uses: golangci/golangci-lint-action@v9
6464
with:
65-
version: v1.59.1
65+
version: v2.4.0
6666
args: --timeout=9m --verbose
6767
env:
6868
GOFLAGS: "-buildvcs=false" # Fix Go 1.22 VCS warnings

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,4 @@ issues:
150150
linters:
151151
- gomnd
152152
- dupl
153-
- goconst
153+
- goconst

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99

1010
<div align="center">
11+
<a href="https://pkg.go.dev/gofr.dev/cli/gofr"><img src="https://img.shields.io/badge/GoDoc-Read%20Documentation-blue?style=for-the-badge" alt="godoc"></a>
12+
<a href="https://gofr.dev/docs/references/gofrcli"><img src="https://img.shields.io/badge/GoFr-Docs-orange?style=for-the-badge" alt="gofr-docs"></a>
1113
<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache_2.0-blue?style=for-the-badge" alt="Apache 2.0 License"></a>
1214
<a href="https://discord.gg/wsaSkQTdgq"><img src="https://img.shields.io/badge/discord-join-us?style=for-the-badge&logo=discord&color=7289DA" alt="discord" /></a>
1315
</div>
@@ -69,4 +71,4 @@ If your PR is merged, or if you contribute by writing articles or promoting GoFr
6971

7072
### Partners
7173

72-
<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.png" alt="JetBrains logo" width="200">
74+
<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.png" alt="JetBrains logo" width="200">

bootstrap/init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
func main() {
2525
app := gofr.New()
2626
27-
app.GET("/hello", func(ctx *gofr.Context) (interface{}, error) {
27+
app.GET("/hello", func(ctx *gofr.Context) (any, error) {
2828
return "Hello World!", nil
2929
})
3030
@@ -39,7 +39,7 @@ type modInfo struct {
3939
GofrVersion string
4040
}
4141

42-
func Create(ctx *gofr.Context) (interface{}, error) {
42+
func Create(ctx *gofr.Context) (any, error) {
4343
name := ctx.Param("name")
4444
gofrVersion := ctx.Param("gofr")
4545

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func main() {
1414
cli.SubCommand("init", bootstrap.Create)
1515

1616
cli.SubCommand("version",
17-
func(*gofr.Context) (interface{}, error) {
17+
func(*gofr.Context) (any, error) {
1818
return CLIVersion, nil
1919
},
2020
)

main_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"testing"
66

77
"github.com/stretchr/testify/assert"
8-
98
"gofr.dev/pkg/gofr/testutil"
109
)
1110

migration/migrate.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ func createMigrationFile(ctx *gofr.Context, migrationName string) error {
100100
return err
101101
}
102102

103-
defer func() { _ = file.Close() }()
103+
defer func() {
104+
_ = file.Close()
105+
}()
104106

105107
err = migrationTemplate.Execute(file, migrationName)
106108
if err != nil {
@@ -123,7 +125,9 @@ func createAllMigration(ctx *gofr.Context) error {
123125
return err
124126
}
125127

126-
defer func() { _ = f.Close() }()
128+
defer func() {
129+
_ = f.Close()
130+
}()
127131

128132
d, err := os.ReadDir("./")
129133
if err != nil {
@@ -154,7 +158,9 @@ func getAllExistingMigrations(ctx *gofr.Context, existing map[string]string) (ma
154158
return nil, err
155159
}
156160

157-
defer func() { _ = file.Close() }()
161+
defer func() {
162+
_ = file.Close()
163+
}()
158164

159165
scanner := bufio.NewScanner(file)
160166
for scanner.Scan() {

wrap/grpc.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var (
3333

3434
// googleProtobufType returns the Go package type for a given Google Protobuf type.
3535
//
36-
//nolint:gocyclo // This function uses a large switch statement for type mapping, which is expected.
36+
//nolint:gocyclo,funlen // This function uses a large switch statement for type mapping, which is expected.
3737
func googleProtobufType(tpe string) (string, bool) {
3838
switch tpe {
3939
case "google.protobuf.Any":
@@ -146,6 +146,7 @@ func googleProtobufType(tpe string) (string, bool) {
146146
return "", false
147147
}
148148
}
149+
149150
// ServiceMethod represents a method in a proto service.
150151
type ServiceMethod struct {
151152
Name string
@@ -212,8 +213,8 @@ func generateWrapper(ctx *gofr.Context, options ...FileType) (interface{}, error
212213
protoPath := ctx.Param("proto")
213214
if protoPath == "" {
214215
ctx.Error(ErrNoProtoFile)
215-
return nil, ErrNoProtoFile
216-
}
216+
return nil, ErrNoProtoFile
217+
}
217218

218219
definition, err := parseProtoFile(ctx, protoPath)
219220
if err != nil {
@@ -253,9 +254,11 @@ func parseProtoFile(ctx *gofr.Context, protoPath string) (*proto.Proto, error) {
253254
ctx.Errorf("Failed to open proto file: %v", err)
254255
return nil, ErrOpeningProtoFile
255256
}
256-
parser := proto.NewParser(file)
257+
257258
defer func() { _ = file.Close() }()
258259

260+
parser := proto.NewParser(file)
261+
259262
definition, err := parser.Parse()
260263
if err != nil {
261264
ctx.Errorf("Failed to parse proto file: %v", err)
@@ -400,6 +403,7 @@ func generateGoFrClient(ctx *gofr.Context, data *WrapperData) string {
400403
// getPackageAndProject extracts the package name and project path from the proto definition.
401404
func getPackageAndProject(ctx *gofr.Context, definition *proto.Proto, protoPath string) (projectPath, packageName string) {
402405
const goPackage = "go_package"
406+
403407
proto.Walk(definition,
404408
proto.WithOption(func(opt *proto.Option) {
405409
if opt.Name == goPackage {
@@ -444,6 +448,7 @@ func getImports(ctx *gofr.Context, definition *proto.Proto, protoPath string) []
444448
imports = append(imports, googleImport)
445449
} else {
446450
lastIndex := strings.LastIndex(protoPath, "/")
451+
447452
newProto, err := parseProtoFile(ctx, protoPath[:lastIndex+1]+imported.Filename)
448453
if err != nil {
449454
ctx.Errorf("Failed to parse imported proto file %s: %v", imported.Filename, err)
@@ -513,10 +518,12 @@ func getProperType(tpe string) string {
513518
} else if strings.Contains(tpe, ".") {
514519
lastIndex := strings.LastIndex(tpe, ".")
515520
submoduleIndex := strings.LastIndex(tpe[:lastIndex], ".")
521+
516522
if submoduleIndex != -1 {
517523
return fmt.Sprintf("%s.%s", tpe[submoduleIndex+1:lastIndex], tpe[lastIndex+1:])
518524
}
519525
}
526+
520527
return tpe
521528
}
522529

0 commit comments

Comments
 (0)