title: main.go:11:8: package aerospike_shared is not in GOROOT (/usr/local/go/src/aerospike_shared)
body: <p>I've been searching for the whole day what's happening in here and it's seems to be it should work without a problem according to Docker and golang documentation.</p>
  
  <p><strong>First of all the error:</strong></p>
  
  <pre><code>holms@debian ~/D/c/s/app-prebid-config&gt; compose -f compose.yml build app-prebid-config
  Building app-prebid-config
  Step 1/11 : FROM golang:1.14-alpine as dev
   ---&gt; 51e47ee4db58
  Step 2/11 : RUN apk update &amp;&amp; apk upgrade &amp;&amp; apk add --no-cache bash git
   ---&gt; Using cache
   ---&gt; 8ddb9b995df8
  Step 3/11 : RUN mkdir -p /app/prebid-config
   ---&gt; Using cache
   ---&gt; 4c1e8f03b27c
  Step 4/11 : WORKDIR /app/prebid-config
   ---&gt; Using cache
   ---&gt; 25104c791d7e
  Step 5/11 : RUN go mod init setupad.com/prebid-config
   ---&gt; Using cache
   ---&gt; 0b64b735c1f1
  Step 6/11 : RUN go mod download
   ---&gt; Using cache
   ---&gt; 7170aa6447c9
  Step 7/11 : RUN go mod vendor
   ---&gt; Using cache
   ---&gt; 0bbc220e43b9
  Step 8/11 : COPY . .
   ---&gt; Using cache
   ---&gt; 9d5ab625ccd0
  Step 9/11 : RUN go get -d -v ./...
   ---&gt; Using cache
   ---&gt; d4057dd0d9a7
  Step 10/11 : RUN go install -v ./...
   ---&gt; Running in c5b7a8cbc33e
  main.go:11:8: package aerospike_shared is not in GOROOT (/usr/local/go/src/aerospike_shared)
  ERROR: Service 'app-prebid-config' failed to build: The command '/bin/sh -c go install -v ./...' returned a non-zero code: 1
  </code></pre>
  
  <p><strong>Dockerfile:</strong></p>
  
  <pre><code>holms@debian ~/D/c/s/a/app&gt; cat Dockerfile 
  FROM golang:1.14-alpine as dev
  
  ENV GO111MODULE=auto
  ENV CGO_ENABLED=0
  ENV GOOS=linux
  
  RUN apk update &amp;&amp; apk upgrade &amp;&amp; apk add --no-cache bash git
  
  RUN mkdir -p /app/prebid-config
  WORKDIR /app/prebid-config
  
  COPY go.mod  .
  RUN go mod download
  COPY . .
  RUN go get -d -v ./...
  RUN go install -v ./...
  RUN go build -a -installsuffix cgo -o app .
  
  FROM alpine:latest as prod
  RUN apk --no-cache add ca-certificates
  COPY --from=dev /app/app /app
  EXPOSE 8080
  CMD ["/app"]
  </code></pre>
  
  <p><strong>Code it self:</strong></p>
  
  <pre><code>holms@debian ~/D/c/s/a/app&gt; tree
  .
  ├── aerospike_shared
  │   └── client.go
  ├── Dockerfile
  └── main.go
  
  1 directory, 3 files
  </code></pre>
  
  <p><strong>main.go</strong></p>
  
  <pre><code>holms@debian ~/D/c/s/a/app&gt; cat main.go
  package main
  
  import (
          "net/http"
  
          "github.com/labstack/echo/v4"
          "github.com/labstack/echo/v4/middleware"
          "github.com/labstack/gommon/log"
  )
  
  import "aerospike_shared"
  
  func main() {
  
          // Echo instance
          e := echo.New()
          e.Logger.SetLevel(log.ERROR)
          e.Use(middleware.Logger())
  
          e.GET("/", func(c echo.Context) error {
                  return c.String(http.StatusOK, "Hello, World!")
          })
  
          // Connect to Aerospike
          a = aerospike_shared.client
  
          // Start server
          e.Logger.Fatal(e.Start(":1323"))
  }
  </code></pre>
  
  <p><strong>aerospike_shared/client.go</strong></p>
  
  <pre><code>holms@debian ~/D/c/s/a/app&gt; cat aerospike_shared/client.go
  package aerospike_shared
  
  import (
          "bytes"
          "fmt"
          "log"
          "math"
          "os"
          "runtime"
          "strconv"
  
          as "github.com/aerospike/aerospike-client-go"
  )
  
  var WritePolicy = as.NewWritePolicy(0, 0)
  var Policy = as.NewPolicy()
  
  var Host = os.Getenv("AEROSPIKE_HOST")
  var Port, PortErr = strconv.Atoi(os.Getenv("AEROSPIKE_PORT"))
  
  var Namespace = "prebid"
  var Set = "prebid_configs"
  
  var client *as.Client
  
  func main() {
          // use all cpus in the system for concurrency
          runtime.GOMAXPROCS(runtime.NumCPU())
  
          log.SetOutput(os.Stdout)
  
          var err error
          client, err = as.NewClient(Host, Port)
          if err != nil {
                  PanicOnError(err)
          }
  }
  
  func PanicOnError(err error) {
          if err != nil {
                  log.Fatalln(err.Error())
          }
  }
  </code></pre>