Import a golang module with LFS objects
Asked Answered
H

1

6

I need to import a module with LFS objects into my go project. I already added the module to go.mod, but when the go tools download the dependencies into my ~/go/pkg/... folder, the LFS objects are not downloaded. Instead of the full object, I get the LFS metadata. This causes my build to fail.

I already went through the go get and go mod docs but couldn't find anything on this topic. The only workaround I've found to far is to manually download the files post go mod download, but I'm looking for a more official solution.

Home answered 8/10, 2019 at 6:5 Comment(2)
How did You add LDS module to go.mod? By go get command? DId You use LFS module in Your code? When I add dependencies to my code i make only go get and than I can use this module in code.Janeenjanek
No, in my repo I'm not using LFS. The dependency I want to import into my go project is the one that's using LFS. It's something similar to github.com/coconaut/gobig, but imagine that github.com/coconaut/gobig/blob/master/models/big_binary_1.bin is an actual go class, so it's needed during build.Home
I
2

Assuming go get uses the standard Git commands to download and fetch repositories, it should be sufficient to have installed Git LFS and run git lfs install. That will install the Git filter configuration that Git LFS needs in your per-user Git configuration and then cloning or pulling the changes should result in the proper LFS files being checked out.

You may also want to use the --skip-repo option if you run the command outside of a repository.

Intercolumniation answered 8/10, 2019 at 19:56 Comment(2)
Where does git lfs install needs to be installed? In the repo or is it a computer-wide setting?Home
git lfs install --skip-repo will install its configuration into your ~/.gitconfig, so it can run from anywhere. It's per-user; if you want a system-wide setting, add --system and run it with appropriate privileges.Intercolumniation

© 2022 - 2024 — McMap. All rights reserved.