github.com/benma/gogen@v0.0.0-20160826115606-cf49914b915a/cmd/gospecific/README.md (about)

     1  # gospecific
     2  
     3  Avoid using generic packages with `interface{}` by generating specific
     4  packages that can be used with safe types.
     5  
     6  # Usage
     7  
     8  Install gospecific
     9  
    10  ```go
    11  go get github.com/ernesto-jimenez/gogen/cmd/gospecific
    12  ```
    13  
    14  Add a go generate comment to generate a package
    15  
    16  ```go
    17  //go:generate gospecific -pkg=container/list -specific-type=string
    18  ```
    19  
    20  Generate the code
    21  
    22  ```go
    23  go generate
    24  ```
    25  
    26  Now you will have your own `list` package to store strings rather than
    27  `interface{}`
    28  
    29  ```sh
    30  % godoc github.com/ernesto-jimenez/gogen/list | egrep 'func.+string'
    31  ```
    32  
    33  ```go
    34  func (l *List) InsertAfter(v string, mark *Element) *Element
    35  func (l *List) InsertBefore(v string, mark *Element) *Element
    36  func (l *List) PushBack(v string) *Element
    37  func (l *List) PushFront(v string) *Element
    38  func (l *List) Remove(e *Element) string
    39  ```