github.com/golangci/go-tools@v0.0.0-20190318060251-af6baa5dc196/cmd/keyify/README.md (about) 1 Keyify turns unkeyed struct literals (`T{1, 2, 3}`) into keyed 2 ones (`T{A: 1, B: 2, C: 3}`) 3 4 ## Installation 5 6 Keyify requires Go 1.6 or later. 7 8 go get github.com/golangci/go-tools/cmd/keyify 9 10 ## Usage 11 12 Call keyify with a position such as `/some/file.go:#5`, where #5 is 13 the byte offset in the file and has to point at or into a struct 14 literal. 15 16 By default, keyify will print the new literal on stdout, formatted as 17 Go code. By using the `-json` flag, it will print a JSON object 18 denoting the start and end of the original literal, and its 19 replacement. This is useful for integration with editors. 20 21 For a description of all available flags, see `keyify -help`. 22 23 ### Emacs 24 25 For Emacs integration, add the following to your `.emacs` file: 26 27 ``` 28 (add-to-list 'load-path "/your/gopath/src/github.com/golangci/go-tools/cmd/keyify) 29 (eval-after-load 'go-mode 30 (lambda () 31 (require 'go-keyify))) 32 ``` 33 34 With point on or in a struct literal, call the `go-keyify` command. 35 36 ![gif of keyify](http://stuff.fork-bomb.org/keyify.gif)