go get sys: textflag.h missing - go

I am trying to use the "sys" package in a go program. So I did
go get golang.org/x/sys/unix
and got
# golang.org/x/sys/unix
src/golang.org/x/sys/unix/asm.s:6 6a: No such file or directory: textflag.h
I am on Fedora 20, using
go version go1.3.3 linux/amd64
Any ideas how to solve this?

The sys package was introduced as a replacement for syscall in go 1.4, I would assume that it doesn't work in versions prior to 1.4.
if you cannot upgrade, look at the syscall package to see if it meets your needs.

Related

go 1.18 in google.cloud

Description
I am trying to install a library from a go v1.18 program to access Google Cloud.
Previously, the "go get" command was used, but since version 1.18, it is no longer available.
It seems to use go install, but I get an error when executing the command.
% go install cloud.google.com/go/bigquery
go: 'go install' requires a version when current directory is not in a module
Try 'go install cloud.google.com/go/bigquery#latest' to install the latest version
% go install cloud.google.com/go/bigquery#latest
package cloud.google.com/go/bigquery is not a main package
% go install cloud.google.com/go#latest
package cloud.google.com/go is not a main package
Environments
% go version
go version go1.18 darwin/amd64
% uname -v
Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64
% sw_vers
ProductName: macOS
ProductVersion: 12.3.1
BuildVersion: 21E258
Reference
bigquery package - cloud.google.com/go/bigquery - pkg.go.dev
I tried,
Thank you for your support.
% go mod init cloud.google.com/go
% go get -u cloud.google.com/go/datacatalog
go: added cloud.google.com/go/datacatalog v1.3.0
% go mod tidy
go: downloading google.golang.org/appengine v1.6.7
go: downloading golang.org/x/sys v0.0.0-20220209214540-3681064d5158
% go mod vendor
% go run catalog.go
package command-line-arguments is not a main package
What should I do next ?
Self resolved.
-> change package name "main"
go install is used to install binary programs available on the package. Usually command line tools.
go get, until go1.18, was used to update packages and install programs, they change it by split in several programs
Seems there is nothing to install. Also the main package is not bigquery but cloud.google.com/go
If you want to install a dependency, if you are using vendorized modules you can do
$ go get -u cloud.google.com/go/bigquery
$ go mod tidy
$ go mod vendor
If not, you may try it by running go mod init first

GOlang core dump analysis using delve throws error 'unrecognized core format'

Iam trying to analyse core file of GO program generated by gcore using delve. Below are steps I have followed. I got Unrecognized format error
$go version
go version go1.13.1 darwin/amd64
$/Users/sudhakar/go/bin/dlv version
Delve Debugger
Version: 1.4.0
Build: 37bee98a8821843314b561bc6ab328dfff2aad1b
$./hello &
[1] 72335
$gcore 72335
$sudo gcore 72335
$/Users/sudhakar/go/bin/dlv core ./hello /cores/hello-72335-20200427T185443Z
unrecognized core format
At the time of this post darwin/amd64 is not supported by delve.
Ref: https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_core.md
However this can change over time (delve may add support to this arch) attaching screenshot of documentation (at the time of this post)
Special thanks to delve-dev list member (Choudhary Sourya Vastayan) who pointed me to this.

Unable to Install Go-Ipfs from source

I'm trying to Build IPFS from Source on windows 10.
Previously i installed it from source.It was working fine. But i needed the latest source so i started again from the scratch. because i edited some parts in the source.
I followed instructions on https://github.com/ipfs/go-ipfs/blob/master/docs/windows.md.
I received following error on executing following commands.
code
cd %GOPATH%\src\github.com\ipfs\go-ipfs
make install
Error
go version go1.12.6 windows/amd64
bin/check_go_version 1.12
go install -asmflags=all=-trimpath="D:\GO_WORKSPACE" -gcflags=all=-trimpath="D:\GO_WORKSPACE" -ldflags="-X "github.com/ipfs/go-ipfs".CurrentCommit=810cb607e-dirty" ./cmd/ipfs
# github.com/ipfs/go-ipfs/plugin/loader
plugin\loader\preload.go:11:2: undefined: pluginipldgit
plugin\loader\preload.go:12:2: undefined: pluginbadgerds
plugin\loader\preload.go:13:2: undefined: pluginflatfs
plugin\loader\preload.go:14:2: undefined: pluginlevelds
make: *** [cmd/ipfs/Rules.mk:37: cmd/ipfs-install] Error 2
I tried Adding this plugins in to preload.go file under src\github.com\ipfs\go-ipfs\plugin\loader directory.
exisiting code on preload.go.
import (
"github.com/ipfs/go-ipfs/plugin"
)
i added after the issue
import (
"github.com/ipfs/go-ipfs/plugin"
pluginipldgit "github.com/ipfs/go-ipfs/plugin/plugins/git"
pluginbadgerds "github.com/ipfs/go-ipfs/plugin/plugins/git"
pluginflatfs "github.com/ipfs/go-ipfs/plugin/plugins/git"
pluginlevelds "github.com/ipfs/go-ipfs/plugin/plugins/git"
)
so after i added this lines result is success.
Executed command
make install
Result
go version go1.12.6 windows/amd64
bin/check_go_version 1.12
go install -asmflags=all=-trimpath="D:\GO_WORKSPACE" -gcflags=all=-trimpath="D:\GO_WORKSPACE" -ldflags="-X "github.com/ipfs/go-ipfs".CurrentCommit=810cb607e-dirty" ./cmd/ipfs
Then i tried to start the ipfs using following command
ipfs daemon
Error
Initializing daemon...
go-ipfs version: 0.4.22-dev-810cb607e-dirty
Repo version: 7
System version: amd64/windows
Golang version: go1.12.6
Error: unknown datastore type: flatfs
Can someone help me configure the IPFS from source.
Thanks in advance.
I solved this problem by following method. not sure this will be a good solution or not. any way i could solve the issue.
I'm posting this as a answer. so it will be useful to everyone who has the same issue.
1) Deleted go-ipfs folder inside the "%GO_WORKSPACE% / .... / ipfs" folder.
2) Git clone the go ipfs repo manually on the same location.
3) go inside go-ipfs folder.
4) execute install command.
make install
Done on Windows.
Save IPFS (kubo) to some folder inside %GOPATH% (I cloned https://github.com/ipfs/kubo) to folder %GOPATH%\kubo
Important cd %GOPATH%\kubo\cmd\ipfs\
go install
ipfs.exe was placed in %GOPATH%\bin
I launched it as daemon - works.
BTW: GOROOT is defined and path to go is included in PATH

import object is expected Error in Golang 1.4.2

I have just upgraded Golang from 1.3 to version 1.4.2. And cannot compile due to error:
../../my/mandrill.go:5: import /path/to/go/home/pkg/darwin_amd64/github.com/keighl/mandrill.a: object is [darwin amd64 go1.3.3 X:precisestack] expected [darwin amd64 go1.4.2 X:precisestack]
FAIL folder [build failed]
on line m "github.com/keighl/mandrill"
package my
import (
"fmt"
m "github.com/keighl/mandrill"
)
I guess some rules of importing have changed in 1.4.2. But cannot figure out how to change my import code to make it compile.
Just delete the old pkg files, usually it upgrades automatically though.
rm -rf $GOPATH/pkg/
I met this problem too. I deleted the old packages but still get same error. finally I found the old pkg keep get generated by my "sublime text2". after restarted it. everything back to work :p

syscall variables undefined

When trying to build the following program on my Mac I get a build error: undefined: syscall.TCPInfo even though that variable is clearly documented http://golang.org/pkg/syscall/#TCPInfo
package main
import "syscall"
func main() {
_ = syscall.TCPInfo{}
}
Here is my go tool version.
$ go version
go version go1.3 darwin/amd64
I thought this might be an issue a lack of OS support so I tried it on http://play.golang.org, but it looks like many documented variables are just randomly missing from the syscall package: http://play.golang.org/p/w3Uk6NaZVy
Am I missing something?
The variable specified inside syscall are OS dependent.
you can add a suffix to the file to specify which os they should be built for:
// +build linux,386 darwin,!cgo
So you can use specific syscall flags for each OS.

Resources