Fix referencing TVL as a go module

#299
Opened by flokli at 2023-09-09T12·27+00

@brianmcgee wanted to use the generated tvix-store proto bindings present at tvix/store/protos from outside the monorepo, similar to something like that:

package main

import (
	storepb "code.tvl.fyi/tvix/store/protos"
)

func main() {
	_ := storepb.StatBlobRequest{}
}

Unfortunately, go get fails because cgit is no git repo directly:

go get code.tvl.fyi/tvix/store/protos
go: unrecognized import path "code.tvl.fyi/tvix/store/protos": reading https://code.tvl.fyi/tvix/store/protos?go-get=1: 404 Not Found

The repo is reachable via http at https://code.tvl.fyi/depot.git, so a go get code.tvl.fyi/depot.git/tvix/store/protos via http might work, but it takes a lot of time (as it's a full repo clone), and then we stumble on the differing parts in go.mod.

Maybe we can solve this by using some josh-based paths in go.mod?

  1. Relevant: https://pkg.go.dev/cmd/go#hdr-Remote_import_paths

    tazjin at 2023-09-09T20·00+00

  2. According to those docs, go will prevent using something like josh by verifying that the repo is static for the root of a domain as well as the sub paths for modules.

    Might be possible to work around that by first redirecting to the Go module proxy stuff, and doing it there, but this is way too much code to write already imo.

    tazjin at 2023-09-09T20·06+00

  3. It might be this would only bite us if there's nested go.mod files, at least it doesn't seem to be an issue for cloning code.tvl.fyi/tvix/store/protos.

    flokli at 2023-09-10T11·17+00

  4. Fixed in https://cl.tvl.fyi/c/depot/+/9290.

    flokli at 2023-09-10T11·19+00

  5. flokli closed this issue at 2023-09-10T13·14+00