We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bedfad9 commit aead067Copy full SHA for aead067
pkg/uid/uid.go
@@ -6,6 +6,7 @@ import (
6
"os"
7
"path/filepath"
8
"strings"
9
+ "sync"
10
11
"github.com/carapace-sh/carapace/internal/pflagfork"
12
"github.com/spf13/cobra"
@@ -38,8 +39,17 @@ func reverse(s []string) {
38
39
}
40
41
42
+var flagMutex sync.RWMutex
43
+
44
// Flag creates a uid for given flag.
45
func Flag(cmd *cobra.Command, flag *pflagfork.Flag) *url.URL {
46
+ // TODO dirty quickfix to avoid concurrent map write when modifying the `formal` map in FlagSet.AddFlag (#1182)
47
+ flagMutex.Lock()
48
+ defer flagMutex.Unlock()
49
50
+ if cmd.LocalFlags().Lookup(flag.Name) == nil && cmd.HasParent() {
51
+ return Flag(cmd.Parent(), flag)
52
+ }
53
uid := Command(cmd)
54
values := uid.Query()
55
values.Set("flag", flag.Name)
0 commit comments