Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ $ go run .
Hello World

--------------------------------------------------------------------------------
Go Version: go1.24.4
Go Version: go1.24.9

```

Expand Down Expand Up @@ -160,7 +160,7 @@ $ go run .
Hello World

--------------------------------------------------------------------------------
Go Version: go1.24.4
Go Version: go1.24.9

```

Expand Down Expand Up @@ -189,7 +189,7 @@ $ go run .
Hello World

--------------------------------------------------------------------------------
Go Version: go1.24.4
Go Version: go1.24.9

```

Expand Down Expand Up @@ -219,7 +219,7 @@ $ go run .
./main.go:7:6: undefined: fmt.Prin

--------------------------------------------------------------------------------
Go Version: go1.24.4
Go Version: go1.24.9

```

Expand Down Expand Up @@ -256,7 +256,7 @@ type Context interface{ ... }
func WithoutCancel(parent Context) Context

--------------------------------------------------------------------------------
Go Version: go1.24.4
Go Version: go1.24.9

```

Expand All @@ -279,7 +279,7 @@ func WithCancel(parent Context) (ctx Context, cancel CancelFunc)
call cancel as soon as the operations running in this Context complete.

--------------------------------------------------------------------------------
Go Version: go1.24.4
Go Version: go1.24.9

```

Expand Down
23 changes: 21 additions & 2 deletions document.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,31 @@ func (doc *Document) MarshalJSON() ([]byte, error) {
return nil, ErrIsNil("document")
}

// Create sorted maps to ensure deterministic JSON output
sortedRules := make(map[string]string)
if doc.Snippets.rules != nil {
for k, v := range doc.Snippets.rules {
sortedRules[k] = v
}
}

sortedSnippets := make(map[string]map[string]Snippet)
if doc.Snippets.snippets != nil {
for k, v := range doc.Snippets.snippets {
innerMap := make(map[string]Snippet)
for ik, iv := range v {
innerMap[ik] = iv
}
sortedSnippets[k] = innerMap
}
}

snips := struct {
Rules map[string]string `json:"rules,omitempty"`
Snippets map[string]map[string]Snippet `json:"snippets,omitempty"`
}{
Rules: doc.Snippets.rules,
Snippets: doc.Snippets.snippets,
Rules: sortedRules,
Snippets: sortedSnippets,
}

x := struct {
Expand Down
Loading