Questions tagged [go-packages]
45 questions
0
votes
1 answer
How to list all non-standard/custom packages in Go?
As mentioned here one can get all the standard Go packages using https://godoc.org/golang.org/x/tools/go/packages 's Load() function in which one can give "pattern" as input.
pkgs, err := packages.Load(nil, pattern)
For example, if pattern = "std"…

Satyajit Das
- 2,740
- 5
- 16
- 30
0
votes
2 answers
Is there an easier way to keep local Go packages updated
I am using multiple packages that I import into different projects, these range from custom adapters for my business logic that are shared by lambda and google cloud functions and other public packages. The way I do this right now is that I vendor…

automaticAllDramatic
- 2,025
- 1
- 21
- 25
0
votes
0 answers
Vgo build triggers "unknown directive: go"?
Any vgo command shows the same error with parsing go.mod file.
unknown directive: go
Here is my go.mod file:
module github.com/SvitlanaShepitsena/surf
go 1.13
require (
github.com/PuerkitoBio/goquery v1.5.0
github.com/headzoo/surf v1.0.0…

Svitlana
- 2,324
- 4
- 22
- 31
0
votes
1 answer
Getting full path to a package source from the package import path
Currently I have a parameter like str := "github.com/pkg/errors". I need the full path to the package.
Currently how I achieve this is by using build.Default.GOPATH+"/src/"+str.
Is there a native non hacky way of resolving the full path to an import…

Coyote
- 2,454
- 26
- 47
0
votes
1 answer
How to get coverage for multiple files in GOLANG
I have a package in GO-LANG that has several files implementing it. (all files are in the same directory)
file1: mypackage.go
package mypackage
func f1 () {}
file2: mypackage_addition.go
package mypackage
func f2 () {}
file3:…

Sharon Katz
- 898
- 9
- 12
0
votes
1 answer
import code from a separate package/folder
I have this directory layout:
/baba
biz.go # package baba
/hello
foo.go # package main
biz.go looks like this:
package baba
func Foodd(z int) int {
return z + 5
}
and foo.go looks like this:
package main
import (
…

Alexander Mills
- 90,741
- 139
- 482
- 817
-1
votes
2 answers
Can not use same variable name in different go file
Here is my first go file:
package main
import (
"bufio"
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
"os"
"strconv"
)
var db13 *sql.DB
then, I create the second go file:
package main
import "database/sql"
var…

Erika
- 453
- 8
- 23
-1
votes
1 answer
Trouble with using gorilla/mux package in mac
I am trying to learn how to build a webserver using go and mux. I am importing mux to the main.go file as import github.com/gorilla/mux. However, when I am trying to run the code. I get the following error
no required module provides package…

Michio Kaku
- 49
- 1
- 6
-2
votes
2 answers
Unable to import func A() of package main, inside another package main func main. There are 2 package main
At package level main I have 2 files hello.go and main.go.
|- hello.go
|- main.go
Both the files are in package main level but unlike other packages I am unable to import a func defined in the hello in the func main. Can there be only 1 file with…

Shubham Chadokar
- 2,520
- 1
- 24
- 45
-2
votes
1 answer
Is it possible to update local packages without running go install?
I am trying to import a local file into my main.go file and this tutorial (and other similar tutorials) says to run go install in order to import that path as a package. This seems like a slow way to develop local packages because you would…

sdfsdf
- 5,052
- 9
- 42
- 75
-2
votes
1 answer
I'm unable to clone from multiple repos on CircleCi
I'm unable to download my newly released go package from CircleCi. Locally it works.
I'm able to verify that the tag I'm trying to use is available by visiting
https://github.com/acme/my-lib/tree/v0.0.3
However, go get will not download it.
I have…

martins
- 9,669
- 11
- 57
- 85
-2
votes
1 answer
Cannot find nested package
I have a project with the following structure:
myapp/
-services/
-services/
-exch.go
-services.go
-server.go
Having $GOPATH set to /home/dev/dev/go
this is how server.go names it's package and imports:
//server.go
package…

ntonnelier
- 1,539
- 3
- 23
- 49
-3
votes
1 answer
os.Read() How is work? Golang
Why if I print bs, before calling Read(), it prints nothing, but after the call file.Read(bs), it shows the inside of test.txt file. Unless bs is only argument, how Read() can Change it?
package main
import (
"os"
"fmt"
)
func main() {
file ,…

Py_Dev
- 15
- 5
-4
votes
1 answer
Should I checkin pkg/mod/cache to git?
I'm using go mod for my project. If my understanding is right, go.mod and go.sum can be checked in. However, I'm curious to know if I should check in pkg/mod/cache as well.

user3587025
- 173
- 1
- 4
- 17
-4
votes
1 answer
Does go have OS-specific packages that cannot be used on another OS?
I cannot call myself an absolute beginner in go, and I'm definitively not an expert.
Today, I noticed something VERY confusing. I was experimenting with Unix sockets and Windows named pipes, and from my research, there are 2 packages that support…

Farzad
- 1,770
- 4
- 26
- 48