You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2026/08/25 13:43:09 UTC

(plc4x) 01/02: build(plc4go): take uuid from the standard library

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit d2155be6b0d2a750318668e45317764b06ae5309
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Tue Aug 25 15:26:09 2026 +0200

    build(plc4go): take uuid from the standard library
    
    Go 1.27 ships a uuid package, and plc4go was the only module in its own
    dependency graph that required github.com/google/uuid — verified with
    go mod graph — so the switch drops the dependency outright rather than
    merely moving it. It is gone from both go.mod and go.sum.
    
    The cost is the floor: the stdlib package only exists in 1.27, so the go
    directive moves with it and every plc4go consumer now needs 1.27, which
    released 2026-08-18. Anyone pinning GOTOOLCHAIN=local on 1.26 will no
    longer build; everyone else downloads it automatically. The Maven
    go.version property and the generator's module template move too, so the
    toolchain the build fetches matches what the module asks for.
    
    Three call sites needed more than a changed import, because the stdlib
    API is not a superset of google/uuid's:
    
    - NewString() does not exist. Replaced with New().String(), which is
      what google/uuid's NewString does internally.
    - UUID has no MarshalBinary(). It is [16]byte, so the OPC-UA GUID node
      id now slices it directly. The bytes are identical to what
      MarshalBinary returned, and the error branch it forced is gone since
      slicing cannot fail. The open question in the comment there about
      whether the GUID needs byte-flipping is untouched.
    - NewUUID() does not exist; the stdlib offers no version 1. Subscription
      handles now use NewV7, which keeps the time ordering that version 1
      provided while dropping the MAC address from the identifier. This is a
      behaviour change, though the value is only ever used as an opaque
      handle id and the version 1 error return was already discarded.
    
    Verified on 1.27.0: gofmt clean, go build and go vet clean across the
    module (vet's pre-existing ReadByte/WriteByte signature and shift
    warnings in generated code are unchanged), and the tests for all four
    affected packages pass.
---
 code-generation/language/go/src/test/resources/plc4go/go.mod | 4 ++--
 plc4go/go.mod                                                | 5 ++---
 plc4go/go.sum                                                | 2 --
 plc4go/internal/opcua/common.go                              | 7 ++-----
 plc4go/pom.xml                                               | 2 +-
 plc4go/spi/default/DefaultCodec.go                           | 6 +++---
 plc4go/spi/default/DefaultCodec_test.go                      | 2 +-
 plc4go/spi/default/defaultExpectation.go                     | 3 +--
 plc4go/spi/model/DefaultPlcSubscriptionHandle.go             | 5 ++---
 plc4go/spi/utils/IdGenerator.go                              | 5 ++---
 10 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/code-generation/language/go/src/test/resources/plc4go/go.mod b/code-generation/language/go/src/test/resources/plc4go/go.mod
index 8900a7b3e6..7397d4efa7 100644
--- a/code-generation/language/go/src/test/resources/plc4go/go.mod
+++ b/code-generation/language/go/src/test/resources/plc4go/go.mod
@@ -19,9 +19,9 @@
 
 module github.com/apache/plc4x/plc4go
 
-go 1.26
+go 1.27
 
-toolchain go1.26.3
+toolchain go1.27.0
 
 require (
 	github.com/ajankovic/xdiff v0.0.1
diff --git a/plc4go/go.mod b/plc4go/go.mod
index 3617c1f805..2b63300fe4 100644
--- a/plc4go/go.mod
+++ b/plc4go/go.mod
@@ -19,14 +19,13 @@
 
 module github.com/apache/plc4x/plc4go
 
-go 1.26
+go 1.27
 
-toolchain go1.26.3
+toolchain go1.27.0
 
 require (
 	github.com/ajankovic/xdiff v0.0.1
 	github.com/fatih/color v1.19.0
-	github.com/google/uuid v1.6.0
 	github.com/gopacket/gopacket v1.7.1
 	github.com/rs/zerolog v1.35.1
 	github.com/stretchr/testify v1.12.1
diff --git a/plc4go/go.sum b/plc4go/go.sum
index 296409e3ce..246d335484 100644
--- a/plc4go/go.sum
+++ b/plc4go/go.sum
@@ -4,8 +4,6 @@ github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w=
 github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE=
 github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
 github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
-github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
-github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/gopacket/gopacket v1.7.1 h1:1C7/wrJ5HyiEAYDtStJHQk4rV0ChpanZDV9+3Ov3gaM=
 github.com/gopacket/gopacket v1.7.1/go.mod h1:QKowPlTLrQU2rqV5C5I14Aoaid3l8da3kbddibc/Wgk=
 github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy0/jY=
diff --git a/plc4go/internal/opcua/common.go b/plc4go/internal/opcua/common.go
index fa7b25c805..dc3d924766 100644
--- a/plc4go/internal/opcua/common.go
+++ b/plc4go/internal/opcua/common.go
@@ -23,8 +23,8 @@ import (
 	"fmt"
 	"strconv"
 	"time"
+	"uuid"
 
-	"github.com/google/uuid"
 	"github.com/rs/zerolog"
 
 	apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
@@ -53,10 +53,7 @@ func generateNodeId(tag Tag) (readWriteModel.NodeId, error) {
 		if err != nil {
 			return nil, errors.Wrap(err, "error parsing guid")
 		}
-		guidBytes, err := guid.MarshalBinary() // TODO: do we need to do flip it here?
-		if err != nil {
-			return nil, errors.Wrap(err, "error marshaling guid")
-		}
+		guidBytes := guid[:] // TODO: do we need to do flip it here?
 		nodeId = readWriteModel.NewNodeId(readWriteModel.NewNodeIdGuid( /*TODO: do we want to check for overflow?*/ uint16(tag.GetNamespace()), guidBytes))
 	} else if tag.GetIdentifierType() == readWriteModel.OpcuaIdentifierType_STRING_IDENTIFIER {
 		nodeId = readWriteModel.NewNodeId(readWriteModel.NewNodeIdString( /*TODO: do we want to check for overflow?*/ uint16(tag.GetNamespace()), readWriteModel.NewPascalString(new(tag.GetIdentifier()))))
diff --git a/plc4go/pom.xml b/plc4go/pom.xml
index 88b5f94f13..212524c814 100644
--- a/plc4go/pom.xml
+++ b/plc4go/pom.xml
@@ -49,7 +49,7 @@
 
     <go.cover.flag>-coverprofile=target/coverage.out</go.cover.flag>
 
-    <go.version>1.26.0</go.version>
+    <go.version>1.27.0</go.version>
   </properties>
 
   <build>
diff --git a/plc4go/spi/default/DefaultCodec.go b/plc4go/spi/default/DefaultCodec.go
index cc76fbbff8..edc07b4b52 100644
--- a/plc4go/spi/default/DefaultCodec.go
+++ b/plc4go/spi/default/DefaultCodec.go
@@ -26,8 +26,8 @@ import (
 	"sync"
 	"sync/atomic"
 	"time"
+	"uuid"
 
-	"github.com/google/uuid"
 	"github.com/rs/zerolog"
 
 	"github.com/apache/plc4x/plc4go/pkg/api/config"
@@ -382,7 +382,7 @@ func (m *defaultCodec) ExpireWork() {
 	if !m.traceDefaultMessageCodecWorker {
 		workerLog = zerolog.Nop()
 	}
-	workerLog = workerLog.With().Str("workerId", uuid.NewString()).Logger()
+	workerLog = workerLog.With().Str("workerId", uuid.New().String()).Logger()
 	workerLog.Trace().Msg("Starting expire work")
 	defer workerLog.Trace().Msg("expire work ended")
 
@@ -448,7 +448,7 @@ func (m *defaultCodec) ReceiveWork() {
 	if !m.traceDefaultMessageCodecWorker {
 		workerLog = zerolog.Nop()
 	}
-	workerLog = workerLog.With().Str("workerId", uuid.NewString()).Logger()
+	workerLog = workerLog.With().Str("workerId", uuid.New().String()).Logger()
 	workerLog.Trace().Msg("Starting work")
 	defer workerLog.Trace().Msg("work ended")
 
diff --git a/plc4go/spi/default/DefaultCodec_test.go b/plc4go/spi/default/DefaultCodec_test.go
index 43f5471d2a..cf6e3fcb48 100644
--- a/plc4go/spi/default/DefaultCodec_test.go
+++ b/plc4go/spi/default/DefaultCodec_test.go
@@ -25,8 +25,8 @@ import (
 	"sync/atomic"
 	"testing"
 	"time"
+	"uuid"
 
-	"github.com/google/uuid"
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/mock"
 	"github.com/stretchr/testify/require"
diff --git a/plc4go/spi/default/defaultExpectation.go b/plc4go/spi/default/defaultExpectation.go
index fa1e0a3bd3..c8ce8517ec 100644
--- a/plc4go/spi/default/defaultExpectation.go
+++ b/plc4go/spi/default/defaultExpectation.go
@@ -23,8 +23,7 @@ import (
 	"context"
 	"fmt"
 	"time"
-
-	"github.com/google/uuid"
+	"uuid"
 
 	"github.com/apache/plc4x/plc4go/spi"
 )
diff --git a/plc4go/spi/model/DefaultPlcSubscriptionHandle.go b/plc4go/spi/model/DefaultPlcSubscriptionHandle.go
index 4436ba079b..61c2650ba6 100644
--- a/plc4go/spi/model/DefaultPlcSubscriptionHandle.go
+++ b/plc4go/spi/model/DefaultPlcSubscriptionHandle.go
@@ -20,7 +20,7 @@
 package model
 
 import (
-	"github.com/google/uuid"
+	"uuid"
 
 	apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
 	"github.com/apache/plc4x/plc4go/spi"
@@ -35,9 +35,8 @@ type DefaultPlcSubscriptionHandle struct {
 
 // NewDefaultPlcSubscriptionHandle can be used when the DefaultPlcSubscriptionHandle is sufficient
 func NewDefaultPlcSubscriptionHandle(plcSubscriber spi.PlcSubscriber) apiModel.PlcSubscriptionHandle {
-	uuid, _ := uuid.NewUUID()
 	handle := &DefaultPlcSubscriptionHandle{
-		uuid:          uuid,
+		uuid:          uuid.NewV7(),
 		plcSubscriber: plcSubscriber,
 	}
 	handle.handleToRegister = handle
diff --git a/plc4go/spi/utils/IdGenerator.go b/plc4go/spi/utils/IdGenerator.go
index 8c7f4a887e..c9dea626cd 100644
--- a/plc4go/spi/utils/IdGenerator.go
+++ b/plc4go/spi/utils/IdGenerator.go
@@ -22,8 +22,7 @@ package utils
 import (
 	"crypto/rand"
 	"encoding/hex"
-
-	"github.com/google/uuid"
+	"uuid"
 )
 
 var randomByteFiller = rand.Read
@@ -32,7 +31,7 @@ func GenerateId(numBytes int) string {
 	transactionIdBytes := make([]byte, numBytes)
 	_, err := randomByteFiller(transactionIdBytes)
 	if err != nil {
-		return err.Error() + uuid.NewString()
+		return err.Error() + uuid.New().String()
 	}
 	return hex.EncodeToString(transactionIdBytes)
 }