Search code examples
goaws-sdk-go

Build dependencis for aws-sdk-go fails on Go version 1.13


I have been trying to build a module on Go v1.13 with dependencies on github.com/aws/aws-lambda-go and github.com/aws/aws-sdk-go which fail on the two imports:

    "github.com/aws/aws-sdk-go/aws/service/s3"
    "github.com/aws/aws-sdk-go/aws/service/s3/s3manager"

The stderr is as follows for GOOS=linux GOARCH=amd64 go build -o dist/api ./api where the api directory contains my module definition:

api/main.go:11:2: cannot find package "github.com/aws/aws-sdk-go/aws/service/s3" in any of:
        /usr/local/go/src/github.com/aws/aws-sdk-go/aws/service/s3 (from $GOROOT)
        /u/go/src/github.com/aws/aws-sdk-go/aws/service/s3 (from $GOPATH)
api/main.go:12:2: cannot find package "github.com/aws/aws-sdk-go/aws/service/s3/s3manager" in any of:
        /usr/local/go/src/github.com/aws/aws-sdk-go/aws/service/s3/s3manager (from $GOROOT)
        /u/go/src/github.com/aws/aws-sdk-go/aws/service/s3/s3manager (from $GOPATH)

Honestly, I have no clue why this is happening and any inputs would be appreciated.

Already tried using go get to ensure that the dependencies have been pulled:

$ go get github.com/aws/aws-sdk-go

and the requested import paths are present under $GOPATH/src/github.com/aws/aws-sdk/go/aws/service/s3 and $GOPATH/src/github.com/aws/aws-sdk/go/aws/service/s3/s3manager

Also, tried clearing the cache using go clean --cache --modcache whilst removing previously pulled modules.

On closer inspection, something that I completely overlooked, the import path is /u/go/src/github.com/aws/aws-sdk-go/aws/service/s3 instead of /u/go/src/github.com/aws/aws-sdk-go/service/s3 with the former having an additional aws subpath inside aws-sdk-go.


Solution

  • Just realized the copy/paste error I had made in the code.

    import (
        "github.com/aws/aws-sdk-go/aws/service/s3"
        "github.com/aws/aws-sdk-go/aws/service/s3/s3manager"
    )
    

    instead of

    import (
        "github.com/aws/aws-sdk-go/service/s3"
        "github.com/aws/aws-sdk-go/service/s3/s3manager"
    )