Skip to content

go-import meta tag should not be rendered when accessing a non-repository url

Summary

According to https://golang.org/cmd/go/#hdr-Relative_import_paths, a HTML should contains go-import meta tag for golang tools:

The meta tag has the form:

<meta name="go-import" content="import-prefix vcs repo-root"> The import-prefix is the import path corresponding to the repository root.

However, when accessing a non-root url, for example, https://gitlab.com/israelazo?go-get=1, the meta tag will still be rendered, which is inappropriate, because gitlab.com/israelazo is actually not a repo root and https://gitlab.com/israelazo.git doesn't exist at all.

image

This issue will affect one tool written by me, in which I need to know where is the repository root. Is there any workarounds or configurations so I can configure my own gitlab?

Steps to reproduce

Access any url+?go-get=1, e.g. https://gitlab.com/israelazo?go-get=1

What is the current bug behavior?

See above.

What is the expected correct behavior?

When accessing a non-repository url, do not render go-import tag.

Relevant logs and/or screenshots

See above.

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Results of GitLab application Check

Possible fixes

Edited by Bo Zhang