Skip to content

Commit f938530

Browse files
committed
codestyle: fix codestyle issues
1 parent 5757d59 commit f938530

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

formatter/formatter_d2.go

+12-10
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ import (
1515
"oss.terrastruct.com/d2/lib/textmeasure"
1616
)
1717

18+
// D2LangFormatter is struct defined for D2 Language Output use-case
1819
type D2LangFormatter struct {
1920
config *Config
2021
}
2122

23+
// Format the data to D2 Language and output it to a D2 Language file
2224
func (f *D2LangFormatter) Format(td *TemplateData, templateContent string) (err error) {
2325
ruler, _ := textmeasure.NewRuler()
2426
layoutResolver := func(engine string) (d2graph.LayoutGraph, error) {
@@ -50,22 +52,22 @@ func (f *D2LangFormatter) Format(td *TemplateData, templateContent string) (err
5052
return err
5153
}
5254

53-
hostId := hex.EncodeToString(fnv.Sum(nil))
54-
graph, _, _ = d2oracle.Create(graph, nil, hostId)
55-
graph, _ = d2oracle.Set(graph, nil, hostId+".label", nil, &hostLabel)
56-
graph, _ = d2oracle.Set(graph, nil, "nmap -> "+hostId, nil, nil)
55+
hostID := hex.EncodeToString(fnv.Sum(nil))
56+
graph, _, _ = d2oracle.Create(graph, nil, hostID)
57+
graph, _ = d2oracle.Set(graph, nil, hostID+".label", nil, &hostLabel)
58+
graph, _ = d2oracle.Set(graph, nil, "nmap -> "+hostID, nil, nil)
5759

5860
for j := range host.Port {
5961
port := &host.Port[j]
60-
portId := fmt.Sprintf("%s-port%d", hostId, port.PortID)
61-
graph, _, _ = d2oracle.Create(graph, nil, portId)
62+
portID := fmt.Sprintf("%s-port%d", hostID, port.PortID)
63+
graph, _, _ = d2oracle.Create(graph, nil, portID)
6264
portLabel := fmt.Sprintf("%d/%s\n%s\n%s", port.PortID, port.Protocol, port.State.State, port.Service.Name)
63-
graph, _ = d2oracle.Set(graph, nil, portId+".label", nil, &portLabel)
65+
graph, _ = d2oracle.Set(graph, nil, portID+".label", nil, &portLabel)
6466
shape := "circle"
65-
graph, _ = d2oracle.Set(graph, nil, portId+".shape", nil, &shape)
67+
graph, _ = d2oracle.Set(graph, nil, portID+".shape", nil, &shape)
6668
width := "25"
67-
graph, _ = d2oracle.Set(graph, nil, portId+".width", nil, &width)
68-
graph, _ = d2oracle.Move(graph, nil, portId, hostId+"."+portId, true)
69+
graph, _ = d2oracle.Set(graph, nil, portID+".width", nil, &width)
70+
graph, _ = d2oracle.Move(graph, nil, portID, hostID+"."+portID, true)
6971
}
7072
}
7173
_, err = f.config.Writer.Write([]byte(d2format.Format(graph.AST)))

0 commit comments

Comments
 (0)