ソースを参照

Updated to go1.23

Sayan Mallick 1 年間 前
コミット
0799c819db
4 ファイル変更14 行追加14 行削除
  1. 5 5
      .github/workflows/test.yml
  2. 1 1
      go.mod
  3. 2 2
      models/names.go
  4. 6 6
      pro/types.go

+ 5 - 5
.github/workflows/test.yml

@@ -15,7 +15,7 @@ jobs:
       - name: Setup Go
         uses: actions/setup-go@v5
         with:
-          go-version: 1.19
+          go-version-file: go.mod
       - name: Build
         run: |
          env CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build main.go
@@ -29,7 +29,7 @@ jobs:
       - name: Setup go
         uses: actions/setup-go@v5
         with:
-          go-version: 1.19
+          go-version-file: go.mod
       - name: Build
         run: |
           cd cli
@@ -46,7 +46,7 @@ jobs:
       - name: Setup Go
         uses: actions/setup-go@v5
         with:
-          go-version: 1.19
+          go-version-file: go.mod
       - name: run tests
         run: |
           go vet ./...
@@ -66,9 +66,9 @@ jobs:
       - name: Setup Go
         uses: actions/setup-go@v5
         with:
-          go-version: 1.19
+          go-version-file: go.mod
       - name: run static checks
         run: |
           sudo apt update
-          go install honnef.co/go/tools/cmd/staticcheck@v0.4.7
+          go install honnef.co/go/tools/cmd/staticcheck@latest
           { ~/go/bin/staticcheck  -tags=ee ./... ; }

+ 1 - 1
go.mod

@@ -1,6 +1,6 @@
 module github.com/gravitl/netmaker
 
-go 1.19
+go 1.23
 
 require (
 	github.com/eclipse/paho.mqtt.golang v1.4.3

+ 2 - 2
models/names.go

@@ -235,8 +235,8 @@ var logoString = retrieveLogo()
 
 // GenerateNodeName - generates a random node name
 func GenerateNodeName() string {
-	rand.Seed(time.Now().UnixNano())
-	return SMALL_NAMES[rand.Intn(len(SMALL_NAMES))] + "-" + NAMES[seededRand.Intn(len(NAMES))]
+	rng := rand.New(rand.NewSource(time.Now().UnixNano()))
+	return SMALL_NAMES[rng.Intn(len(SMALL_NAMES))] + "-" + NAMES[rng.Intn(len(NAMES))]
 }
 
 // RetrieveLogo - retrieves the ascii art logo for Netmaker

+ 6 - 6
pro/types.go

@@ -4,7 +4,7 @@
 package pro
 
 import (
-	"fmt"
+	"errors"
 )
 
 // constants for accounts api hosts
@@ -23,7 +23,7 @@ const (
 	server_id_key              = "nm-server-id"
 )
 
-var errValidation = fmt.Errorf(license_validation_err_msg)
+var errValidation = errors.New(license_validation_err_msg)
 
 // LicenseKey - the license key struct representation with associated data
 type LicenseKey struct {
@@ -42,14 +42,14 @@ type LicenseKey struct {
 
 // ValidatedLicense - the validated license struct
 type ValidatedLicense struct {
-	LicenseValue     string `json:"license_value" binding:"required"`     // license that validation is being requested for
+	LicenseValue     string `json:"license_value"     binding:"required"` // license that validation is being requested for
 	EncryptedLicense string `json:"encrypted_license" binding:"required"` // to be decrypted by Netmaker using Netmaker server's private key
 }
 
 // LicenseSecret - the encrypted struct for sending user-id
 type LicenseSecret struct {
 	AssociatedID string `json:"associated_id" binding:"required"` // UUID for user foreign key to User table
-	Usage        Usage  `json:"limits" binding:"required"`
+	Usage        Usage  `json:"limits"        binding:"required"`
 }
 
 // Usage - struct for license usage
@@ -81,9 +81,9 @@ func (l *Usage) SetDefaults() {
 
 // ValidateLicenseRequest - used for request to validate license endpoint
 type ValidateLicenseRequest struct {
-	LicenseKey     string `json:"license_key" binding:"required"`
+	LicenseKey     string `json:"license_key"       binding:"required"`
 	NmServerPubKey string `json:"nm_server_pub_key" binding:"required"` // Netmaker server public key used to send data back to Netmaker for the Netmaker server to decrypt (eg output from validating license)
-	EncryptedPart  string `json:"secret" binding:"required"`
+	EncryptedPart  string `json:"secret"            binding:"required"`
 }
 
 type licenseResponseCache struct {