From c494917c738fdf8189e09b24a2ee9a9e1e9613c9 Mon Sep 17 00:00:00 2001
From: John Weldon <johnweldon4@gmail.com>
Date: Tue, 4 Apr 2023 18:08:02 -0700
Subject: [PATCH] gofumpt

---
 add.go                      |  1 -
 bind.go                     |  7 +++---
 compare.go                  |  3 ++-
 dn_test.go                  | 47 +++++++++++++++++++++++++------------
 examples_test.go            |  6 ++---
 examples_windows_test.go    |  1 -
 gssapi/sspi.go              |  1 -
 search_test.go              |  6 ++---
 v3/add.go                   |  1 -
 v3/bind.go                  |  7 +++---
 v3/compare.go               |  3 ++-
 v3/control.go               |  1 +
 v3/dn_test.go               | 47 +++++++++++++++++++++++++------------
 v3/examples_test.go         |  6 ++---
 v3/examples_windows_test.go |  1 -
 v3/gssapi/sspi.go           |  1 -
 v3/search_test.go           |  6 ++---
 17 files changed, 85 insertions(+), 60 deletions(-)

diff --git a/add.go b/add.go
index c3101b76..5591ee77 100644
--- a/add.go
+++ b/add.go
@@ -61,7 +61,6 @@ func NewAddRequest(dn string, controls []Control) *AddRequest {
 		DN:       dn,
 		Controls: controls,
 	}
-
 }
 
 // Add performs the given AddRequest
diff --git a/bind.go b/bind.go
index 9c6cc282..09914b27 100644
--- a/bind.go
+++ b/bind.go
@@ -261,7 +261,7 @@ func parseParams(str string) (map[string]string, error) {
 	var state int
 	for i := 0; i <= len(str); i++ {
 		switch state {
-		case 0: //reading key
+		case 0: // reading key
 			if i == len(str) {
 				return nil, fmt.Errorf("syntax error on %d", i)
 			}
@@ -270,7 +270,7 @@ func parseParams(str string) (map[string]string, error) {
 				continue
 			}
 			state = 1
-		case 1: //reading value
+		case 1: // reading value
 			if i == len(str) {
 				m[key] = value
 				break
@@ -289,7 +289,7 @@ func parseParams(str string) (map[string]string, error) {
 			default:
 				value += string(str[i])
 			}
-		case 2: //inside quotes
+		case 2: // inside quotes
 			if i == len(str) {
 				return nil, fmt.Errorf("syntax error on %d", i)
 			}
@@ -651,7 +651,6 @@ func (l *Conn) GSSAPIBindRequest(client GSSAPIClient, req *GSSAPIBindRequest) er
 }
 
 func (l *Conn) saslBindTokenExchange(reqControls []Control, reqToken []byte) ([]byte, error) {
-
 	// Construct LDAP Bind request with GSSAPI SASL mechanism.
 	envelope := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
 	envelope.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, l.nextMessageID(), "MessageID"))
diff --git a/compare.go b/compare.go
index cd43e4c5..a1cd760b 100644
--- a/compare.go
+++ b/compare.go
@@ -34,7 +34,8 @@ func (l *Conn) Compare(dn, attribute, value string) (bool, error) {
 	msgCtx, err := l.doRequest(&CompareRequest{
 		DN:        dn,
 		Attribute: attribute,
-		Value:     value})
+		Value:     value,
+	})
 	if err != nil {
 		return false, err
 	}
diff --git a/dn_test.go b/dn_test.go
index 89722a6b..a937f498 100644
--- a/dn_test.go
+++ b/dn_test.go
@@ -11,55 +11,72 @@ func TestSuccessfulDNParsing(t *testing.T) {
 		"cn=Jim\\2C \\22Hasse Hö\\22 Hansson!,dc=dummy,dc=com": {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"cn", "Jim, \"Hasse Hö\" Hansson!"}}},
 			{[]*AttributeTypeAndValue{{"dc", "dummy"}}},
-			{[]*AttributeTypeAndValue{{"dc", "com"}}}}},
+			{[]*AttributeTypeAndValue{{"dc", "com"}}},
+		}},
 		"UID=jsmith,DC=example,DC=net": {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"UID", "jsmith"}}},
 			{[]*AttributeTypeAndValue{{"DC", "example"}}},
-			{[]*AttributeTypeAndValue{{"DC", "net"}}}}},
+			{[]*AttributeTypeAndValue{{"DC", "net"}}},
+		}},
 		"OU=Sales+CN=J. Smith,DC=example,DC=net": {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{
 				{"OU", "Sales"},
-				{"CN", "J. Smith"}}},
+				{"CN", "J. Smith"},
+			}},
 			{[]*AttributeTypeAndValue{{"DC", "example"}}},
-			{[]*AttributeTypeAndValue{{"DC", "net"}}}}},
+			{[]*AttributeTypeAndValue{{"DC", "net"}}},
+		}},
 		"1.3.6.1.4.1.1466.0=#04024869": {[]*RelativeDN{
-			{[]*AttributeTypeAndValue{{"1.3.6.1.4.1.1466.0", "Hi"}}}}},
+			{[]*AttributeTypeAndValue{{"1.3.6.1.4.1.1466.0", "Hi"}}},
+		}},
 		"1.3.6.1.4.1.1466.0=#04024869,DC=net": {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"1.3.6.1.4.1.1466.0", "Hi"}}},
-			{[]*AttributeTypeAndValue{{"DC", "net"}}}}},
+			{[]*AttributeTypeAndValue{{"DC", "net"}}},
+		}},
 		"CN=Lu\\C4\\8Di\\C4\\87": {[]*RelativeDN{
-			{[]*AttributeTypeAndValue{{"CN", "Lučić"}}}}},
+			{[]*AttributeTypeAndValue{{"CN", "Lučić"}}},
+		}},
 		"  CN  =  Lu\\C4\\8Di\\C4\\87  ": {[]*RelativeDN{
-			{[]*AttributeTypeAndValue{{"CN", "Lučić"}}}}},
+			{[]*AttributeTypeAndValue{{"CN", "Lučić"}}},
+		}},
 		`   A   =   1   ,   B   =   2   `: {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"A", "1"}}},
-			{[]*AttributeTypeAndValue{{"B", "2"}}}}},
+			{[]*AttributeTypeAndValue{{"B", "2"}}},
+		}},
 		`   A   =   1   +   B   =   2   `: {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{
 				{"A", "1"},
-				{"B", "2"}}}}},
+				{"B", "2"},
+			}},
+		}},
 		`   \ \ A\ \    =   \ \ 1\ \    ,   \ \ B\ \    =   \ \ 2\ \    `: {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"  A  ", "  1  "}}},
-			{[]*AttributeTypeAndValue{{"  B  ", "  2  "}}}}},
+			{[]*AttributeTypeAndValue{{"  B  ", "  2  "}}},
+		}},
 		`   \ \ A\ \    =   \ \ 1\ \    +   \ \ B\ \    =   \ \ 2\ \    `: {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{
 				{"  A  ", "  1  "},
-				{"  B  ", "  2  "}}}}},
+				{"  B  ", "  2  "},
+			}},
+		}},
 
 		`cn=john.doe;dc=example,dc=net`: {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"cn", "john.doe"}}},
 			{[]*AttributeTypeAndValue{{"dc", "example"}}},
-			{[]*AttributeTypeAndValue{{"dc", "net"}}}}},
+			{[]*AttributeTypeAndValue{{"dc", "net"}}},
+		}},
 
 		// Escaped `;` should not be treated as RDN
 		`cn=john.doe\;weird name,dc=example,dc=net`: {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"cn", "john.doe;weird name"}}},
 			{[]*AttributeTypeAndValue{{"dc", "example"}}},
-			{[]*AttributeTypeAndValue{{"dc", "net"}}}}},
+			{[]*AttributeTypeAndValue{{"dc", "net"}}},
+		}},
 		`cn=ZXhhbXBsZVRleHQ=,dc=dummy,dc=com`: {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"cn", "ZXhhbXBsZVRleHQ="}}},
 			{[]*AttributeTypeAndValue{{"dc", "dummy"}}},
-			{[]*AttributeTypeAndValue{{"dc", "com"}}}}},
+			{[]*AttributeTypeAndValue{{"dc", "com"}}},
+		}},
 	}
 
 	for test, answer := range testcases {
diff --git a/examples_test.go b/examples_test.go
index af6d6e45..60e674ae 100644
--- a/examples_test.go
+++ b/examples_test.go
@@ -346,9 +346,9 @@ func ExampleControlPaging_manualPaging() {
 
 // This example demonstrates how to use EXTERNAL SASL with TLS client certificates.
 func ExampleConn_ExternalBind() {
-	var ldapCert = "/path/to/cert.pem"
-	var ldapKey = "/path/to/key.pem"
-	var ldapCAchain = "/path/to/ca_chain.pem"
+	ldapCert := "/path/to/cert.pem"
+	ldapKey := "/path/to/key.pem"
+	ldapCAchain := "/path/to/ca_chain.pem"
 
 	// Load client cert and key
 	cert, err := tls.LoadX509KeyPair(ldapCert, ldapKey)
diff --git a/examples_windows_test.go b/examples_windows_test.go
index dbfac77b..f24698b3 100644
--- a/examples_windows_test.go
+++ b/examples_windows_test.go
@@ -12,7 +12,6 @@ import (
 // This example demonstrates passwordless bind using the current process' user
 // credentials on Windows (SASL GSSAPI mechanism bind with SSPI client).
 func ExampleConn_SSPIClient_GSSAPIBind() {
-
 	// Windows only: Create a GSSAPIClient using Windows built-in SSPI lib
 	// (secur32.dll).
 	// This will use the credentials of the current process' user.
diff --git a/gssapi/sspi.go b/gssapi/sspi.go
index bd6aae71..3bad8b43 100644
--- a/gssapi/sspi.go
+++ b/gssapi/sspi.go
@@ -99,7 +99,6 @@ func (c *SSPIClient) InitSecContext(target string, token []byte) ([]byte, bool,
 // NegotiateSaslAuth performs the last step of the SASL handshake.
 // See RFC 4752 section 3.1.
 func (c *SSPIClient) NegotiateSaslAuth(token []byte, authzid string) ([]byte, error) {
-
 	// Using SSPI rather than of GSSAPI, relevant documentation of differences here:
 	// https://learn.microsoft.com/en-us/windows/win32/secauthn/sspi-kerberos-interoperability-with-gssapi
 
diff --git a/search_test.go b/search_test.go
index 54a3dc94..6d034e4b 100644
--- a/search_test.go
+++ b/search_test.go
@@ -1,9 +1,10 @@
 package ldap
 
 import (
-	"github.com/stretchr/testify/assert"
 	"reflect"
 	"testing"
+
+	"github.com/stretchr/testify/assert"
 )
 
 // TestNewEntry tests that repeated calls to NewEntry return the same value with the same input
@@ -51,7 +52,6 @@ func TestGetAttributeValue(t *testing.T) {
 }
 
 func TestEntry_Unmarshal(t *testing.T) {
-
 	t.Run("passing a struct should fail", func(t *testing.T) {
 		entry := &Entry{}
 
@@ -131,7 +131,6 @@ func TestEntry_Unmarshal(t *testing.T) {
 
 		assert.Nil(t, err)
 		assert.Equal(t, expect, result)
-
 	})
 
 	t.Run("group struct be decoded", func(t *testing.T) {
@@ -169,5 +168,4 @@ func TestEntry_Unmarshal(t *testing.T) {
 		assert.Nil(t, err)
 		assert.Equal(t, expect, result)
 	})
-
 }
diff --git a/v3/add.go b/v3/add.go
index c3101b76..5591ee77 100644
--- a/v3/add.go
+++ b/v3/add.go
@@ -61,7 +61,6 @@ func NewAddRequest(dn string, controls []Control) *AddRequest {
 		DN:       dn,
 		Controls: controls,
 	}
-
 }
 
 // Add performs the given AddRequest
diff --git a/v3/bind.go b/v3/bind.go
index 9a87d027..a37f8e2c 100644
--- a/v3/bind.go
+++ b/v3/bind.go
@@ -261,7 +261,7 @@ func parseParams(str string) (map[string]string, error) {
 	var state int
 	for i := 0; i <= len(str); i++ {
 		switch state {
-		case 0: //reading key
+		case 0: // reading key
 			if i == len(str) {
 				return nil, fmt.Errorf("syntax error on %d", i)
 			}
@@ -270,7 +270,7 @@ func parseParams(str string) (map[string]string, error) {
 				continue
 			}
 			state = 1
-		case 1: //reading value
+		case 1: // reading value
 			if i == len(str) {
 				m[key] = value
 				break
@@ -289,7 +289,7 @@ func parseParams(str string) (map[string]string, error) {
 			default:
 				value += string(str[i])
 			}
-		case 2: //inside quotes
+		case 2: // inside quotes
 			if i == len(str) {
 				return nil, fmt.Errorf("syntax error on %d", i)
 			}
@@ -651,7 +651,6 @@ func (l *Conn) GSSAPIBindRequest(client GSSAPIClient, req *GSSAPIBindRequest) er
 }
 
 func (l *Conn) saslBindTokenExchange(reqControls []Control, reqToken []byte) ([]byte, error) {
-
 	// Construct LDAP Bind request with GSSAPI SASL mechanism.
 	envelope := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
 	envelope.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, l.nextMessageID(), "MessageID"))
diff --git a/v3/compare.go b/v3/compare.go
index cd43e4c5..a1cd760b 100644
--- a/v3/compare.go
+++ b/v3/compare.go
@@ -34,7 +34,8 @@ func (l *Conn) Compare(dn, attribute, value string) (bool, error) {
 	msgCtx, err := l.doRequest(&CompareRequest{
 		DN:        dn,
 		Attribute: attribute,
-		Value:     value})
+		Value:     value,
+	})
 	if err != nil {
 		return false, err
 	}
diff --git a/v3/control.go b/v3/control.go
index 7dd0da0d..ad405faf 100644
--- a/v3/control.go
+++ b/v3/control.go
@@ -740,6 +740,7 @@ type ControlServerSideSortingResult struct {
 func (control *ControlServerSideSortingResult) GetControlType() string {
 	return ControlTypeServerSideSortingResult
 }
+
 func (c *ControlServerSideSortingResult) Encode() *ber.Packet {
 	packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "SortResult sequence")
 	sortResult := ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagEnumerated, int64(c.Result), "SortResult")
diff --git a/v3/dn_test.go b/v3/dn_test.go
index 89722a6b..a937f498 100644
--- a/v3/dn_test.go
+++ b/v3/dn_test.go
@@ -11,55 +11,72 @@ func TestSuccessfulDNParsing(t *testing.T) {
 		"cn=Jim\\2C \\22Hasse Hö\\22 Hansson!,dc=dummy,dc=com": {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"cn", "Jim, \"Hasse Hö\" Hansson!"}}},
 			{[]*AttributeTypeAndValue{{"dc", "dummy"}}},
-			{[]*AttributeTypeAndValue{{"dc", "com"}}}}},
+			{[]*AttributeTypeAndValue{{"dc", "com"}}},
+		}},
 		"UID=jsmith,DC=example,DC=net": {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"UID", "jsmith"}}},
 			{[]*AttributeTypeAndValue{{"DC", "example"}}},
-			{[]*AttributeTypeAndValue{{"DC", "net"}}}}},
+			{[]*AttributeTypeAndValue{{"DC", "net"}}},
+		}},
 		"OU=Sales+CN=J. Smith,DC=example,DC=net": {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{
 				{"OU", "Sales"},
-				{"CN", "J. Smith"}}},
+				{"CN", "J. Smith"},
+			}},
 			{[]*AttributeTypeAndValue{{"DC", "example"}}},
-			{[]*AttributeTypeAndValue{{"DC", "net"}}}}},
+			{[]*AttributeTypeAndValue{{"DC", "net"}}},
+		}},
 		"1.3.6.1.4.1.1466.0=#04024869": {[]*RelativeDN{
-			{[]*AttributeTypeAndValue{{"1.3.6.1.4.1.1466.0", "Hi"}}}}},
+			{[]*AttributeTypeAndValue{{"1.3.6.1.4.1.1466.0", "Hi"}}},
+		}},
 		"1.3.6.1.4.1.1466.0=#04024869,DC=net": {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"1.3.6.1.4.1.1466.0", "Hi"}}},
-			{[]*AttributeTypeAndValue{{"DC", "net"}}}}},
+			{[]*AttributeTypeAndValue{{"DC", "net"}}},
+		}},
 		"CN=Lu\\C4\\8Di\\C4\\87": {[]*RelativeDN{
-			{[]*AttributeTypeAndValue{{"CN", "Lučić"}}}}},
+			{[]*AttributeTypeAndValue{{"CN", "Lučić"}}},
+		}},
 		"  CN  =  Lu\\C4\\8Di\\C4\\87  ": {[]*RelativeDN{
-			{[]*AttributeTypeAndValue{{"CN", "Lučić"}}}}},
+			{[]*AttributeTypeAndValue{{"CN", "Lučić"}}},
+		}},
 		`   A   =   1   ,   B   =   2   `: {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"A", "1"}}},
-			{[]*AttributeTypeAndValue{{"B", "2"}}}}},
+			{[]*AttributeTypeAndValue{{"B", "2"}}},
+		}},
 		`   A   =   1   +   B   =   2   `: {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{
 				{"A", "1"},
-				{"B", "2"}}}}},
+				{"B", "2"},
+			}},
+		}},
 		`   \ \ A\ \    =   \ \ 1\ \    ,   \ \ B\ \    =   \ \ 2\ \    `: {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"  A  ", "  1  "}}},
-			{[]*AttributeTypeAndValue{{"  B  ", "  2  "}}}}},
+			{[]*AttributeTypeAndValue{{"  B  ", "  2  "}}},
+		}},
 		`   \ \ A\ \    =   \ \ 1\ \    +   \ \ B\ \    =   \ \ 2\ \    `: {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{
 				{"  A  ", "  1  "},
-				{"  B  ", "  2  "}}}}},
+				{"  B  ", "  2  "},
+			}},
+		}},
 
 		`cn=john.doe;dc=example,dc=net`: {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"cn", "john.doe"}}},
 			{[]*AttributeTypeAndValue{{"dc", "example"}}},
-			{[]*AttributeTypeAndValue{{"dc", "net"}}}}},
+			{[]*AttributeTypeAndValue{{"dc", "net"}}},
+		}},
 
 		// Escaped `;` should not be treated as RDN
 		`cn=john.doe\;weird name,dc=example,dc=net`: {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"cn", "john.doe;weird name"}}},
 			{[]*AttributeTypeAndValue{{"dc", "example"}}},
-			{[]*AttributeTypeAndValue{{"dc", "net"}}}}},
+			{[]*AttributeTypeAndValue{{"dc", "net"}}},
+		}},
 		`cn=ZXhhbXBsZVRleHQ=,dc=dummy,dc=com`: {[]*RelativeDN{
 			{[]*AttributeTypeAndValue{{"cn", "ZXhhbXBsZVRleHQ="}}},
 			{[]*AttributeTypeAndValue{{"dc", "dummy"}}},
-			{[]*AttributeTypeAndValue{{"dc", "com"}}}}},
+			{[]*AttributeTypeAndValue{{"dc", "com"}}},
+		}},
 	}
 
 	for test, answer := range testcases {
diff --git a/v3/examples_test.go b/v3/examples_test.go
index af6d6e45..60e674ae 100644
--- a/v3/examples_test.go
+++ b/v3/examples_test.go
@@ -346,9 +346,9 @@ func ExampleControlPaging_manualPaging() {
 
 // This example demonstrates how to use EXTERNAL SASL with TLS client certificates.
 func ExampleConn_ExternalBind() {
-	var ldapCert = "/path/to/cert.pem"
-	var ldapKey = "/path/to/key.pem"
-	var ldapCAchain = "/path/to/ca_chain.pem"
+	ldapCert := "/path/to/cert.pem"
+	ldapKey := "/path/to/key.pem"
+	ldapCAchain := "/path/to/ca_chain.pem"
 
 	// Load client cert and key
 	cert, err := tls.LoadX509KeyPair(ldapCert, ldapKey)
diff --git a/v3/examples_windows_test.go b/v3/examples_windows_test.go
index ddc9aedf..7fe90a0c 100644
--- a/v3/examples_windows_test.go
+++ b/v3/examples_windows_test.go
@@ -12,7 +12,6 @@ import (
 // This example demonstrates passwordless bind using the current process' user
 // credentials on Windows (SASL GSSAPI mechanism bind with SSPI client).
 func ExampleConn_SSPIClient_GSSAPIBind() {
-
 	// Windows only: Create a GSSAPIClient using Windows built-in SSPI lib
 	// (secur32.dll).
 	// This will use the credentials of the current process' user.
diff --git a/v3/gssapi/sspi.go b/v3/gssapi/sspi.go
index bd6aae71..3bad8b43 100644
--- a/v3/gssapi/sspi.go
+++ b/v3/gssapi/sspi.go
@@ -99,7 +99,6 @@ func (c *SSPIClient) InitSecContext(target string, token []byte) ([]byte, bool,
 // NegotiateSaslAuth performs the last step of the SASL handshake.
 // See RFC 4752 section 3.1.
 func (c *SSPIClient) NegotiateSaslAuth(token []byte, authzid string) ([]byte, error) {
-
 	// Using SSPI rather than of GSSAPI, relevant documentation of differences here:
 	// https://learn.microsoft.com/en-us/windows/win32/secauthn/sspi-kerberos-interoperability-with-gssapi
 
diff --git a/v3/search_test.go b/v3/search_test.go
index 54a3dc94..6d034e4b 100644
--- a/v3/search_test.go
+++ b/v3/search_test.go
@@ -1,9 +1,10 @@
 package ldap
 
 import (
-	"github.com/stretchr/testify/assert"
 	"reflect"
 	"testing"
+
+	"github.com/stretchr/testify/assert"
 )
 
 // TestNewEntry tests that repeated calls to NewEntry return the same value with the same input
@@ -51,7 +52,6 @@ func TestGetAttributeValue(t *testing.T) {
 }
 
 func TestEntry_Unmarshal(t *testing.T) {
-
 	t.Run("passing a struct should fail", func(t *testing.T) {
 		entry := &Entry{}
 
@@ -131,7 +131,6 @@ func TestEntry_Unmarshal(t *testing.T) {
 
 		assert.Nil(t, err)
 		assert.Equal(t, expect, result)
-
 	})
 
 	t.Run("group struct be decoded", func(t *testing.T) {
@@ -169,5 +168,4 @@ func TestEntry_Unmarshal(t *testing.T) {
 		assert.Nil(t, err)
 		assert.Equal(t, expect, result)
 	})
-
 }