cloudflare / cloudflare/cfssl

Issues with interfaces using vendored code

Open
#811 4 comments 2 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
9.5k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Since cfssl includes a vendor directory, if I have an external application that attempts to implement cfssl's Source interface like so:
```go
import (
"crypto"
"crypto/x509"
cfocsp "github.com/cloudflare/cfssl/ocsp"
"golang.org/x/crypto/ocsp"
)
type SimpleSource struct {
responder *x509.Certificate
key crypto.Signer
status int
ttl time.Duration
}

func (src *SimpleSource) Response(request *ocsp.Request) ([]byte, http.Header, error) {
// ...
}
```
the compiler complains about the following:
```
./main.go:122:2: cannot use src (type SimpleSource) as type "github.com/cloudflare/cfssl/ocsp".Source in return argument:
SimpleSource does not implement "github.com/cloudflare/cfssl/ocsp".Source (wrong type for Response method)
have Response(*"golang.org/x/crypto/ocsp".Request) ([]byte, http.Header, error)
want Response(*"github.com/cloudflare/cfssl/vendor/golang.org/x/crypto/ocsp".Request) ([]byte, http.Header, error)
```
If I remove the vendor directory from cfssl, it works.

In general, Go libraries **should not** use vendor directories. Vendor directories should only be used by applications.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.