Repository: caddyserver/caddy (language: go)

Issue:
why not change the type map[string]bool to map[string]struct{} in importgraph.go file
i would like to propose a tiny code improvement, where we can change the **map[string]bool** type inside importgraph.go file to **map[string]struct{}** type and treat the nodes field of the **importGraph** struct just like a set.
![caddy](https://github.com/caddyserver/caddy/assets/35922417/6f0bdd65-4228-426f-a3f3-2a3c209e17c8)




Discussion / hints:
What's the gain? The entire structure is internal
@mohammed90 you are absolutely right , didn't think too much about it 


Without looking I don't remember the purpose of the `bool` -- if it's just for syntactic sugar, then sure, a `struct{}` could be used. [This prevents an allocation.](https://gist.github.com/davecheney/3be245c92b61e5045f75?permalink_comment_id=2671632#gistcomment-2671632)

Not sure if it matters here. Maybe on huuuuge Caddyfiles.
@mholt Yes it is a **syntactic sugar**, using the bool the author is trying to create a **quasi set**, **struct{}** would be better, just like you rightly said it prevents an unnecessary allocation. if you want me to make a change please comment, I would be happy to open a **pull request**.
I think the gain is minimal; I have no opinion either way. If a PR is created I'd probably be fine with it, but I'm OK with it as-is too.

Fix patch:
diff --git a/caddyconfig/caddyfile/importgraph.go b/caddyconfig/caddyfile/importgraph.go
index d27f4710bd9..d5037fe6232 100644
--- a/caddyconfig/caddyfile/importgraph.go
+++ b/caddyconfig/caddyfile/importgraph.go
@@ -21,18 +21,18 @@ import (
 type adjacency map[string][]string
 
 type importGraph struct {
-	nodes map[string]bool
+	nodes map[string]struct{}
 	edges adjacency
 }
 
 func (i *importGraph) addNode(name string) {
 	if i.nodes == nil {
-		i.nodes = make(map[string]bool)
+		i.nodes = make(map[string]struct{})
 	}
 	if _, exists := i.nodes[name]; exists {
 		return
 	}
-	i.nodes[name] = true
+	i.nodes[name] = struct{}{}
 }
 
 func (i *importGraph) addNodes(names []string) {
@@ -66,7 +66,7 @@ func (i *importGraph) addEdge(from, to string) error {
 	}
 
 	if i.nodes == nil {
-		i.nodes = make(map[string]bool)
+		i.nodes = make(map[string]struct{})
 	}
 	if i.edges == nil {
 		i.edges = make(adjacency)
diff --git a/caddyconfig/caddyfile/parse.go b/caddyconfig/caddyfile/parse.go
index 9f79d913a88..cdb9a7619f7 100644
--- a/caddyconfig/caddyfile/parse.go
+++ b/caddyconfig/caddyfile/parse.go
@@ -50,7 +50,7 @@ func Parse(filename string, input []byte) ([]ServerBlock, error) {
 	p := parser{
 		Dispenser: NewDispenser(tokens),
 		importGraph: importGraph{
-			nodes: make(map[string]bool),
+			nodes: make(map[string]struct{}),
 			edges: make(adjacency),
 		},
 	}


Test patch: