diff --git a/.DS_Store b/.DS_Store index bd3b42c..22759d2 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b862fdb..63aca6e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,8 +3,23 @@ name: ci on: - push jobs: + lint: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: latest + args: --timeout=30m build: runs-on: ubuntu-latest + needs: + - lint steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..d383eb2 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,33 @@ +--- +linters: + disable-all: true + enable: + - govet + - staticcheck + - gocritic + - gosec + - gofmt + - goimports + - errcheck + - gosimple + - unused + - unconvert + - goconst + - gocyclo + - revive + +linters-settings: + wrapcheck: + ignoreSigs: + - .JSON + - .NewHTTPError + - .Redirect + - .NoContent + - .Errorf( + - errors.New( + - errors.Unwrap( + - .Wrap( + - .Wrapf( + - .WithMessage( + - .WithMessagef( + - .WithStack( \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..cc8d28f --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,15 @@ +--- +project_name: radio-music +builds: + - main: ./cmd/main.go + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 +release: + github: + owner: debug-ing + name: radio-music \ No newline at end of file diff --git a/config/config.go b/config/config.go index 5ca5c20..dcf1719 100644 --- a/config/config.go +++ b/config/config.go @@ -14,7 +14,6 @@ type Config struct { } } -var configPublic *Config var once sync.Once func LoadConfig(address string) (config *Config) { @@ -26,7 +25,6 @@ func LoadConfig(address string) (config *Config) { if err := viper.Unmarshal(&config); err != nil { panic("ERROR load config file!") } - configPublic = config log.Println("================ Loaded Configuration ================") }) return diff --git a/internal/client.go b/internal/client.go index 1eebc34..36c73c9 100644 --- a/internal/client.go +++ b/internal/client.go @@ -69,7 +69,7 @@ func (c *Client) GetClients() []chan []byte { } // HandleClient handles the client -func (c *Client) HandleClient(w http.ResponseWriter, r *http.Request) { +func (c *Client) HandleClient(w http.ResponseWriter, _ *http.Request) { client := c.AddClient() defer c.RemoveClient(client) w.Header().Set("Content-Type", "audio/mpeg") diff --git a/internal/stream.go b/internal/stream.go index ac872d8..5ae4f2e 100644 --- a/internal/stream.go +++ b/internal/stream.go @@ -2,7 +2,6 @@ package internal import ( "fmt" - "io/ioutil" "log" "os" "strings" @@ -27,7 +26,7 @@ var ( ) func getPlaylist(folderPath string) ([]string, error) { - files, err := ioutil.ReadDir(folderPath) + files, err := os.ReadDir(folderPath) if err != nil { return nil, err }