From a70dfc28f7e825163d2d8e86c9a320f93c27d482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Schr=C3=B6der?= Date: Tue, 13 Jun 2023 07:35:15 +0200 Subject: [PATCH 1/3] Clarify supported go versions, retract broken versions --- README.md | 15 +++------------ go.mod | 5 +++++ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 02be8c3d..aa6a86d4 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ A native Go implementation of the OPC/UA Binary Protocol. -You need go1.13 or higher. We test with the current and previous Go version. +We support the current and previous major Go release. See below for a list of [Tested Platforms](#tested-platforms) and [Supported Features](#supported-features). [![GitHub](https://github.com/gopcua/opcua/workflows/gopuca/badge.svg)](https://github.com/gopcua/opcua/actions) @@ -20,16 +20,9 @@ See below for a list of [Tested Platforms](#tested-platforms) and [Supported Fea [![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/gopcua/opcua/blob/master/LICENSE) [![Version](https://img.shields.io/github/tag/gopcua/opcua.svg?color=blue&label=version)](https://github.com/gopcua/opcua/releases) -## Note - -`v0.2.4` and `v0.2.5` are broken and should not be used. Please upgrade to `v0.2.6` or later. -See [#538](https://github.com/gopcua/opcua/issues/538) for details. - ## Quickstart ```sh -# make sure you have go1.17 or higher - # install library go get -u github.com/gopcua/opcua @@ -95,11 +88,9 @@ We would also like to list organizations which use `gopcua` in production. Pleas We are still actively working on this project and the APIs will change. -We have started to tag the code to support go modules and reproducible builds -but there is still no guarantee of API stability. - However, you can safely assume that we are aiming to make the APIs as -stable as possible. :) +stable as possible since the code is in use in several large scale +production environments. The [Current State](https://github.com/gopcua/opcua/wiki/Current-State) was moved to the [Wiki](https://github.com/gopcua/opcua/wiki). diff --git a/go.mod b/go.mod index eaea9cdb..699fe089 100644 --- a/go.mod +++ b/go.mod @@ -12,3 +12,8 @@ require ( golang.org/x/sys v0.6.0 // indirect golang.org/x/term v0.6.0 // indirect ) + +retract ( + v0.2.5 // https://github.com/gopcua/opcua/issues/538 + v0.2.4 // https://github.com/gopcua/opcua/issues/538 +) From 772a0ac3fd1f7d3cda58cbd4ecd37f365a7a3a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Schr=C3=B6der?= Date: Tue, 13 Jun 2023 07:35:46 +0200 Subject: [PATCH 2/3] use golang.org/exp/x/slices --- client.go | 9 --------- client_sub.go | 3 ++- debug/debug.go | 13 +++---------- go.mod | 1 + go.sum | 2 ++ 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/client.go b/client.go index c9440339..0dcb2158 100644 --- a/client.go +++ b/client.go @@ -1431,15 +1431,6 @@ func safeAssign(t, ptrT interface{}) error { return nil } -func uint32SliceContains(n uint32, a []uint32) bool { - for _, v := range a { - if n == v { - return true - } - } - return false -} - type InvalidResponseTypeError struct { got, want interface{} } diff --git a/client_sub.go b/client_sub.go index e8b70d8b..63578b46 100644 --- a/client_sub.go +++ b/client_sub.go @@ -11,6 +11,7 @@ import ( "github.com/gopcua/opcua/stats" "github.com/gopcua/opcua/ua" "github.com/gopcua/opcua/uasc" + "golang.org/x/exp/slices" ) // Subscribe creates a Subscription with given parameters. @@ -156,7 +157,7 @@ func (c *Client) sendRepublishRequests(ctx context.Context, sub *Subscription, a // todo(fs): check if sub.nextSeq is in the available sequence numbers // todo(fs): if not then we need to decide whether we fail b/c of data loss // todo(fs): or whether we log it and continue. - if len(availableSeq) > 0 && !uint32SliceContains(sub.nextSeq, availableSeq) { + if len(availableSeq) > 0 && !slices.Contains(availableSeq, sub.nextSeq) { log.Printf("sub %d: next sequence number %d not in retransmission buffer %v", sub.SubscriptionID, sub.nextSeq, availableSeq) } diff --git a/debug/debug.go b/debug/debug.go index 1dfec9e6..113bef01 100644 --- a/debug/debug.go +++ b/debug/debug.go @@ -12,6 +12,8 @@ import ( "log" "os" "strings" + + "golang.org/x/exp/slices" ) // Flags contains the debug flags set by OPC_DEBUG. @@ -58,14 +60,5 @@ func ToJSON(v interface{}) string { // FlagSet returns true if the OPCUA_DEBUG environment variable contains the // given flag. func FlagSet(name string) bool { - return stringSliceContains(name, strings.Fields(Flags)) -} - -func stringSliceContains(s string, vals []string) bool { - for _, v := range vals { - if s == v { - return true - } - } - return false + return slices.Contains(strings.Fields(Flags), name) } diff --git a/go.mod b/go.mod index 699fe089..b29c2c63 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/pascaldekloe/goe v0.1.0 github.com/pkg/errors v0.8.1 golang.org/x/crypto v0.7.0 + golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 ) require ( diff --git a/go.sum b/go.sum index 78079615..1b1c1288 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= From a7a9435495e77d52880414eb8b5cfd7719b16314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Schr=C3=B6der?= Date: Tue, 13 Jun 2023 07:50:39 +0200 Subject: [PATCH 3/3] update dependencies --- go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index b29c2c63..b09c69c7 100644 --- a/go.mod +++ b/go.mod @@ -3,15 +3,15 @@ module github.com/gopcua/opcua go 1.20 require ( - github.com/pascaldekloe/goe v0.1.0 - github.com/pkg/errors v0.8.1 - golang.org/x/crypto v0.7.0 + github.com/pascaldekloe/goe v0.1.1 + github.com/pkg/errors v0.9.1 + golang.org/x/crypto v0.9.0 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 ) require ( - golang.org/x/sys v0.6.0 // indirect - golang.org/x/term v0.6.0 // indirect + golang.org/x/sys v0.8.0 // indirect + golang.org/x/term v0.8.0 // indirect ) retract ( diff --git a/go.sum b/go.sum index 1b1c1288..7a5ce3fc 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,12 @@ -github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= -github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +github.com/pascaldekloe/goe v0.1.1 h1:Ah6WQ56rZONR3RW3qWa2NCZ6JAVvSpUcoLBaOmYFt9Q= +github.com/pascaldekloe/goe v0.1.1/go.mod h1:KSyfaxQOh0HZPjDP1FL/kFtbqYqrALJTaMafFUIccqU= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= +golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=