dongqiu5184 2018-11-16 02:54
浏览 136

为什么函数runtime_args可以这样表示?

This code is in proc.go. I can not understand function runtime_args, can anyone help me? Sorry for my poor english.

// Args hold the command-line arguments, starting with the program name.
var Args []string

func init() {
    if runtime.GOOS == "windows" {
        // Initialized in exec_windows.go.
        return
    }
    Args = runtime_args()
}

func runtime_args() []string // in package runtime

// Getuid returns the numeric user id of the caller.
//
// On Windows, it returns -1.
func Getuid() int { return syscall.Getuid() }
  • 写回答

1条回答 默认 最新

  • du67560 2018-11-16 03:23
    关注

    According to Go Programming Language Specification:

    A function declaration may omit the body. Such a declaration provides the signature for a function implemented outside Go, such as an assembly routine.

    In your case this function implementation is actually declared in the runtime package

    proc.go:

    ...
    func runtime_args() []string // in package runtime
    ...
    

    runtime.go:

    ...
    //go:linkname os_runtime_args os.runtime_args
    func os_runtime_args() []string { return append([]string{}, argslice...) }
    ...
    
    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退