Questions tagged as 'golang'

1
answer

How to update column for each SELECT in a given table?

I tried to create a trigger for a table using it so that it would be activated after every select , but by searching a little I discovered that it is not possible to create triggers for selections, only for update, insert ) a...
asked by 13.06.2018 / 18:49
1
answer

Use function in another Golang folder

I created a pacote within $GOPATH/src/github.com/meu-user/meupacote with a meupacote.go file that has the main function and another folder with the name products that has the products.go file, in this my...
asked by 18.01.2018 / 00:58
1
answer

Convert multiple nodes in XML to struct

I looked for some examples in the official documentation of golang and in some online tutorials but only find simple examples see: <data> <person> <firstname>Nic</firstname> <lastname>Ra...
asked by 18.01.2018 / 01:31
1
answer

Why does this loop with goroutines only repeat the last value?

This loop is always repeating the last value, consider the following: type unique struct { id, nonce uint64 } func (unique *unique) print() { fmt.Println(unique.id) } func main() { teste := []unique{unique{1, 2}, unique{3, 4...
asked by 24.06.2017 / 11:19
2
answers

Persist JSON Postgres / Golang

Hello, is there any way to persist a JSON in postgres with GO language? I do not want to do a manual insert, I want to map my JSON with a struct and persist, similar to hibernate in Java. I found this lib link Convert my JSON to BSON...
asked by 16.04.2015 / 13:36
0
answers

Login with GORM with return interspersed between ID and 0

Well, I'm learning to program in the GO language, and I made an api with a login system. func Authenticate(db *gorm.DB, auth models.UserAuthForm) uint { hasher.Write([]byte(auth.Password)) pass_hash := hex.EncodeToString(hasher.Sum(nil...
asked by 02.11.2018 / 16:27
1
answer

Date range by week number

With this simple function, I can get the week number. Now with the number of the week, how can I get the date range, started on Sunday? import ( "fmt" "time" ) func main() { Week(time.Now().UTC()) } func Week(now time.Time) strin...
asked by 12.09.2018 / 13:56
1
answer

Problem catching the title of a URL using regular expression

I'm learning Go language on the competition side. I was challenged to use the default generator to get a channel that reads the title of a URL through a goroutine. Inside this goroutine that I mounted, the reading is performed through the GET...
asked by 07.10.2018 / 19:10
0
answers

How to export package documentation with css using godoc?

After writing my package I know that it is possible to generate an html page with all the documentation provided through comments in my code; godoc -html github.com/user/package > index.html But the generated file ( index.html...
asked by 02.06.2018 / 02:04
1
answer

How to show reason for error 422 in GO

Lately I'm breaking my head to debug POST and PUT requests where the HTTP 422 (Incorrect Input Format) error always occurs In my project I'm using the GIN framework to do a JSON BIND from the front end. I needed to know what the structure att...
asked by 27.12.2016 / 18:22