Most voted "golang" questions
Use this tag when the question refers to some resource, information, or problem relating exclusively to the Go programming language. Go (also known as Golang) is an open source programming language initially developed in Google, high-level, with strong, secure, nominal and structural typing, manifest or inferent, essentially imperative paradigm and which has competition mechanisms.
Learn more…111 questions
Sort by count of
-
1
votes4
answers103
viewsExtracting json value from page
Good evening. I’m trying to extract a json value from a certain page. Trial code: package main import ( "encoding/json" "io/ioutil" "net/http" "fmt" ) type Response struct { proxy string…
golangasked 5 years, 8 months ago Júlio César 33 -
1
votes1
answer58
viewsGET golang syntax error with optional parameters
I am trying to filter my records based on a "Name parameter" I did this Handler Function: func GetFuncionaries(w http.ResponseWriter, r *http.Request) { var f model.Funcionary var t util.App var d…
golangasked 5 years, 4 months ago veroneseComS 2,752 -
1
votes1
answer58
viewsString Return
I’m trying to return a String format in a function, however error n occurs defined. func descreve(x, y int) string{ total := soma(x, y) return "%d + %d = %d", x, y, total } I don’t want to wear just…
-
1
votes1
answer57
viewsFunction does not return value with goroutines
Good afternoon. I own this code: package main import( "fmt" "net/http" "bytes" "io/ioutil" urlU "net/url" "strconv" "math/rand" "strings" ) func random(min, max int) int { return rand.Intn(max -…
-
1
votes2
answers65
viewsHow do local modules work in Go?
I saw in this question that it is possible to define local modules in Go using the GOPATH. However, in the solution of this question, the file is not used go.mod What is this file for? There is a…
-
1
votes1
answer83
viewsValue input problem - Golang
I’m playing an old-fashioned game where the input is a number from 1 to 9 that corresponds to the location on the field, if I enter more than 1 digit like 44 or "Asd" is given as invalid input.…
-
1
votes1
answer42
viewsGolang: Pass Nested Struct to Htmltemplate
Good afternoon to all! I need a help, I have two structs that are in the controller package as below: type ListValidation struct{ Id int Nameplan string Escop string Data string } type ListTests…
-
1
votes1
answer41
viewsError handling a method called by a go routine
When we have a method like this: func (vu *VideoUpload) ProcessUpload(concurrency int, doneUpload chan string) error { in := make(chan int, runtime.NumCPU()) returnChannel := make(chan string) err…
golangasked 3 years, 10 months ago Rafael Costa 374 -
1
votes2
answers84
viewsRandom Doubt and Periodic Activities in Golang
Is there any way I can get one executed fmt.Printf(choosenCity) every 6 hours and, at each run, he chooses a different element of the Array? I even managed to get him to perform periodically after a…
-
1
votes1
answer47
viewsInstallation bcrypt golang
I have a problem that I cannot solve and would like help if possible. I am new to golang language. During a tutorial that was following regarding the language, a script was created with the bcrypt…
-
1
votes0
answers71
viewsHow to open encrypted . zip files?
I am trying to open . zip files with password, using existing passwords in other file. txt. The code function that opens the file: package main import ( "bufio" "fmt" "os" "time"…
-
1
votes0
answers47
viewsHandle dynamic role and function names
I’m on my first Golang project, which consists of a small router for an MVC structure. Basically, what I expect him to do is take the request URL, separate it into pieces, and forward the execution…
-
0
votes3
answers452
viewsSettings of the Go language
I need to do a job in college and I chose to do it in Go language because I wanted to learn a new language. Yesterday I installed . msi of the site and saw that I needed to configure the variables…
golangasked 9 years, 1 month ago Gustavo Mendonça 177 -
0
votes1
answer100
viewsGolang - Dependency Verification
I need to change the get answer below: router.GET("/health", func(context *gin.Context) { context.JSON(http.StatusOK, gin.H{ "message": "OK", }) }) I need to create a dependency checker. A request…
golangasked 8 years, 6 months ago Daniel Moraes 1 -
0
votes1
answer919
viewsOpen text file and handle by line
I’m starting the first steps in go and I am needing to first get a text file open it and filter by row where each line is separated by | and I’m gonna make a if to show a certain line Example:…
golangasked 7 years, 9 months ago Ricardo Gomes 273 -
0
votes1
answer3438
viewsMessage "Invalid Object name 'dbo.table' SQL Server with Go Lang
I am trying to use a select in my SQL Server Database that I have in Azure. I’m using the Driver: https://github.com/denisenkom/go-mssqldb. However, a message is returned to me: mssql: Invalid…
-
0
votes1
answer119
viewsFree up server memory space when idle
I have a code sort of with this structure: package main import ( "html/template" "net/http" "log" ) func main() { http.HandleFunc("/",taltal) http.ListenAndServe(":8080",nil) } func check(err…
golangasked 7 years, 8 months ago MarceloBoni 6,385 -
0
votes0
answers66
viewsConvert a variable to a reflect. Type
I started learning Go recently. I want to be able to save one type of data into one variable, and convert another variable to it. I know that one way to save a data type is by using reflect.Type. i…
-
0
votes2
answers921
viewsImport/insert other files - go (golang)
I am studying go (golang) and I have a question regarding the import of files, the doubt is about something "elementary" but I could not find anything specifically about it. I have a package (test)…
-
0
votes1
answer107
viewsDownload package using "go get"
The installation of go in /usr/local/go occurs perfectly and I can verify this using: go --version When trying to use get with: go get github.com/russross/blackfriday I get the following error:…
-
0
votes1
answer218
viewsHow to set $GOPATH to existing folder?
I want install one bundle in a project in go go get -u github.com/gorilla/mux But to the type that commando in the terminal of Ubuntu package github.com/gorilla/mux: cannot download, $GOPATH not…
golangasked 6 years, 9 months ago Junior Vilas Boas 353 -
0
votes2
answers373
viewsHow to generate a RSA key pair in Windows 10?
I’m trying to use jwt, more specifically the jwt to go, but I need to generate a key pair (a public and a private) RSA, I tried to generate by puttygen but Dã error Key must be PEM encoded PKCS1 or…
-
0
votes1
answer117
viewsgo(golang) error giving go install - Unexpected directory layout command
I’m new to go(golang) I’m trying to start an application but without success, it returns me the following error when giving the go install command: unexpected directory layout: import path:…
-
0
votes2
answers100
viewsHow is it still possible to calculate 1<<64-1 without issuing an overflow?
The uint64 limit is (2 64)-1, or simply 1<<64-1. When you try to do something like fmt.Print(uint64(1<<64-1)) it works normally, makes sense once it’s within the limit. However, if the…
-
0
votes1
answer71
viewsAssign method to custom types in Golang
I have a code where I need to perform several replaces and for that I did so as follows: exemplo := "Olá, meu nome é xpto, na verdade xpto da silva xpto" formated := strings.Replace(exemplo, "xpto",…
-
0
votes1
answer145
viewsImporting local libraries into GO
I’m having a hard time importing a library from do go. The library is in a folder in the same project directory and always of the import error, when not of the import error, of the error to access…
-
0
votes1
answer108
viewsusing twitter api with golang
I am trying to make this request "oauth/request_token" on twitter using go. // GET PARAMS TO REQUEST t := time.Now().Format("20060102150405") values := make(url.Values) values.Add("oauth_nonce",…
-
0
votes1
answer483
viewsCross-Origin Golang with Gorilla/Mux
In my application I am using the package gorilla/mux next to the gorilla/handlers to enable/configure the CORS of my application, I currently have an GO and a frontend application in vue, in my…
-
0
votes0
answers205
viewsFirebird database connection with golang
Does anyone use Go to access Firebird database? I’m having connection problems and I’m not being able to solve them !! My connection string Conn, err := sql. Open("firebirdsql",…
-
0
votes1
answer253
viewsThe period between two dates
How to get a period between two dates? d1, _ := time.Parse(time.RFC3339, "2018-10-27T00:00:00Z") d2, _ := time.Parse(time.RFC3339, "2018-10-28T00:00:00Z") // Não funciona. fmt.Println(d2 - d1)…
-
0
votes1
answer53
viewsFull value in hours with Golang
I’m trying to compare 2 dates that have only 1 minute difference between them and apply a price rule based on that time where; Each minute must have the value of R$0.10 st := time.Date(2019, 9, 21,…
-
0
votes1
answer522
viewsAssign values to a struct array in Golang
I’m starting to learn go and need to populate the different structs with their values. I thought about creating an array of structs and trying to use a for to fill the fields but give an error of…
-
0
votes1
answer40
viewsString to time conversion. Time
Good afternoon! I wanted to know how to convert/transform a String date into (dd/mm/yyyy) time format. Time
-
0
votes1
answer75
viewsQuery Beego problem
I’m having problems to mount a Query in Go, using the Beego framework. Error: 2018/12/20 09:21:32.104 [C] [asm_amd64.s:522] Handler Crashed with error Runtime error: invalid memory address or nil…
-
0
votes2
answers45
viewsUsing variable values
I have this code in GO and as you can see I use two constants to pass the region and the name of Bucket. I would like to know how to leave these values variable, since I can use Buckets in other…
-
0
votes1
answer78
viewsGolang Web: Head function
Good night, I’m starting in GO, and I have a question that may seem simple. I am creating a site with GO in Backend, my doubt is I have index.html and main.go created and are working, but in the…
-
0
votes1
answer88
viewsHow to read the contents of a file in awsS3 with golang
I’m trying to create an API in golang This will return the read data from a file in AWS (S3) For example, in c# I do this way to read the data: GetObjectRequest request = new GetObjectRequest{…
-
0
votes1
answer68
viewsPointers in Go
I’m trying to change a String in Go using pointers, but I get one invalid operation: oculta[i] (type *string does not support indexing) The function I’m performing the change. func verifica(palavra,…
-
0
votes1
answer118
viewsReturn of JSON column from the bank in Golang
I am creating a function to return the data of a query that involves SELECT, however there is a column that stores a JSON, and in return comes a number structure, someone could explain to me what…
-
0
votes1
answer39
viewsGo function with parameters instead of name?
Hello, I would like to understand how functions work in the Go language, I made a code to assemble the data structure Stack and I came across two functions that in place of the name has a…
-
0
votes1
answer370
viewsProblem reading csv file that has comma and comma and comma
The code reads the file successfully until it hangs on line 6, which has a comma in the middle, I took the comma off line 6, and the err went to line 8 and so on. How do I read the file? ignoring…
-
0
votes1
answer164
viewsJSON to String API GATEWAY ( AWS )
I need to receive a JSON in my API GATEWAY and pass to my LAMBDA ( GOLANG ) a STRING, The Structure Apigatewayproxyrequest the body is String type, when I try to call the lambda passing the json the…
-
0
votes1
answer303
viewsHow to search a letter in a string with Golang?
I need to take a user string and check if 1) The first letter begins with i or I 2) The last letter ends with n or N 3) If string theme letter a or A in the middle. I started writing something like…
golangasked 4 years, 9 months ago Ana Carolina Esteves 71 -
0
votes0
answers179
viewsORA-01000: maximum open cursors exceeded golang
I have a service that runs a stack. For this, it performs the reading of this stack through a query in Oracle. Turns out, after hours of execution, I get the message: ORA-01000: maximum open cursors…
-
0
votes2
answers93
viewsHow to make a function accept a Slice parameter of any kind?
I created this shuffle function, but I would like it to accept and return any kind of Slice func Shuffle(ptr *[]int, seed int64) []int { rand.Seed(seed) rand.Shuffle(len(*ptr), func(i, j int) {…
-
0
votes1
answer62
viewsWhat can make the texture disappear in Opengl?
I’m using a flame engine Engo, and made a Fork and I’m adding some things and at the same time trying to learn more about Opengl. As it is a graphic question there is how to put an image of what is…
-
0
votes1
answer36
viewsDoubt Function / Callback Golang
Do I necessarily need to deal with Sponse for the function to be executed? As it stands it says that the variable "tweet" was declared but not used, but as it is a POST request, I see no point in…
-
0
votes1
answer174
viewsFormat conversion 0001-01-01T00:00:00Z from time field. Time
I’m using the ORM Gorm for a project, and in the columns referring to the dates, according to documentation, it is necessary to set the type team. Time in Structs fields that abstract dates. The…
-
0
votes1
answer40
viewsGolang- Problems to build packages using the Ohmyzsh shell
$ go build src/github.com/Lohanguedes/firstapp Returns error: Even with the correct path to the folder, the command: go build did not complete the package I currently use Ohmyzsh, it follows the…
-
-1
votes1
answer317
viewsHow to find the largest and smallest element of an Array/Slice in Go?
Hi, guys! I would like some help. How could I find the smallest and largest element of an Array/Slice in Go? Is there a standard library function that already does this? If not, could you show me…