Unexported embedded struct with skip-unexported option is still tagged
eduhenke opened this issue · 3 comments
eduhenke commented
Input:
type stationEvent struct{}
type StationConnectorUnplugged struct {
stationEvent
ConnectorID int
MeterStop int
TransactionID int32
ChargingCardID identifier.ChargingCardID
Timestamp time.Time `json:"timestamp`
}
Output:
type stationEvent struct{}
type StationConnectorUnplugged struct {
stationEvent `json:"stationEvent"`
ConnectorID int `json:"connectorID"`
MeterStop int `json:"meterStop"`
TransactionID int32 `json:"transactionID"`
ChargingCardID identifier.ChargingCardID `json:"chargingCardID"`
Timestamp time.Time `json:"timestamp`
}
Expected:
type stationEvent struct{}
type StationConnectorUnplugged struct {
stationEvent
ConnectorID int `json:"connectorID"`
MeterStop int `json:"meterStop"`
TransactionID int32 `json:"transactionID"`
ChargingCardID identifier.ChargingCardID `json:"chargingCardID"`
Timestamp time.Time `json:"timestamp`
}
fatih commented
Thank you for opening the issue. Can you please give me the command line arguments (that you passed to gomodifytags
) with the exact content, including the package name ? That would help me to better test and see the issue.
eduhenke commented
Sure!
// file.go
package event
type StationEvent interface {
DomainEvent
isStationEvent()
}
type stationEvent struct{}
func (evt stationEvent) isStationEvent() {}
type StationCreated struct {
stationEvent
ID int `json:"id"`
Name string `json:"name"`
}
Command:
go run github.com/fatih/gomodifytags -file file.go -line 1,100000 -add-tags json -transform camelcase --skip-unexported
Output:
package event
type StationEvent interface {
DomainEvent
isStationEvent()
}
type stationEvent struct{}
func (evt stationEvent) isStationEvent() {}
type StationCreated struct {
stationEvent `json:"stationEvent"`
ID int `json:"id"`
Name string `json:"name"`
}