dongwang6837 2019-02-23 17:29
浏览 412
已采纳

导入错误:带有html的golang.org/x/net/html

I'm using "html" and "golang.org/x/net/html" in golang.

enter image description here

It's got error by same name.So I named other name like this.

net_html "golang.org/x/net/html"

and also I tried like this

_ "golang.org/x/net/html"

But it wasn't effect for me.

Do you know how to solve this problem?

  • 写回答

2条回答 默认 最新

  • duanbo7517 2019-02-23 19:34
    关注

    Using _ "golang.org/x/net/html" you import the package but you cut-off all access to it, this is used only when you need the imported package to perform some initialization and nothing else.

    Using net_html "golang.org/x/net/html" is ok and is exactly what you should do in this case. If you're still getting the "html redeclared as imported package ..." error then there might be an issue with the IDE you are using, but generally the Go compiler will not complain and your code should run without problems.

    To see for yourself that it works in a normal environment go to the following link and try running the program and you'll see that it compiles and executes. https://play.golang.com/p/jRdWucKjQ_0

    And here's a version with the same kind of error as the one that you're getting. https://play.golang.com/p/H5AFpXKJOBy


    So if net_html "golang.org/x/net/html" doesn't fix the "html redeclared as imported package ..." error, then try providing more info about your environment, like what IDE you're using, what version of Go you've installed, etc.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵