如果我有
// types.go
type S string
func (s *S) Lower() *S {
*s = S(strings.ToLower(string(*s)))
return s
}
Run Code Online (Sandbox Code Playgroud)
`
// in another file
import "u/types"
func main() {
s := types.S("asdf")
if s == "asdf" {
s.Lower()
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法将types.S("asdf")缩短为S("asdf")?
有没有办法从其他文件小写方法调用?egsLower()=> s.lower()?
| 归档时间: |
|
| 查看次数: |
1951 次 |
| 最近记录: |