Questions tagged as 'golang'

1
answer

Using FileServer to share files

I'm learning Golang and to practice I'm doing some small "projects", my idea is to just share a folder from my windows or some file through my local wifi network using Golang's net / http package. I used this little code below to "upar" a folder...
asked by 14.12.2017 / 20:49
1
answer

Return values in time format

I have struct with 2 ints and I need to return these values in string but in time format. type Clock struct { hour int minute int } func New(hour, minute int) Clock { return Clock{hour, minute} } func (c Cl...
asked by 27.09.2017 / 17:16
2
answers

vscode removing imports when saving file

I have a very simple code in GO . Using the vs code, when I save the file I'm working on, the editor removes import "math" Follow the code package main import "math" func main() { a := Sqrt(float64(60)) } When you save...
asked by 26.06.2017 / 20:55
2
answers

Is there any way to force ignore Go errors?

Golang forces us to manually remove unused items in the code, for example: for index, item := range retorno.Threads { fmt.Fprint(w, item.Id) } If you run a go run .... it will say:    index declared and not used And as a r...
asked by 25.05.2017 / 07:30
1
answer

Language golang

I am entering the market right now, and am pursuing internship in a development company. I have some doubts about the language of Google, Golang (Go), they are: Is there anything ready with AES and RSA encryption for the Go language?...
asked by 23.06.2017 / 22:07
1
answer

Pass pointer from sql.DB as method parameter

I have a struct that has a save method that receives a pointer for access to the database as a parameter; func (c Call) Save(db *sql.DB) error { stmt, err := db.Prepare(' INSERT INTO calls values($1, $2, $3, $4) ') i...
asked by 02.11.2018 / 20:09
1
answer

Capture Timeout on GET request

In my code I have an "attempt" to catch the timeout of method Get of package http but for some reason the error is not caught and a panic is displayed saying:    Get link : net / http: request canceled (Client.Time...
asked by 18.09.2018 / 15:23
1
answer

How to access map coming from a JSON without creating structs?

After getting some data from an endpoint I can pass them to a variable of type interface{} ; var example interface{} err := json.Unmarshal(payload, &example) If I run a fmt.Println(example) I have the following data: map[...
asked by 31.05.2018 / 21:25
1
answer

Use function from the same package with Golang

Within my project I have 2 files, main.go and price.go ; in my main.go file inside the main() function I tried to call a function from the price file that is exportable (starts with a capital letter), and when t...
asked by 19.05.2018 / 21:22
1
answer

How does the Deploy process in Golang work?

Situation In my company we are initiating a process of technology exchange. And one of the suggested ones was Golang. And one of the biggest drawbacks is the deploy process. Experiences In PHP, even because it is an interpreted langu...
asked by 13.09.2018 / 23:23