bwmarrin / discordgo

(Golang) Go bindings for Discord
BSD 3-Clause "New" or "Revised" License
5.07k stars 806 forks source link

Go path returns error #526

Closed ren-kun closed 6 years ago

ren-kun commented 6 years ago

go get github.com/bwmarrin/discordgo

golang.org/x/crypto/poly1305

/usr/local/go/src/golang.org/x/crypto/poly1305/sum_amd64.s:8 6a: No such file or directory: textflag.h

github.com/gorilla/websocket

/usr/local/go/src/github.com/gorilla/websocket/compression.go:95: undefined: sync.Pool

How do I fix this? Did I do something wrong?

Necroforger commented 6 years ago

You might be using an older version of go. You could try updating. Type go version to see the version you're on right now. I see go version go1.9.3 windows/amd64 for mine

Sync.pool was introduced in go version 1.3

ren-kun commented 6 years ago

I uninstalled Go and tried it again. But i get this output for version:

go version xgcc (Ubuntu 4.9.3-0ubuntu4) 4.9.3 linux/amd64

Perhaps I missed a step?

ren-kun commented 6 years ago

Ahh.... I have two types of go's

sudo apt-get remove gccgo

worked and i had to rego the PATHs

ren-kun commented 6 years ago

I get:

warning: GOPATH set to GOROOT (/usr/local/go) has no effect

Now, is that an error

Necroforger commented 6 years ago

Yeah, you can't download packages to the same place your root go files are installed. So you need to set your GOPATH to something else, like ~/godata

ren-kun commented 6 years ago

So I change export PATH=$PATH:/usr/local/go/bin

to something like: export PATH=$PATH:/var/Something

Necroforger commented 6 years ago

You need to export GOPATH=/home/something

and all your downloaded packages and executeables will go there.

You also need to export PATH=$PATH;/home/something/bin/

ren-kun commented 6 years ago

Thanks!

Now i get:

can't load package: package .: no Go files in /folder/here

when building go

Necroforger commented 6 years ago

Can you go get github.com/bwmarrin/discordgo

ren-kun commented 6 years ago

Yes I did the command and it seems to have worked (No error returned)

Just "can't load package: package .: no Go files in /folder" still. when

"go build"

Necroforger commented 6 years ago

Make sure your terminal is in the right directory and that the package you're building has package main at the top of all the go files if you want to build an executeable.

I will get the same error if I try to use go build in my home directory, which contains no go files.

Usually when working on projects you will want to create them under your github name or something in your GOPATH. So a good project directory would be something like $GOPATH/src/github.com/yourname/project

ren-kun commented 6 years ago

Where is the right directory? For example I go get..

go get github.com/bwmarrin/discordgo go get github.com/joho/godotenv

where would i go to compile it? I think I am not trying to build an executable. Pardon if I can not post other git links here but I'm just trying to do follow "https://github.com/FactoKit/FactoCord"

Necroforger commented 6 years ago

When you go get github.com/FactoKit/FactoCord it should build an executeable and place it in $GOPATH/bin.

Otherwise you would have to

cd "$GOPATH/src/github.com/FactoKit/FactoCord"
go build

which would produce an executeable called FactoCord in the current directory.

So to run you would just type FactoCord if $GOPATH/bin is exported.

ren-kun commented 6 years ago

Ahh I see... So i did the following and tried to do it on my own but i did:

$ sudo gedit ~/.bashrc

Added the following config

export PATH=$PATH:/usr/local/go/bin export GOPATH=/var/Server/go; export PATH=$PATH:$GOPATH/bin;

$ source ~/.bashrc $ go get github.com/bwmarrin/discordgo

I then look at : /var/Server/go/bin

And its empty.

I do see /var/Server/go/src/github.com/FactoKit/FactoCord"

and continue to..

$ go build

and it returns:

main.go:17:2: local import "./commands" in non-local package main.go:18:2: local import "./commands/admin" in non-local package main.go:16:2: local import "./support" in non-local package.

When I look in /var/Server/go/src/github.com All I see is FactoKit and the other go gets are not there,

Did i do something incorrectly?

Necroforger commented 6 years ago

You're not really supposed to use local imports in go/ Sounds like a library issue

ren-kun commented 6 years ago

Could you explain what a Library issue is, so i can further understand?

Necroforger commented 6 years ago

Import paths should be in the form of github.com/yourname/project/package Or be in a special vendor folder like vendor/app/package then you can import as app/package in your project

ren-kun commented 6 years ago

Ahhh! I see them now, strange it took a while to show up.

image

So where do I navigate now to "go build"?

OH... i go into every folder...

Necroforger commented 6 years ago

Enter the FactoKit/FactoCord directory and type go build

ren-kun commented 6 years ago

Ahh thankyou soooo much @Necroforger !!!

Everything built except the factocord which returned the same error:

main.go:17:2: local import "./commands" in non-local package main.go:18:2: local import "./commands/admin" in non-local package main.go:16:2: local import "./support" in non-local package.

Perhaps I should try an older pull of factocord..

Can I buy you a coffee?

Necroforger commented 6 years ago

You should just need to replace the lines at https://github.com/FactoKit/FactoCord/blob/master/main.go#L16 with

"github.com/FactoKit/FactoCord/support"
"github.com/FactoKit/FactoCord/commands"
"github.com/FactoKit/FactoCord/commands/admin"

To get it working

ren-kun commented 6 years ago

That did it!

Once again I thank-you!

Necroforger commented 6 years ago

Np If you need any more help you could check out the golang discord server https://discord.gg/5UsRjb