
我创建一个新类型来添加特定于我的应用需求的自定义方法
type content html.node
我知道我可以从 content 类型的 content var 中派生出 html.node 执行此操作
node := html.node(content)
但是,有一个 html.node 类型的 var,如何转换为 content ?
我发现执行以下操作...
ndoe, err := htmlquery.loadurl(page.url) content := content(node)
...无法工作。它给了我这个错误:
cannot convert doc (variable of type *html.Node) to type Content
正确答案
https://www.php.cn/link/b14fba037d119d307e3b6ceb2a9fbb31
良精商城网店购物系统是一套能够适合不同类型商品、超强灵活的多功能在线商店系统,三级分销 PC+移动端+微网站,为您提供了一个完整的在线开店解决方案。良精网店购物系统除了拥有一般网上商店系统所具有的所有功能,还拥有着其它网店系统没有的许多超强功能。多种独创的技术使得系统能满足各行业广大用户的各种各样的需求,是一个经过完善设计并适用于各种服务器环境的高效、全新、快速和优秀的网上购物软件解决方案。
如果节点是 html.node 使用:
c := content(node)
如果节点是 *html.node 使用:
c := (*content)(node)
上面链接规范的注释:“如果类型以运算符 * 开头...必要时必须将其放在括号中以避免歧义。”
如果您想要 content 而不是 *content 那么您需要在转换之前或之后取消引用指针,例如:
c := Content(*node) // dereference before conversion // or c := *(*Content)(node) // dereference after conversion








