github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/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 See [the main README](https://github.com/dominikh/go-tools#installation) for installation instructions. 7 8 ## Usage 9 10 Call keyify with a position such as `/some/file.go:#5`, where #5 is 11 the byte offset in the file and has to point at or into a struct 12 literal. 13 14 By default, keyify will print the new literal on stdout, formatted as 15 Go code. By using the `-json` flag, it will print a JSON object 16 denoting the start and end of the original literal, and its 17 replacement. This is useful for integration with editors. 18 19 For a description of all available flags, see `keyify -help`. 20 21 ### Emacs 22 23 For Emacs integration, add the following to your `.emacs` file: 24 25 ``` 26 (add-to-list 'load-path "/your/gopath/src/github.com/amarpal/go-tools/cmd/keyify) 27 (eval-after-load 'go-mode 28 (lambda () 29 (require 'go-keyify))) 30 ``` 31 32 With point on or in a struct literal, call the `go-keyify` command. 33 34 ![gif of keyify](http://stuff.fork-bomb.org/keyify.gif)