我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

为什么可以将参数传递给类似http.Dir(“。”)的类型?

In http package it is defined a custom type (type Dir string) and then a method Open is added to it (https://golang.org/src/net/http/fs.go#L34). When invoked elsewhere it is done by http.Dir(".") as it were a function or method. Can someone explain me why and what is happening here?

http.Dir(".") is a type conversion. It converts the string "." to type http.Dir.

近期文章

  • 如何在函数中使用接口,其中参数是另一个具有相同函数列表的接口?
  • Go中未定义的返回类型
  • 在vim中禁用gofmt-在vim ide中插入
  • 如何关闭所有“睡眠”的goroutine?
  • 为什么主goroutine总是第二个被调用
  • 将字符串数组序列化为json
  • 当fmt.Println()时,golang编译器会做什么
  • 引用另一个结构给出“未定义”
  • 如何在GO中另一个包中的文件中使用主包中的函数?
  • 如何通过使用go get获取指定版本的软件包(标签)?
  • 进入wait4功能
  • 输入任何数值并按go1.5.2排序
  • GoLang:将file://的标头设置为null到http://的请求无效
  • 通过Golang执行Shell脚本后找回错误
  • 在Go中构建MRSS Feed
  • 鱼壳中有多个GOPATH
  • 测试功能获得100%覆盖率
  • 在Go中传递响应正文(response.Body)的有效方法是什么?
  • 在Golang中解组json数组
  • PostgreSQL查询中具有模式匹配语法的参数

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华