English 中文(简体)
在戈马建立并参考我自己的当地一揽子方案
原标题:Build and reference my own local package in Go

我与谷歌和Im有 f(!),但我对一揽子子系统有一些问题。

页: 1 我也建立了各种单一档案方案,没有问题(我还利用html/系统安装了一个小型网络应用系统,没有问题,它汇编并毫无错误。)

I ve defined a "reusable" package (even.go):

package even

func Even(i int) bool {
    return i % 2 == 0
}

func Odd(i int) bool {
    return i % 2 == 1
}

消费者方案(消费者方案):

package main

import (
    "./even"
    "fmt"
)

func main() {
    a := 5
    b := 6

    fmt.Printf("%d is even %v?
", a, even.Even(a))
    fmt.Printf("%d is odd %v?
", b, even.Odd(b))
}

但是,当我使用“图书馆”汇编时,我会这样做。

go build even.go

页: 1 无错误,无信息...... 发生了什么?

我应如何这样做?

最佳回答
问题回答

<代码>go 建设只有在建立“单一主包”时才会产生产出文档。 如果你想要为其他包裹提供文件,请使用<代码>go 安装<>/代码>。 这将建立并安装在<编码>pkgs的目录上。

这里没有产生产出的原因是,你重新管理产出。

go build even.go

查询 Pack,而不是main。 在一揽子计划上这样做,将检查一揽子计划上的错误,但由于一揽子计划不是主要产出,因此不会产生任何成功的信息。 如果包裹的内容有问题,就会出现错误,否则,如果将罚款,则不会产出

相反,你应当运行:

go build useeven.go

创建双手,然后执行双手,并从方案获得产出:

./useeven




相关问题
java in-memory on-the-fly class compilation (and loading)

I want to revisit an old question of mine about in-memory "compilation" of classes. Since about 1/2 a year have passed since I asked (and was somewhat answered), I d like to re-raise the issue and see ...

(c)make - resursive compile

Let s assume I have directories like: dir1 main.cpp dir2 abc.cpp dir3 def.cpp dir4 ghi.cpp jkl.cpp And let s assume that main.cpp ...

How to link to a static library in C?

I use code::blocks to compile my static library. The output result is a libstatic.a file. Now, how do I link to my library to use functions that were compiled? (I tried to use #include "libstatic.a"...

Statically linking Winsock?

I m using Winsock 1.1 in my project. I include wsock32.lib in "Additional Dependencies". I m looking at the DLL project using depends.exe and notice that the DLL depends on wsock32.dll. How can I ...

热门标签