dmarkham / enumer

A Go tool to auto generate methods for your enums
Other
410 stars 66 forks source link

Fork force use for go generate #45

Closed abonec closed 2 years ago

abonec commented 3 years ago

Now we have two libraries with similar features but not the same. And when I add annotations like

//go:generate enumer -type=From -json -transform=snake

Binary can be from any of them and result can be different. Is there any way to make sure that code will be generated only by your binary? For example, add different binary name for ensure or some other tricks that provide incompatibility with original version?

dmarkham commented 3 years ago

I like to add a "Dummy" package like this

// +build tools
// tools is a dummy package that will be ignored for builds, but included for dependencies
package tools
import (
    _ "github.com/dmarkham/enumer"
)

Then in my go.mod file I can pin a version

github.com/dmarkham/enumer v1.5.3

Then I can run go:generate like this.

//go:generate go run github.com/dmarkham/enumer  -type=From -json -transform=snake
dmarkham commented 2 years ago

Let me know how this works for you.

abonec commented 2 years ago

It is works, but Goland can't recognize that hack =( image