You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The meta tag should appear as early in the file as possible. In particular, it should appear before any raw JavaScript or CSS, to avoid confusing the go command's restricted parser.
This is not sufficient to have the parser work. The actual requirement is that the HTML page has to follow XML rules until the </head> tag, or some such.
HTML5 does not enforce <head>...</head> to be used, and many HTML minifiers strip it out, leading to the same expected attribute name in element error from encoding/xml even if the meta tag is literally right after doctype and title.
go get chitin.io/chitin fails because of this, because I used https://github.com/tdewolff/minify on it. Yet it's perfectly valid HTML5, and the meta tag is near the beginning.
<!doctype html><title>Chitin – gives structure to your squishy bits</title><meta name=go-import content="chitin.io/chitin git https://github.com/chitin-io/chitin"><style>body{background-color:#ffffea;display:flex;justify-content:center}body>div{flex:1}na ... and so on
IRC conversation made me realize it's worth pointing out that by the time the XML parser fails, go get has already successfully seen the meta tag for the import path it is trying to resolve.
https://golang.org/cmd/go/ since 687925f
says
This is not sufficient to have the parser work. The actual requirement is that the HTML page has to follow XML rules until the
</head>
tag, or some such.HTML5 does not enforce
<head>
...</head>
to be used, and many HTML minifiers strip it out, leading to the sameexpected attribute name in element
error fromencoding/xml
even if the meta tag is literally right afterdoctype
andtitle
.go get chitin.io/chitin
fails because of this, because I used https://github.com/tdewolff/minify on it. Yet it's perfectly valid HTML5, and the meta tag is near the beginning.Here's a HTML5 validator being happy with a sample page (different url because /chitin is a 404, but it has the same meta tags):
https://html5.validator.nu/?doc=https%3A%2F%2Fchitin.io%2F&showsource=yes
The HTML:
See also #8163
The text was updated successfully, but these errors were encountered: