fjl / gencodec

Command gencodec generates marshaling methods for Go struct types.
MIT License
54 stars 26 forks source link

gencodec generates vendored import path instead of regular path #8

Open dimroc opened 5 years ago

dimroc commented 5 years ago

When running go generate ./..., gencodec writes the vendored import paths rather than the correct ones:

As seen here where we are using golang/dep to vendor our dependencies: https://github.com/smartcontractkit/chainlink/pull/680#issuecomment-432803279

Source

//go:generate gencodec -dir . -type Log -field-override logMarshaling -out gen_log_json.go

// Log represents a contract log event. These events are generated by the LOG opcode and
// stored/indexed by the node.
type Log struct {
...

Current Behavior

// Code generated by github.com/fjl/gencodec. DO NOT EDIT.

package store

import (
    "encoding/json"
    "errors"

    "github.com/smartcontractkit/chainlink/vendor/github.com/ethereum/go-ethereum/common"
    "github.com/smartcontractkit/chainlink/vendor/github.com/ethereum/go-ethereum/common/hexutil"
)

...

Expected behavior

// Code generated by github.com/fjl/gencodec. DO NOT EDIT.

package store

import (
    "encoding/json"
    "errors"

    "github.com/ethereum/go-ethereum/common"
    "github.com/ethereum/go-ethereum/common/hexutil"
)

...
dimroc commented 5 years ago

Seems to stem from:

https://github.com/fjl/gencodec/blob/master/main.go#L216

https://godoc.org/golang.org/x/tools/imports#Process