1

I have a repository with a Go project in Github, I need to import in a module a specific branch, to make relevant modifications. It looks like this:

import (
    "github.com/repository/utils/date_utils"
    "github.com/repository/utils/utils/error_utils"
    "github.com/repository/utils/utils/hour_utils"
    "strconv"
    "strings"
)

The import is always done directly from the master. I just need this module to import from a different branch.

Eathekilla
  • 37
  • 4

1 Answers1

5

you can use

go get <path-to-repo>@<branch>

From documentation

Get resolves its command-line arguments to packages at specific module versions, updates go.mod to require those versions, downloads source code into the module cache, then builds and installs the named packages

Also this particular line on the documentation is interesting as-well.

Using a branch name such as go get foo@master (foo@default with mercurial) is one way to obtain the latest commit regardless of whether or not it has a semver tag.

  • Can I mod directly from de repository? de go.mod an then the module? I can´t use a command line. I'm sorry I'm new using go – Eathekilla Jul 31 '21 at 16:49