Home > OS >  Can't execute program in the older Go version
Can't execute program in the older Go version

Time:08-27

I'm trying to build program found on github.(https://github.com/ginuerzh/gimme-bitcoin-address)

I have been programming in golang for half a year, but I have never encountered a situation where the program lacks the "go.mod" file or the main function.

Build instruction looks like this, but you can't build without go.mod file, so I use go mod init ... , but it is not my question here.

$ git clone git://github.com/vsergeev/gimme-bitcoin-address.git
$ cd gimme-bitcoin-address
$ go get code.google.com/p/go.crypto/ripemd160
$ go build

go build isn't building anything ofcourse

Worth to notice is that go get ... is outdated, and you have to import "golang.org/x/crypto/ripemd160"

Project structure looks like this:

gimme-bitcoin-address/
 |-- LICENSE
 |-- README
 |-- gimme-bitcoin-address.go
 |-- gimme-bitcoin-address_test.go

And, as you see there's no main.go file, but as before this is not real problem.

Only one able-to-build file (except the xx_test.go) is gimme-bitcoin-address.go, let's look at the code.

Instead of package main, there's package btcaddr, what else the function that is closest to the main function is func _main

To sum this all up - my question is how can I run this program, after cloning repository, or how to fix it? I dont't really know but, maybe this is some old-fashioned syntax, but function _main is not called anywhere. It's probably quite newbie question, but I can't handle it. I hope maybe someone would help me.

CodePudding user response:

If you are just trying to build the project, the following should work:

$ cd /tmp
$ go version
go version go1.18.5 linux/amd64

$ git clone https://github.com/vsergeev/gimme-bitcoin-address.git
Cloning into 'gimme-bitcoin-address'...
remote: Enumerating objects: 261, done.
remote: Total 261 (delta 0), reused 0 (delta 0), pack-reused 261
Receiving objects: 100% (261/261), 62.36 KiB | 1.02 MiB/s, done.
Resolving deltas: 100% (142/142), done.

$ cd gimme-bitcoin-address/
$ ls
ChangeLog.md  LICENSE  README.md  btckey  main.go

$ go mod init testing
go: creating new go.mod: module testing
go: to add module requirements and sums:
        go mod tidy

$ go mod tidy
go: finding module for package golang.org/x/crypto/ripemd160
go: finding module for package github.com/vsergeev/btckeygenie/btckey
go: downloading golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d
go: downloading github.com/vsergeev/btckeygenie v1.1.0
go: found github.com/vsergeev/btckeygenie/btckey in github.com/vsergeev/btckeygenie v1.1.0
go: found golang.org/x/crypto/ripemd160 in golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d

$ go build
$ ls -la
total 2124
drwxrwxrwx 1 ubuntu ubuntu     512 Aug 26 16:08 .
drwxrwxrwx 1 ubuntu ubuntu     512 Aug 26 16:07 ..
drwxrwxrwx 1 ubuntu ubuntu     512 Aug 26 16:08 .git
-rwxrwxrwx 1 ubuntu ubuntu      45 Aug 26 16:07 ChangeLog.md
-rwxrwxrwx 1 ubuntu ubuntu    1088 Aug 26 16:07 LICENSE
-rwxrwxrwx 1 ubuntu ubuntu    3616 Aug 26 16:07 README.md
drwxrwxrwx 1 ubuntu ubuntu     512 Aug 26 16:07 btckey
-rwxrwxrwx 1 ubuntu ubuntu     131 Aug 26 16:08 go.mod
-rwxrwxrwx 1 ubuntu ubuntu     394 Aug 26 16:08 go.sum
-rwxrwxrwx 1 ubuntu ubuntu    2860 Aug 26 16:07 main.go
-rwxrwxrwx 1 ubuntu ubuntu 2158646 Aug 26 16:08 testing

This is from an Ubuntu 20.04 Windows Subsystem for Linux environment using Go 1.18.5.

  • Related