juh2
1
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 juh@myserver.net:hugoexample.git
go: malformed module path "juh@myserver.net: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?
razon
2
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. myserver.net/hugoexample
.
hugo mod init myserver.net/hugoexample
You will see the go-import
meta in your repo page.
Some examples.
$ 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">
...
Some references:
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.
I use .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
hugo
juh2
3
I only have ssh access to the repo, no https.
bep
4
@razon is right – the above is correct. Any authentication (e.g. username) needs to live elsewhere, e.g. in your Git config:
[url "ssh://juh@myserver.net"]
insteadOf = myserver.net
Or something.
1 Like