I host my repos on my own server without a code hosting software like gitlab or gitea. When I try to init a project as module I get this error.
hugo mod init firstname.lastname@example.org:hugoexample.git
go: malformed module path "email@example.com:hugoexample.git": invalid char '@'
A similar question was asked here but in Github context.
Is it possible to use a normal git repository at all?
Is your repo public? If so, would you mind posting your test repo link here?
The module path is typically the URL of you repo (without protocol), e.g.
hugo mod init myserver.net/hugoexample
You will see the
go-import meta in your repo page.
$ curl https://github.com/hugomods/images?go-get=1 | grep go-import
<meta name="go-import" content="github.com/hugomods/images git https://github.com/hugomods/images.git">
$ curl https://codeberg.org/razonyang/hugo-mod-hello.git?go-get=1 | grep go-import
<meta name="go-import" content="codeberg.org/razonyang/hugo-mod-hello git https://codeberg.org/razonyang/hugo-mod-hello.git.git">
If your repo is private, I’d suggest
- creating a test public repo for making sure everything is OK on your self-hosted Git server,
- and then create your private repo, to see how to authenticate with your self-hosted Git server.
.netrc on my workflow to authenticate with GitHub for my private modules, you may find more approaches on Google with
go modules private repo.
// my build script
echo "machine github.com login $GITHUB_USER password $GITHUB_TOKEN" >> $HOME/.netrc
I only have ssh access to the repo, no https.
@razon is right – the above is correct. Any authentication (e.g. username) needs to live elsewhere, e.g. in your Git config:
insteadOf = myserver.net