0

I wanna convert url f.e.:

xn--h1aaebtrh5b.xn--p1ai --> кисточки.рф

And of course reverse:

kremlin.ru ---> xn--d1abbgf6aiiy.xn--p1ai

I try use idna package, but i can't import vendor package idna

Link on doc: https://godoc.org/golang.org/x/net/idna#Profile.ToUnicode

Try import:

import "golang_org/x/net/idna"

Get error:

main.go:18:8: cannot find package "golang_org/x/net/idna" in any of:
    /usr/local/go/src/golang_org/x/net/idna (from $GOROOT)
    /home/arseny/go/src/golang_org/x/net/idna (from $GOPATH)

Another try:

import "vendor/golang_org/x/net/idna"

Errors:

main.go:18:8: must be imported as golang_org/x/net/idna

main.go:19:2: use of vendored package not allowed
Arseny
  • 111
  • 12
  • Why are you importing `golang_org/x/net/idna`? The package is called `golang.org/x/net/idna`. – Jonathan Hall Jul 13 '17 at 19:28
  • Yes and No, in IDE Goglang, this folder calls golang_org – Arseny Jul 14 '17 at 09:54
  • why -1 ??? strange people...... the same quastion in js https://stackoverflow.com/questions/183485/converting-punycode-with-dash-character-to-unicode?rq=1 – Arseny Jul 14 '17 at 09:54
  • This question isn't really about how to convert punycode to unicode. It's about why you can't import that package. You already know how to convert punycode, as indicated by your question. – Jonathan Hall Jul 14 '17 at 10:53
  • Realy?? Ok, in the begin, i say what i want, i use google and find package for it, next i really can't import them, BUT if you KNOW another way HOW to convert punycode to unicode and reverse, i would be greatfull. – Arseny Jul 14 '17 at 12:21

1 Answers1

2

Some people say that this code work

In bash:

go get golang.org/x/net/idna

Example code go:

package main

import (
    "fmt"
    "golang.org/x/net/idna"
)

var p *idna.Profile

func main() {
    // Raw Punycode has no restrictions and does no mappings.
    p = idna.New()
    fmt.Println(p.ToUnicode("xn--d1abbgf6aiiy.xn--p1ai"))
}

But i'm still hope that another way exist. I unlike to do local copy of package into $GOROOT path.

Arseny
  • 111
  • 12