How to import package with slash

I am a beginner in GO.
I want to import packages with slash like “unicode/utf16” or “golang(point)org/x/text/encoding/unicode”.

  1. “unicode/utf16”
    When I tried to build my code, the error message was <undefined: unicode>.
    So I added unicode package like <import (“unicode”;“unicode/utf16”)>.
    And I got more error messages like <undefined: unicode.UTF16>.
    What does it mean and how can I solve my problems?
  2. “golang(point)org/x/text/encoding/unicode”
    When I tried to build my code, I got the below error message.
    <cannot find package “” in any of:
    c:\go\src\\x\text\encoding\unicode (from $GOROOT)>
    Should I install the package in c:\go\src?
    How can I install the package?

import "unicode/utf16" should totally do.

As well as import "" should work, after go get from within the project. I can’t do this on the playground though.

Packages that are not from the stdlib need to be “installed” or downloaded first. As I said already, go get does that. Though instead of using legacy style projects that rely on the GOPATH, you should use go module based projects instead, though you still need to go get your dependencies, its just that managing the project will be much easier in the long term, especially when you have more than one project on your computer.

1 Like

Thanks very much.
Have a nice day.

  1. I should study more.
  2. ‘go get’ works nice.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.