diff --git a/.golangci.yaml b/.golangci.yaml index 52ecb11..b575ea8 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -4,12 +4,13 @@ linters: - exportloopref # Deprecated - execinquery # Deprecated - gci - - gocritic - - gofumpt - forbidigo + - gocritic - godot - godox - gomnd + - gochecknoglobals + - gosec - ireturn - exhaustruct - mnd @@ -25,12 +26,10 @@ linters: - wsl - err113 - stylecheck - - gochecknoglobals - depguard - cyclop - whitespace - revive - - gosec - protogetter - funlen - unparam diff --git a/cmd/monitor/page_services.go b/cmd/monitor/page_services.go index 53d1be8..48b645f 100644 --- a/cmd/monitor/page_services.go +++ b/cmd/monitor/page_services.go @@ -62,7 +62,6 @@ func (m *model_services) navDown() { detailed.Id = id detailed.Refresh() m.subpage = subpage_services_detailed - } } diff --git a/cmd/monitor/page_topics_detailed.go b/cmd/monitor/page_topics_detailed.go index 60f955b..5e8c2d2 100644 --- a/cmd/monitor/page_topics_detailed.go +++ b/cmd/monitor/page_topics_detailed.go @@ -15,7 +15,6 @@ type model_topic_detailed struct { } func NewDetailedModel() *model_topic_detailed { - cols := []table.Column{ {Title: "", Width: 14}, {Title: "", Width: 67}, @@ -61,12 +60,14 @@ func (m *model_topic_detailed) updateDetailedTable(msg tea.Msg) { rows := []table.Row{ {"Datatype", fmt.Sprintf("(%s) %s", t.Datatype.Encoding, t.Datatype.Name)}, {"Unit", t.Unit_name}, - {"Messages", + { + "Messages", fmt.Sprintf("%v (%v dropped)", t.Data_clock, t.Message_drops), }, {"Frequency", strconv.FormatFloat(float64(t.Data_freq)/1000, 'f', -1, 32)}, {"Message Size", strconv.FormatInt(int64(t.Topic_size), 10)}, - {"Connections", + { + "Connections", fmt.Sprintf("%v local, %v external", t.Connections_local, t.Connections_external), }, {"Tick", strconv.FormatInt(int64(t.Registration_clock), 10)}, diff --git a/ecal/callback.go b/ecal/callback.go index 7149bed..ed8404d 100644 --- a/ecal/callback.go +++ b/ecal/callback.go @@ -2,6 +2,7 @@ package ecal //#include import "C" + import ( "runtime/cgo" ) diff --git a/ecal/core.go b/ecal/core.go index d4459de..21b1517 100644 --- a/ecal/core.go +++ b/ecal/core.go @@ -4,6 +4,7 @@ package ecal // #include "core.h" // #include import "C" + import ( "runtime/cgo" "unsafe" @@ -86,6 +87,7 @@ func SetUnitName(unit_name string) bool { defer C.free(unsafe.Pointer(unit_c)) return bool(C.SetUnitName(unit_c)) } + func Ok() bool { return bool(C.Ok()) } diff --git a/ecal/core_test.go b/ecal/core_test.go index ac3505b..ba309a0 100644 --- a/ecal/core_test.go +++ b/ecal/core_test.go @@ -26,7 +26,6 @@ func TestGetVersion(t *testing.T) { } func TestInitializeFinalize(t *testing.T) { - if IsInitialized() { t.Error("eCAL pre-initialized...") } diff --git a/ecal/logging/callback.go b/ecal/logging/callback.go index d7a860e..5e80c76 100644 --- a/ecal/logging/callback.go +++ b/ecal/logging/callback.go @@ -3,6 +3,7 @@ package logging //#include "logging.h" //#include "types.h" import "C" + import ( "runtime/cgo" "unsafe" diff --git a/ecal/logging/logging.go b/ecal/logging/logging.go index 98f1ecd..ac562e7 100644 --- a/ecal/logging/logging.go +++ b/ecal/logging/logging.go @@ -7,6 +7,7 @@ package logging // Log(level, _GoStringPtr(msg), _GoStringLen(msg)); // } import "C" + import ( "fmt" "runtime/cgo" diff --git a/ecal/monitoring/callback.go b/ecal/monitoring/callback.go index d6b9f30..d22cfe8 100644 --- a/ecal/monitoring/callback.go +++ b/ecal/monitoring/callback.go @@ -2,6 +2,7 @@ package monitoring //#include "monitoring.h" import "C" + import ( "runtime/cgo" "unsafe" diff --git a/ecal/monitoring/monitoring.go b/ecal/monitoring/monitoring.go index 9df2d61..4f98aae 100644 --- a/ecal/monitoring/monitoring.go +++ b/ecal/monitoring/monitoring.go @@ -5,6 +5,7 @@ package monitoring //#include "monitoring.h" //#cgo CPPFLAGS: -I${SRCDIR}/../types import "C" + import ( "runtime/cgo" "strconv" diff --git a/ecal/protobuf/publisher/protobuf_publisher_test.go b/ecal/protobuf/publisher/protobuf_publisher_test.go index c8f883a..dd1dbc1 100644 --- a/ecal/protobuf/publisher/protobuf_publisher_test.go +++ b/ecal/protobuf/publisher/protobuf_publisher_test.go @@ -15,7 +15,8 @@ func TestProtobufPublisher(t *testing.T) { t.Error("Message channel nil") } - person := &protos.Person{Id: 0, Name: "John", Email: "john@doe.net", + person := &protos.Person{ + Id: 0, Name: "John", Email: "john@doe.net", Dog: &protos.Dog{Name: "Pluto"}, House: &protos.House{Rooms: 5}, } diff --git a/ecal/protobuf/subscriber/protobuf_subscriber_test.go b/ecal/protobuf/subscriber/protobuf_subscriber_test.go index 4b34784..9c1f6bd 100644 --- a/ecal/protobuf/subscriber/protobuf_subscriber_test.go +++ b/ecal/protobuf/subscriber/protobuf_subscriber_test.go @@ -35,7 +35,6 @@ func TestSubscriber(t *testing.T) { go sendMessages(pub) for range 10 { msg, err := sub.Receive(2 * time.Second) - if err != nil { t.Error(err) } @@ -66,7 +65,8 @@ func TestSubscriberTimeout(t *testing.T) { } func sendMessages(p *publisher.Publisher[*protos.Person]) { - person := &protos.Person{Id: 0, Name: "John", Email: "john@doe.net", + person := &protos.Person{ + Id: 0, Name: "John", Email: "john@doe.net", Dog: &protos.Dog{Name: "Pluto"}, House: &protos.House{Rooms: 5}, } diff --git a/ecal/publisher/publisher.go b/ecal/publisher/publisher.go index ad37be0..6d56526 100644 --- a/ecal/publisher/publisher.go +++ b/ecal/publisher/publisher.go @@ -10,6 +10,7 @@ package publisher // const char* const descriptor, size_t descriptor_len //); import "C" + import ( "errors" "runtime/cgo" diff --git a/ecal/publisher/publisher_test.go b/ecal/publisher/publisher_test.go index d6751ed..63b21e5 100644 --- a/ecal/publisher/publisher_test.go +++ b/ecal/publisher/publisher_test.go @@ -23,5 +23,4 @@ func TestPublisher(t *testing.T) { if pub.Messages == nil { t.Error("Message channel nil") } - } diff --git a/ecal/registration/registration.go b/ecal/registration/registration.go index 1e6f3e5..6a3381f 100644 --- a/ecal/registration/registration.go +++ b/ecal/registration/registration.go @@ -5,6 +5,7 @@ package registration //#include "types.h" // #cgo CPPFLAGS: -I${SRCDIR}/../types import "C" + import ( "runtime/cgo" @@ -20,8 +21,10 @@ const ( type QualityFlags uint8 -type EntityId = types.EntityId -type TopicId = types.TopicId +type ( + EntityId = types.EntityId + TopicId = types.TopicId +) type CallbackToken struct { ecal_token uint diff --git a/ecal/subscriber/subscriber.go b/ecal/subscriber/subscriber.go index 32f877d..a1517da 100644 --- a/ecal/subscriber/subscriber.go +++ b/ecal/subscriber/subscriber.go @@ -10,6 +10,7 @@ package subscriber // const char* const descriptor, size_t descriptor_len // ); import "C" + import ( "errors" "runtime/cgo" diff --git a/internal/ecaltest/protobuf/testutil_publisher/testutil_protobuf_publisher.go b/internal/ecaltest/protobuf/testutil_publisher/testutil_protobuf_publisher.go index 0f0c0d3..3aee3ab 100644 --- a/internal/ecaltest/protobuf/testutil_publisher/testutil_protobuf_publisher.go +++ b/internal/ecaltest/protobuf/testutil_publisher/testutil_protobuf_publisher.go @@ -8,7 +8,6 @@ import ( func NewProtobufPublisher[U any, T publisher.Msg[U]](t *testing.T, topic string) *publisher.Publisher[T] { pub, err := publisher.New[U, T]() - if err != nil { t.Error(err) } diff --git a/internal/ecaltest/string/testutil_publisher/testutil_string_publisher.go b/internal/ecaltest/string/testutil_publisher/testutil_string_publisher.go index e7946b8..abe6dac 100644 --- a/internal/ecaltest/string/testutil_publisher/testutil_string_publisher.go +++ b/internal/ecaltest/string/testutil_publisher/testutil_string_publisher.go @@ -8,7 +8,6 @@ import ( func NewStringPublisher(t *testing.T, topic string) *publisher.Publisher { pub, err := publisher.New() - if err != nil { t.Error(err) } diff --git a/main.go b/main.go index 2bebaa5..73db213 100644 --- a/main.go +++ b/main.go @@ -51,7 +51,8 @@ func main() { } defer pub.Delete() // Don't forget to delete the publisher when done! - person := &protos.Person{Id: 0, Name: "John", Email: "john@doe.net", + person := &protos.Person{ + Id: 0, Name: "John", Email: "john@doe.net", Dog: &protos.Dog{Name: "Pluto"}, House: &protos.House{Rooms: 5}, }