From a34d0b9da624e0219b8114b3a49f68f748ab8631 Mon Sep 17 00:00:00 2001 From: Stefan Jenkner Date: Thu, 3 Oct 2024 22:43:39 +0200 Subject: [PATCH] refactor: add module prefix (#150) --- .golangci.yml | 12 +++++++++++- .idea/runConfigurations/app_help.xml | 12 ------------ .idea/runConfigurations/help.xml | 12 ++++++++++++ .idea/runConfigurations/test.xml | 12 ++++++++++++ .pre-commit-config.yaml | 2 +- cmd/{app => fdf-console-monitor}/main.go | 5 +++-- go.mod | 2 +- {internal => pkg}/events/dataevent.go | 0 {internal => pkg}/events/observer.go | 0 {internal => pkg}/events/statuschangeevent.go | 0 {internal => pkg}/fitnessmachine/fitnessmachine.go | 2 +- .../fitnessmachine/fitnessmachine_test.go | 2 +- {internal => pkg}/serialmonitor/capture.go | 0 {internal => pkg}/serialmonitor/parser.go | 0 {internal => pkg}/serialmonitor/parser_test.go | 0 {internal => pkg}/serialmonitor/serialmonitor.go | 2 +- .../serialmonitor/serialmonitor_test.go | 2 +- 17 files changed, 44 insertions(+), 21 deletions(-) delete mode 100644 .idea/runConfigurations/app_help.xml create mode 100644 .idea/runConfigurations/help.xml create mode 100644 .idea/runConfigurations/test.xml rename cmd/{app => fdf-console-monitor}/main.go (84%) rename {internal => pkg}/events/dataevent.go (100%) rename {internal => pkg}/events/observer.go (100%) rename {internal => pkg}/events/statuschangeevent.go (100%) rename {internal => pkg}/fitnessmachine/fitnessmachine.go (99%) rename {internal => pkg}/fitnessmachine/fitnessmachine_test.go (96%) rename {internal => pkg}/serialmonitor/capture.go (100%) rename {internal => pkg}/serialmonitor/parser.go (100%) rename {internal => pkg}/serialmonitor/parser_test.go (100%) rename {internal => pkg}/serialmonitor/serialmonitor.go (98%) rename {internal => pkg}/serialmonitor/serialmonitor_test.go (99%) diff --git a/.golangci.yml b/.golangci.yml index 0b20d25..2ce3d65 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -12,10 +12,20 @@ linters: # - complexity # - error # - format - # - import + - import # - metalinter # - module - performance # - style # - test - unused +linters-settings: + depguard: + rules: + main: + files: + - $all + allow: + - $gostd + - github.com/go-ble/ble + - github.com/stefanjenkner/fdf-console-monitor diff --git a/.idea/runConfigurations/app_help.xml b/.idea/runConfigurations/app_help.xml deleted file mode 100644 index a41fe18..0000000 --- a/.idea/runConfigurations/app_help.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/.idea/runConfigurations/help.xml b/.idea/runConfigurations/help.xml new file mode 100644 index 0000000..c585c2c --- /dev/null +++ b/.idea/runConfigurations/help.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/.idea/runConfigurations/test.xml b/.idea/runConfigurations/test.xml new file mode 100644 index 0000000..50fb7e3 --- /dev/null +++ b/.idea/runConfigurations/test.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a802e9b..715a27d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: - repo: https://github.com/golangci/golangci-lint rev: v1.61.0 hooks: - - id: golangci-lint + - id: golangci-lint-full - repo: https://github.com/DavidAnson/markdownlint-cli2 rev: v0.14.0 hooks: diff --git a/cmd/app/main.go b/cmd/fdf-console-monitor/main.go similarity index 84% rename from cmd/app/main.go rename to cmd/fdf-console-monitor/main.go index a9d49c5..8511e1e 100644 --- a/cmd/app/main.go +++ b/cmd/fdf-console-monitor/main.go @@ -1,13 +1,14 @@ package main import ( - "fdf-console-monitor/internal/fitnessmachine" - "fdf-console-monitor/internal/serialmonitor" "flag" "log" "os" "os/signal" "syscall" + + "github.com/stefanjenkner/fdf-console-monitor/pkg/fitnessmachine" + "github.com/stefanjenkner/fdf-console-monitor/pkg/serialmonitor" ) func main() { diff --git a/go.mod b/go.mod index 0bb3057..84eead4 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module fdf-console-monitor +module github.com/stefanjenkner/fdf-console-monitor go 1.23.1 diff --git a/internal/events/dataevent.go b/pkg/events/dataevent.go similarity index 100% rename from internal/events/dataevent.go rename to pkg/events/dataevent.go diff --git a/internal/events/observer.go b/pkg/events/observer.go similarity index 100% rename from internal/events/observer.go rename to pkg/events/observer.go diff --git a/internal/events/statuschangeevent.go b/pkg/events/statuschangeevent.go similarity index 100% rename from internal/events/statuschangeevent.go rename to pkg/events/statuschangeevent.go diff --git a/internal/fitnessmachine/fitnessmachine.go b/pkg/fitnessmachine/fitnessmachine.go similarity index 99% rename from internal/fitnessmachine/fitnessmachine.go rename to pkg/fitnessmachine/fitnessmachine.go index a4211b1..c7646ad 100644 --- a/internal/fitnessmachine/fitnessmachine.go +++ b/pkg/fitnessmachine/fitnessmachine.go @@ -6,9 +6,9 @@ import ( "log" "time" - "fdf-console-monitor/internal/events" "github.com/go-ble/ble" "github.com/go-ble/ble/examples/lib/dev" + "github.com/stefanjenkner/fdf-console-monitor/pkg/events" ) type FitnessMachine struct { diff --git a/internal/fitnessmachine/fitnessmachine_test.go b/pkg/fitnessmachine/fitnessmachine_test.go similarity index 96% rename from internal/fitnessmachine/fitnessmachine_test.go rename to pkg/fitnessmachine/fitnessmachine_test.go index c27da9d..135f43d 100644 --- a/internal/fitnessmachine/fitnessmachine_test.go +++ b/pkg/fitnessmachine/fitnessmachine_test.go @@ -3,12 +3,12 @@ package fitnessmachine import ( "bytes" "context" - "fdf-console-monitor/internal/events" "reflect" "testing" "time" "github.com/go-ble/ble" + "github.com/stefanjenkner/fdf-console-monitor/pkg/events" ) type NotifierMock struct { diff --git a/internal/serialmonitor/capture.go b/pkg/serialmonitor/capture.go similarity index 100% rename from internal/serialmonitor/capture.go rename to pkg/serialmonitor/capture.go diff --git a/internal/serialmonitor/parser.go b/pkg/serialmonitor/parser.go similarity index 100% rename from internal/serialmonitor/parser.go rename to pkg/serialmonitor/parser.go diff --git a/internal/serialmonitor/parser_test.go b/pkg/serialmonitor/parser_test.go similarity index 100% rename from internal/serialmonitor/parser_test.go rename to pkg/serialmonitor/parser_test.go diff --git a/internal/serialmonitor/serialmonitor.go b/pkg/serialmonitor/serialmonitor.go similarity index 98% rename from internal/serialmonitor/serialmonitor.go rename to pkg/serialmonitor/serialmonitor.go index 797443a..57f60d1 100644 --- a/internal/serialmonitor/serialmonitor.go +++ b/pkg/serialmonitor/serialmonitor.go @@ -2,11 +2,11 @@ package serialmonitor import ( "bufio" - "fdf-console-monitor/internal/events" "fmt" "log" "strings" + "github.com/stefanjenkner/fdf-console-monitor/pkg/events" "go.bug.st/serial" ) diff --git a/internal/serialmonitor/serialmonitor_test.go b/pkg/serialmonitor/serialmonitor_test.go similarity index 99% rename from internal/serialmonitor/serialmonitor_test.go rename to pkg/serialmonitor/serialmonitor_test.go index 4923ef4..611bc53 100644 --- a/internal/serialmonitor/serialmonitor_test.go +++ b/pkg/serialmonitor/serialmonitor_test.go @@ -2,11 +2,11 @@ package serialmonitor import ( "bytes" - "fdf-console-monitor/internal/events" "reflect" "testing" "time" + "github.com/stefanjenkner/fdf-console-monitor/pkg/events" "go.bug.st/serial" )