# Caching go modules

**URL:** <https://drone.discourse.group/t/caching-go-modules/10778>\
**Category:** Drone Support\
**Created:** [May 4, 2019, 3:35pm UTC](https://drone.discourse.group/t/caching-go-modules/10778 "2019-05-04T15:35:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luis](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/luis/32/4291_2.png) [@Luis](https://drone.discourse.group/u/Luis)\
**Post date:** [May 4, 2019, 3:35pm UTC](https://drone.discourse.group/t/caching-go-modules/10778/1 "2019-05-04T15:35:14Z")

</div>

I’m using go mod, and I want to use S3 cache plugin to speed up the build step. I’ve tried to use `go mod vendor` command after finishing the build to make a vendor dir in the workdir, so i can mount and cache the vendor dir using the cache plugin. But it seems have to download dependency every time when i execute the `go mod vendor`. I can’t find anyone is discussing related topic, am I going the wrong direction?

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [May 4, 2019, 4:32pm UTC](https://drone.discourse.group/t/caching-go-modules/10778/2 "2019-05-04T16:32:10Z")

</div>

Hi Luis, it may be helpful to provide a copy of your yaml so that people can see what you are doing and advise according.

> [@On another topic](https://drone.discourse.group/t/4507/1):
>
> to make a vendor dir in the workdir, so i can mount and cache the vendor dir using the cache plugin

Copying folders into the workspace for caching purposes is not longer required as of drone 1.0. Instead, you can mount a temporary volume outside of the workspace at the go module path. Example mounting a temporary volume here [https://docs.drone.io/examples/language/golang/#dependencies](https://docs.drone.io/examples/language/golang/#dependencies)

---

<div class="post-metadata">

**Author:** ![Luis](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/luis/32/4291_2.png) [@Luis](https://drone.discourse.group/u/Luis)\
**Post date:** [May 5, 2019, 3:36pm UTC](https://drone.discourse.group/t/caching-go-modules/10778/3 "2019-05-05T15:36:09Z")

</div>

Hi Brad, here is my yaml. The cache plugin is similar to the s3 cache plugin, china can’t use aws, the oss is the same as aws s3.

```auto
kind: pipeline
name: default

platform:
  os: linux
  arch: amd64

steps:
  - name: restore
    image: luischan/drone-oss-cache
    pull: always
    settings:
      endpoint: ENDPOINT
      debug: true
      access_key:
        from_secret: oss_ak
      secret_key:
        from_secret: oss_sk
      restore: true
      bucket: drone-build-cache

  - name: build
    image: golang:1.12.4-alpine3.9
    commands:
      - "go build -o sever main.go"
      - go mod vendor
    environment:
      CGO_ENABLED: 0
      GOPROXY: https://someproxy.com

  - name: rebuild
    image: luischan/drone-oss-cache
    pull: always
    settings:
      endpoint: ENDPOINT
      access_key:
        from_secret: oss_ak
      secret_key:
        from_secret: oss_sk
      rebuild: true
      bucket: drone-build-cache
      debug: true
      mount:
        - vendor

  - name: docker
    image: plugins/docker
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      registry: REGISTRY
      repo: REGISTRY/some
      tags:
        - dev

```

I look the link you gave, it looks good for docker compose. I have a three instance k8s cluster, and it don’t know which node will spin up and do the job, any ideas?
