chore: use gofumpt for code formatting

This commit is contained in:
Quentin McGaw
2024-10-11 19:20:48 +00:00
parent 3daf15a612
commit 76a4bb5dc3
289 changed files with 784 additions and 548 deletions

View File

@@ -14,7 +14,8 @@ var (
// Data extracts the lines and connection from the OpenVPN configuration file.
func (e *Extractor) Data(filepath string) (lines []string,
connection models.Connection, err error) {
connection models.Connection, err error,
) {
lines, err = readCustomConfigLines(filepath)
if err != nil {
return nil, connection, fmt.Errorf("reading configuration file: %w", err)

View File

@@ -11,12 +11,11 @@ import (
"github.com/qdm12/gluetun/internal/models"
)
var (
errRemoteLineNotFound = errors.New("remote line not found")
)
var errRemoteLineNotFound = errors.New("remote line not found")
func extractDataFromLines(lines []string) (
connection models.Connection, err error) {
connection models.Connection, err error,
) {
for i, line := range lines {
hashSymbolIndex := strings.Index(line, "#")
if hashSymbolIndex >= 0 {
@@ -54,7 +53,8 @@ func extractDataFromLines(lines []string) (
}
func extractDataFromLine(line string) (
ip netip.Addr, port uint16, protocol string, err error) {
ip netip.Addr, port uint16, protocol string, err error,
) {
switch {
case strings.HasPrefix(line, "proto "):
protocol, err = extractProto(line)
@@ -108,7 +108,8 @@ var (
)
func extractRemote(line string) (ip netip.Addr, port uint16,
protocol string, err error) {
protocol string, err error,
) {
fields := strings.Fields(line)
n := len(fields)
@@ -146,9 +147,7 @@ func extractRemote(line string) (ip netip.Addr, port uint16,
return ip, port, protocol, nil
}
var (
errPostLineFieldsCount = errors.New("post line has not 2 fields as expected")
)
var errPostLineFieldsCount = errors.New("post line has not 2 fields as expected")
func extractPort(line string) (port uint16, err error) {
fields := strings.Fields(line)

View File

@@ -7,9 +7,7 @@ import (
"fmt"
)
var (
errPEMDecode = errors.New("cannot decode PEM encoded block")
)
var errPEMDecode = errors.New("cannot decode PEM encoded block")
func PEM(b []byte) (encodedData string, err error) {
pemBlock, _ := pem.Decode(b)

View File

@@ -7,7 +7,8 @@ import (
)
func readCustomConfigLines(filepath string) (
lines []string, err error) {
lines []string, err error,
) {
file, err := os.Open(filepath)
if err != nil {
return nil, err