什么是C++在golang中的"using"等价物

coo*_*aac 8 c++ namespaces go

什么是C++ using some_namespace::object在golang中的等价物?

根据这里的问题, 我可以using namespace common在下面说明:

import (
  . "common"
)
Run Code Online (Sandbox Code Playgroud)

但这会导入整个命名空间.现在我只想使用,比如说platform定义using common::platform

在Go中是否有相同的内容,所以我不必一直打字common.platform

Rol*_*lig 5

以下代码在可读性方面接近,但效率较低,因为编译器无法再内联函数调用。

import (
    "fmt"
    "strings"
)

var (
    Sprintf = fmt.Sprintf
    HasPrefix = strings.HasPrefix
)
Run Code Online (Sandbox Code Playgroud)

而且,它具有输入名称的副作用fmt,并strings到该文件的范围,这恐怕是C ++的using没有做。