From 2e6c7a726232dbe357d4c47297d50c30a4f9bc88 Mon Sep 17 00:00:00 2001 From: Alexander Didenko Date: Thu, 20 Jun 2024 13:14:11 +0200 Subject: [PATCH] Fix some lint warning and optimize GH actions --- .github/workflows/build-binaries.yaml | 6 ++--- .../workflows/publish-release-binaries.yaml | 6 ++--- CHANGELOG.md | 8 +++++++ Makefile | 24 +++++++------------ main.go | 20 ++++++++-------- 5 files changed, 31 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build-binaries.yaml b/.github/workflows/build-binaries.yaml index d371889..2448c8f 100644 --- a/.github/workflows/build-binaries.yaml +++ b/.github/workflows/build-binaries.yaml @@ -8,10 +8,8 @@ jobs: matrix: go-version: ["1.22"] os: - - ubuntu-latest-amd64 - - ubuntu-latest-arm64 - - macos-latest-amd64 - - macos-latest-arm64 + - ubuntu-latest + - macos-latest - windows-latest runs-on: ${{ matrix.os }} diff --git a/.github/workflows/publish-release-binaries.yaml b/.github/workflows/publish-release-binaries.yaml index 99e2057..f267bbd 100644 --- a/.github/workflows/publish-release-binaries.yaml +++ b/.github/workflows/publish-release-binaries.yaml @@ -10,10 +10,8 @@ jobs: matrix: go-version: ["1.22"] os: - - ubuntu-latest-amd64 - - ubuntu-latest-arm64 - - macos-latest-amd64 - - macos-latest-arm64 + - ubuntu-latest + - macos-latest - windows-latest runs-on: ${{ matrix.os }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a680af..45fc5ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.6.0] - 2024-07-20 + +### Added + +- Support for HTTP2 +- Update to Go 1.22 +- Build GH actions to build arm64 binaries and multi-arch Docker images + ## [0.5.1] - 2023-11-06 ### Added diff --git a/Makefile b/Makefile index 18895c4..9186784 100644 --- a/Makefile +++ b/Makefile @@ -43,32 +43,26 @@ test: $(VENDOR_DIR) # Some Github targets -.PHONY: build-ubuntu-latest-amd64 +.PHONY: build-ubuntu-latest build-ubuntu-latest: $(VENDOR_DIR) $(OUTPUT_DIR) CGO_ENABLED=1 go build -a -ldflags '-extldflags "-static"' -o output/minigun . - cd output && tar czf minigun-linux-amd64.tar.gz minigun + tar czf output/minigun-linux-amd64.tar.gz output/minigun rm -f output/minigun - -.PHONY: build-macos-latest-amd64 -build-macos-latest: $(VENDOR_DIR) $(OUTPUT_DIR) - CGO_ENABLED=1 go build -a -ldflags '-extldflags "-static"' -o output/minigun . - cd output && tar czf minigun-darwin-amd64.tar.gz minigun - rm -f output/minigun - -.PHONY: build-ubuntu-latest-arm64 -build-ubuntu-latest: $(VENDOR_DIR) $(OUTPUT_DIR) GOARCH=arm64 CGO_ENABLED=1 go build -a -ldflags '-extldflags "-static"' -o output/minigun . - cd output && tar czf minigun-linux-arm64.tar.gz minigun + tar czf output/minigun-linux-arm64.tar.gz output/minigun rm -f output/minigun -.PHONY: build-macos-latest-arm64 +.PHONY: build-macos-latest build-macos-latest: $(VENDOR_DIR) $(OUTPUT_DIR) + CGO_ENABLED=1 go build -a -ldflags '-extldflags "-static"' -o output/minigun . + tar czf output/minigun-darwin-amd64.tar.gz output/minigun + rm -f output/minigun GOARCH=arm64 CGO_ENABLED=1 go build -a -ldflags '-extldflags "-static"' -o output/minigun . - cd output && tar czf minigun-darwin-arm64.tar.gz minigun + tar czf output/minigun-darwin-arm64.tar.gz output/minigun rm -f output/minigun .PHONY: build-windows-latest build-windows-latest: $(VENDOR_DIR) $(OUTPUT_DIR) CGO_ENABLED=1 go build -a -ldflags '-extldflags "-static"' -o output/minigun.exe . - cd output && tar czf minigun-win64.tar.gz minigun.exe + tar czf output/minigun-win64.tar.gz output/minigun.exe rm -f output/minigun.exe diff --git a/main.go b/main.go index 6dd1bd1..491638c 100644 --- a/main.go +++ b/main.go @@ -37,7 +37,7 @@ import ( ) // Constants and vars -const version = "0.5.2" +const version = "0.6.0" const workersCannelSize = 1024 const errorBadHTTPCode = "Bad HTTP status code" @@ -121,7 +121,7 @@ func (headers *httpHeaders) Set(value string) error { s := strings.Split(value, ":") if len(s) < 2 { - return fmt.Errorf("Wrong header argument") + return fmt.Errorf("wrong header argument") } if len(*headers) < 1 { @@ -177,7 +177,7 @@ func health(w http.ResponseWriter, r *http.Request) { healthy := true for id, status := range workerStatuses { - if status.Running != true { + if !status.Running { healthy = false applog.V(8).Infof("Worker %v is not running", id) } @@ -251,7 +251,7 @@ func initClient(config appConfig) (senderClient, error) { } default: - err = fmt.Errorf("Unsupported sendMode") + err = fmt.Errorf("unsupported sendMode") } return client, err @@ -267,7 +267,7 @@ func closeClient(config appConfig, client senderClient) error { case "socket": err = client.socketConn.Close() default: - err = fmt.Errorf("Unsupported sendMode") + err = fmt.Errorf("unsupported sendMode") } return err @@ -385,7 +385,7 @@ func sendDataHTTP(data []byte, config appConfig, client *http.Client) error { } // Send data via socket -func sendDataSocket(data []byte, config appConfig, writer *bufio.Writer) error { +func sendDataSocket(data []byte, writer *bufio.Writer) error { number, err := writer.Write(data) if err == nil { err = writer.Flush() @@ -404,10 +404,10 @@ func sendData(data []byte, config appConfig, client senderClient) error { return sendDataHTTP(data, config, client.httpClient) case "socket": - return sendDataSocket(data, config, client.socketWriter) + return sendDataSocket(data, client.socketWriter) default: - return fmt.Errorf("Unsupported send mode: %s", config.sendMode) + return fmt.Errorf("unsupported send mode: %s", config.sendMode) } } @@ -603,11 +603,11 @@ func validateUrl(inURL string) error { } if u.Scheme == "" { - return fmt.Errorf("Can't find scheme in URL %q", inURL) + return fmt.Errorf("can't find scheme in URL %q", inURL) } if u.Host == "" { - return fmt.Errorf("Can't find host in URL %q", inURL) + return fmt.Errorf("can't find host in URL %q", inURL) } return nil