Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net/html/charset: htmlEncoding incompatibility with x/text/encoding/htmlindex.Name #18949

Open
AsoSunag opened this issue Feb 5, 2017 · 0 comments
Milestone

Comments

@AsoSunag
Copy link

AsoSunag commented Feb 5, 2017

What version of Go are you using (go version)?

$ go version
go version go1.7.3 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/gautiertanguy/work"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/w3/f2rhtgc56jv010vxvkdpvk4m0000gn/T/go-build762276495=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"

What did you do?

Run :

package main

import (
	"fmt"

	"golang.org/x/net/html/charset"
	"golang.org/x/text/encoding/htmlindex"
)

func main() {
	enc, _ := charset.Lookup("UTF-8")
	name, err := htmlindex.Name(enc)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(name)
}

What did you expect to see?

utf-8

What did you see instead?

htmlindex: unknown Encoding

The type assertion in htmlindex.Name(enc) to check if enc is a golang.org/x/text/encoding/internal/identifier.Interfacewill always fail in the above code because here enc is a golang.org/x/net/html/charset.htmlEncoding which wraps the actual encoding (except its eventual internal part).

@rakyll rakyll changed the title golang.org/x/net/html/charset.htmlEncoding incompatibility with golang.org/x/text/encoding/htmlindex.Name x/net/html/charset: htmlEncoding incompatibility with x/text/encoding/htmlindex.Name Feb 6, 2017
@gopherbot gopherbot added this to the Unreleased milestone Mar 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants