Skip to content

Commit b32f265

Browse files
authored
ci: Use gofumpt to format code (caddyserver#5707)
1 parent 431adc0 commit b32f265

33 files changed

+60
-64
lines changed

.golangci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ linters:
88
enable:
99
- bodyclose
1010
- errcheck
11-
- gofmt
12-
- goimports
11+
- gofumpt
1312
- gosec
1413
- gosimple
1514
- govet

admin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ var (
13461346
// will get deleted before the process gracefully exits.
13471347
func PIDFile(filename string) error {
13481348
pid := []byte(strconv.Itoa(os.Getpid()) + "\n")
1349-
err := os.WriteFile(filename, pid, 0600)
1349+
err := os.WriteFile(filename, pid, 0o600)
13501350
if err != nil {
13511351
return err
13521352
}

caddy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,13 @@ func unsyncedDecodeAndRun(cfgJSON []byte, allowPersist bool) error {
356356
newCfg.Admin.Config.Persist == nil ||
357357
*newCfg.Admin.Config.Persist) {
358358
dir := filepath.Dir(ConfigAutosavePath)
359-
err := os.MkdirAll(dir, 0700)
359+
err := os.MkdirAll(dir, 0o700)
360360
if err != nil {
361361
Log().Error("unable to create folder for config autosave",
362362
zap.String("dir", dir),
363363
zap.Error(err))
364364
} else {
365-
err := os.WriteFile(ConfigAutosavePath, cfgJSON, 0600)
365+
err := os.WriteFile(ConfigAutosavePath, cfgJSON, 0o600)
366366
if err == nil {
367367
Log().Info("autosaved config (load with --resume flag)", zap.String("file", ConfigAutosavePath))
368368
} else {
@@ -831,7 +831,7 @@ func InstanceID() (uuid.UUID, error) {
831831
if err != nil {
832832
return uuid, err
833833
}
834-
err = os.WriteFile(uuidFilePath, []byte(uuid.String()), 0600)
834+
err = os.WriteFile(uuidFilePath, []byte(uuid.String()), 0o600)
835835
return uuid, err
836836
} else if err != nil {
837837
return [16]byte{}, err

caddyconfig/caddyfile/importgraph.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func (i *importGraph) addNode(name string) {
3434
}
3535
i.nodes[name] = true
3636
}
37+
3738
func (i *importGraph) addNodes(names []string) {
3839
for _, name := range names {
3940
i.addNode(name)
@@ -43,6 +44,7 @@ func (i *importGraph) addNodes(names []string) {
4344
func (i *importGraph) removeNode(name string) {
4445
delete(i.nodes, name)
4546
}
47+
4648
func (i *importGraph) removeNodes(names []string) {
4749
for _, name := range names {
4850
i.removeNode(name)
@@ -73,6 +75,7 @@ func (i *importGraph) addEdge(from, to string) error {
7375
i.edges[from] = append(i.edges[from], to)
7476
return nil
7577
}
78+
7679
func (i *importGraph) addEdges(from string, tos []string) error {
7780
for _, to := range tos {
7881
err := i.addEdge(from, to)

caddyconfig/caddyfile/parse.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,6 @@ func (p *parser) doSingleImport(importFile string) ([]Token, error) {
565565
// are loaded into the current server block for later use
566566
// by directive setup functions.
567567
func (p *parser) directive() error {
568-
569568
// a segment is a list of tokens associated with this directive
570569
var segment Segment
571570

caddyconfig/httpcaddyfile/addresses.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ import (
7777
// multiple addresses to the same lists of server blocks (a many:many mapping).
7878
// (Doing this is essentially a map-reduce technique.)
7979
func (st *ServerType) mapAddressToServerBlocks(originalServerBlocks []serverBlock,
80-
options map[string]any) (map[string][]serverBlock, error) {
80+
options map[string]any,
81+
) (map[string][]serverBlock, error) {
8182
sbmap := make(map[string][]serverBlock)
8283

8384
for i, sblock := range originalServerBlocks {
@@ -187,7 +188,8 @@ func (st *ServerType) consolidateAddrMappings(addrToServerBlocks map[string][]se
187188
// listenerAddrsForServerBlockKey essentially converts the Caddyfile
188189
// site addresses to Caddy listener addresses for each server block.
189190
func (st *ServerType) listenerAddrsForServerBlockKey(sblock serverBlock, key string,
190-
options map[string]any) ([]string, error) {
191+
options map[string]any,
192+
) ([]string, error) {
191193
addr, err := ParseAddress(key)
192194
if err != nil {
193195
return nil, fmt.Errorf("parsing key: %v", err)

caddyconfig/httpcaddyfile/directives.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ func (h Helper) ExtractMatcherSet() (caddy.ModuleMap, error) {
217217

218218
// NewRoute returns config values relevant to creating a new HTTP route.
219219
func (h Helper) NewRoute(matcherSet caddy.ModuleMap,
220-
handler caddyhttp.MiddlewareHandler) []ConfigValue {
220+
handler caddyhttp.MiddlewareHandler,
221+
) []ConfigValue {
221222
mod, err := caddy.GetModule(caddy.GetModuleID(handler))
222223
if err != nil {
223224
*h.warnings = append(*h.warnings, caddyconfig.Warning{

caddyconfig/httpcaddyfile/httptype.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ type App struct {
4949
}
5050

5151
// ServerType can set up a config from an HTTP Caddyfile.
52-
type ServerType struct {
53-
}
52+
type ServerType struct{}
5453

5554
// Setup makes a config from the tokens.
5655
func (st ServerType) Setup(
@@ -1059,8 +1058,8 @@ func appendSubrouteToRouteList(routeList caddyhttp.RouteList,
10591058
subroute *caddyhttp.Subroute,
10601059
matcherSetsEnc []caddy.ModuleMap,
10611060
p sbAddrAssociation,
1062-
warnings *[]caddyconfig.Warning) caddyhttp.RouteList {
1063-
1061+
warnings *[]caddyconfig.Warning,
1062+
) caddyhttp.RouteList {
10641063
// nothing to do if... there's nothing to do
10651064
if len(matcherSetsEnc) == 0 && len(subroute.Routes) == 0 && subroute.Errors == nil {
10661065
return routeList
@@ -1608,8 +1607,10 @@ type sbAddrAssociation struct {
16081607
serverBlocks []serverBlock
16091608
}
16101609

1611-
const matcherPrefix = "@"
1612-
const namedRouteKey = "named_route"
1610+
const (
1611+
matcherPrefix = "@"
1612+
namedRouteKey = "named_route"
1613+
)
16131614

16141615
// Interface guard
16151616
var _ caddyfile.ServerType = (*ServerType)(nil)

caddyconfig/httpcaddyfile/pkiapp.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ func (st ServerType) buildPKIApp(
174174
options map[string]any,
175175
warnings []caddyconfig.Warning,
176176
) (*caddypki.PKI, []caddyconfig.Warning, error) {
177-
178177
skipInstallTrust := false
179178
if _, ok := options["skip_install_trust"]; ok {
180179
skipInstallTrust = true

caddyconfig/httpcaddyfile/tlsapp.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ func (st ServerType) buildTLSApp(
3636
options map[string]any,
3737
warnings []caddyconfig.Warning,
3838
) (*caddytls.TLS, []caddyconfig.Warning, error) {
39-
4039
tlsApp := &caddytls.TLS{CertificatesRaw: make(caddy.ModuleMap)}
4140
var certLoaders []caddytls.CertificateLoader
4241

0 commit comments

Comments
 (0)