简体   繁体   中英

installing telegram bot api package failed

I'm trying to install telegram bot api module for golang from this link:
https://github.com/go-telegram-bot-api/telegram-bot-api

the installation example that showed there isnt working and raises the next error:

cannot find package "github.com/go-telegram-bot-api/telegram-bot-api/v5" in any of:
    /usr/local/go/src/github.com/go-telegram-bot-api/telegram-bot-api/v5 (from $GOROOT)
    /home/foo/go/src/github.com/go-telegram-bot-api/telegram-bot-api/v5 (from $GOPATH)

I looked on google and I saw some people recommending use "go install", but that raises the same error.

I would like to some help here, I'm trying figuring this out without a success for a while now. and feel free to ask for any further infotmation if you need

Thanks in advance!

So to elaborate on my comment:

The package you're trying to use is a module. It has no main function (or main package). The example in the readme file is something you would write yourself. Say you want to call it "mybot" , you'd go about it something like this:

$ mkdir mybot
$ go mod init github.com/yourname/mybot
$ go get -u github.com/go-telegram-bot-api/telegram-bot-api/v5
$ vim main.go

In this main.go you can paste the example, then run:

$ go build .

It'll generate a binary in the current directory called mybot . You can run this like any executable:

$ ./mybot

Once you're up and running, install it using go install. . This will put the binary in $GOPATH/bin . If you added that to your $PATH variable, you can just run the binary by running mybot from anywhere...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM