Skip to content

Commit 92a1262

Browse files
committed
fix: Update imports and fix type errors
- Replace aliases in imports for yaml and faker packages - Update deprecated io/ioutil to os package - Improve error handling by replacing panic with proper error returns - Add explicit dependency installation in GitHub Actions - Fix typecheck errors for undefined yaml and faker packages
1 parent 8c03ec7 commit 92a1262

File tree

6 files changed

+25
-11
lines changed

6 files changed

+25
-11
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ jobs:
3434
uses: actions/checkout@v4
3535

3636
- name: Install dependencies
37-
run: go mod download
37+
run: |
38+
go mod download
39+
go get github.com/goccy/go-yaml
40+
go get github.com/bxcodec/faker/v3
3841
3942
- name: Run linter
4043
run: |

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Formatting tasks
2+
fmt:
3+
go fmt ./...
4+
15
# Linting tasks
26
lint:
37
$(HOME)/go/bin/golangci-lint run --no-config --disable-all --enable=gofmt,govet,errcheck
@@ -27,4 +31,4 @@ install:
2731
clean:
2832
rm -rf bin/
2933

30-
.PHONY: lint test test-race test-cover build install clean
34+
.PHONY: fmt lint test test-race test-cover build install clean

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,13 @@ make test-race
251251
make test-cover
252252
```
253253

254+
### Formatting Code
255+
256+
```bash
257+
# Format all Go code
258+
make fmt
259+
```
260+
254261
### Running Linter
255262

256263
```bash

config/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package config
22

33
import (
4-
"io/ioutil"
4+
"os"
55

6-
"github.com/goccy/go-yaml"
6+
yaml "github.com/goccy/go-yaml"
77
)
88

99
type Config struct {
@@ -16,13 +16,13 @@ type Config struct {
1616
}
1717

1818
func ReadConfig() (*Config, error) {
19-
buf, err := ioutil.ReadFile("./config.yaml")
19+
buf, err := os.ReadFile("./config.yaml")
2020
if err != nil {
2121
return nil, err
2222
}
2323
var config Config
2424
if err := yaml.Unmarshal(buf, &config); err != nil {
25-
panic(err)
25+
return nil, err
2626
}
2727
return &config, nil
2828
}

config/config_linter.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package config
22

33
import (
4-
"io/ioutil"
4+
"os"
55

6-
"github.com/goccy/go-yaml"
6+
yaml "github.com/goccy/go-yaml"
77
"github.com/tkc/sql-dog/src/domain/model"
88
)
99

@@ -41,13 +41,13 @@ func (c *LintConfig) ConvertToValidators() (*model.Validator, error) {
4141
}
4242

4343
func ReadLintConfig(path string) (*model.Validator, error) {
44-
buf, err := ioutil.ReadFile(path)
44+
buf, err := os.ReadFile(path)
4545
if err != nil {
4646
return nil, err
4747
}
4848
var config LintConfig
4949
if err := yaml.Unmarshal(buf, &config); err != nil {
50-
panic(err)
50+
return nil, err
5151
}
5252
return config.ConvertToValidators()
5353
}

src/usecase/services/emulater_service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"strings"
1010
"time"
1111

12-
"github.com/bxcodec/faker/v3"
12+
faker "github.com/bxcodec/faker/v3"
1313
"github.com/tkc/sql-dog/src/domain/model"
1414
"github.com/tkc/sql-dog/src/infrastructure/datastore/mysql"
1515
"golang.org/x/sync/errgroup"

0 commit comments

Comments
 (0)