构建事件未定义

huangapple go评论103阅读模式
英文:

go build events undefined

问题

环境:Windows 10 专业版 64 位。

我想构建/安装一个 Go 项目(如你所见的 twitterbeat)。

在这里,你可以看到文件的第 62 行:

func (bt *Twitterbeat) Setup(b *beat.Beat) error {
    logp.Info("Setup waitduration and api keys")

    bt.events = b.Events

    var err error
    bt.period, err = time.ParseDuration(*bt.beatConfig.Period)
    if err != nil {
        return err
    }

    anaconda.SetConsumerKey(*bt.beatConfig.Twitter.ConsumerKey)
    anaconda.SetConsumerSecret(*bt.beatConfig.Twitter.ConsumerSecret)
    bt.api = anaconda.NewTwitterApi(*bt.beatConfig.Twitter.AccessKey, *bt.beatConfig.Twitter.AccessSecret)

    return nil
}

我认为代码没有问题,因为我直接从 Github 上下载的。

因为我不在 Linux/Unix 系统上(而且我在代理方面遇到了问题),所以我无法运行 "glide"。相反,我自己下载了所有的依赖项。

我应该怎么做才能构建 twitterbeat?

英文:

Environment: Windows 10 Professional 64-Bit.

I want to build / install a go-project (twitterbeat as you can see).

C:\apps\Go_workspace\src\github.com\buehler\twitterbeat>go build
# github.com/buehler/twitterbeat/beater
beater\twitterbeat.go:62: b.Events undefined (type *beat.Beat has no field or method Events)

Here you can see line 62 of the file:

func (bt *Twitterbeat) Setup(b *beat.Beat) error {
	logp.Info("Setup waitduration and api keys")

	bt.events = b.Events

	var err error
	bt.period, err = time.ParseDuration(*bt.beatConfig.Period)
	if err != nil {
		return err
	}

	anaconda.SetConsumerKey(*bt.beatConfig.Twitter.ConsumerKey)
	anaconda.SetConsumerSecret(*bt.beatConfig.Twitter.ConsumerSecret)
	bt.api = anaconda.NewTwitterApi(*bt.beatConfig.Twitter.AccessKey, *bt.beatConfig.Twitter.AccessSecret)

	return nil
}

I don't think that the code is wrong, because I donwloaded it directly from Github.

Because I am not on a linux / unix system (and I had problems with the proxy), i couldn't run "glide". Instead I donwloaded all dependencies by myself.

What can I do to build twitterbeat?

答案1

得分: 0

当您手动下载依赖项时,需要确保它们与glide.yaml文件中的版本相同。github.com/elastic/libbeat/beat/beat.go中的beat.Beat当前版本比glide.yaml中的版本更新,并且不再具有Events字段。

英文:

When you download the dependencies by hand, you need to make sure that they are the same version as in the glide.yaml file. The current version of beat.Beat in github.com/elastic/libbeat/beat/beat.go is newer than the one in the glide.yaml and doesn't have an Events field any more.

答案2

得分: 0

这不是你的问题,而是你正在使用的库的错误。

根据代码显示,它使用了github.com/elastic/beats/libbeat/beat,然后我们跳转到beat的源代码,Beat结构体如下:

type Beat struct {
    Name      string               // Beat名称。
    Version   string               // Beat版本号。当实现没有设置版本时,默认为libbeat版本。
    UUID      uuid.UUID            // 分配给Beat实例的ID。
    BT        Beater               // Beater实现。
    RawConfig *common.Config       // 可以解包以获取Beat特定配置数据的原始配置。
    Config    BeatConfig           // 公共Beat配置数据。
    Publisher *publisher.Publisher // 发布者

    filters *filter.FilterList // 过滤器
}

它不再有Events字段了!

你可以使用旧版本的库github.com/elastic/beats/libbeat/beat,或者你可以向github.com/buehler/twitterbeat的所有者提交一个问题,告诉他修复这个错误。

英文:

It's not your problem,but a fault of the library you are using.

As the code shows,it used github.com/elastic/beats/libbeat/beat,then we jump to the source of beat,the Beat struct is:

type Beat struct {
    Name      string               // Beat name.
    Version   string               // Beat version number. Defaults to the libbeat version when an implementation does not set a version.
    UUID      uuid.UUID            // ID assigned to a Beat instance.
    BT        Beater               // Beater implementation.
    RawConfig *common.Config       // Raw config that can be unpacked to get Beat specific config data.
    Config    BeatConfig           // Common Beat configuration data.
    Publisher *publisher.Publisher // Publisher

    filters *filter.FilterList // Filters
}

It doesn't have Events field anymore!

You can use the old version of the library github.com/elastic/beats/libbeat/beat,or you can push a issue to the owner of github.com/buehler/twitterbeat to inform him to fix this bug.

huangapple
  • 本文由 发表于 2016年4月22日 15:01:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/36787081.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定