duanmei1536 2015-11-21 15:03
浏览 151

条件编译不起作用

OS: linux/amd64
GO: 1.5.1

When running (go run *.go) the below code I get the following error and I don't understand what I'm doing wrong. I've read the official doc about build constrains. Shouldn't foo_windows.go be ignored?

# command-line-arguments
./foo_windows.go:3: hello redeclared in this block
        previous declaration at ./foo_linux.go:3

main.go

package main

import "fmt"

func main() {
    fmt.Println(hello())
}

foo_linux.go

package main

func hello() string {
    return "hello form linux"
}

foo_windows.go

package main

func hello() string {
    return "hello form windows"
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
    • ¥15 gdf格式的脑电数据如何处理matlab
    • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
    • ¥100 监控抖音用户作品更新可以微信公众号提醒
    • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
    • ¥70 2048小游戏毕设项目
    • ¥20 mysql架构,按照姓名分表
    • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
    • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
    • ¥15 linux驱动,linux应用,多线程