fjl / gencodec

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

Remove <rootpath>/vendor/ prefix from vendored packages #9

Open dimroc opened 6 years ago

dimroc commented 6 years ago

Fixes https://github.com/fjl/gencodec/issues/8


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

Source

package store

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

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

type Log struct {
    Address common.Address `json:"address" gencodec:"required"`
    // list of topics provided by the contract.
    Topics []common.Hash `json:"topics" gencodec:"required"`
    // supplied by the contract, usually ABI-encoded
    Data []byte `json:"data" gencodec:"required"`
}

type logMarshaling struct {
    Data hexutil.Bytes
}

Before

// 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"
)

...

Now

// 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"
)

...

It has been difficult to reproduce the error in the test suite because this project does not use golang/dep to vendor dependencies.

fjl commented 5 years ago

Sorry, I've been really slow catching up with GH notifications. I don't think this is a good solution. We should try to remove the use of goimports instead.