Skip to main content

Questions tagged [go-playground]

The Go Playground is a web service that runs on golang.org's servers. The service receives a Go program, compiles, links, and runs the program inside a sandbox, then returns the output.

go-playground
1 vote
0 answers
40 views

err.Translate(trans) only works if translator passed via param (go-playground/validator)

I'm trying to translate the validation errors message because I don't like the default error message. When I pass the trans variable via param from controllers to a helper (to handle validation error),...
Andi Fasaya Yaqhsya Ma'ruf's user avatar
0 votes
0 answers
24 views

Validate attributes comparing with a sibling struct

I have a struct that looks like this: type DataPoint struct { Config struct { ... ReferenceTimestamp time.Time `json:"referenceTimestamp" binding:"required&...
Marcelo Magnani's user avatar
2 votes
0 answers
120 views

How to validate uniqueness of nested struct inside slice

I am using go-playground/validator Does anyone know how to validate Code field for its uniqueness type Product struct { Code string `validate:"required"` } type UpdateValidation ...
Bens's user avatar
  • 926
1 vote
1 answer
1k views

How can I validate an array of strings from a JSON in Golang with validator package?

I'm using the package validator to help me deal with JSON fields in golang. I know how to use oneof to check for specific values in a field. Is there any option for doing the same, but for an array of ...
Hugo-Cruz's user avatar
  • 140
2 votes
2 answers
2k views

Accessing validation tag parameters of other fields in go-playground/validator

I'm using the go-playground/validator package to validate a struct in Go. Here is my struct definition: GetLogRequest struct { CreatedAtMin string `query:"created_at_min" validate:&...
Edwyn Rangel's user avatar
1 vote
1 answer
943 views

How to import specific version of 3rd party library in Go Playground?

Let's say I want to import version v0.11.0 of Slack Go package. In CLI I would call: go get github.com/slack-go/[email protected] but in Go Playground I can only use import. I've tried import "github....
gondo's user avatar
  • 997
2 votes
0 answers
869 views

Why doesn’t 'dive' work on gin? (about validator)

I just would like to do like the below about validation on Gin(Golang). type Accounts struct { Accounts []*Account `json:"accounts" binding:"required,dive"` } type Account ...
TomoEno's user avatar
  • 21
1 vote
1 answer
1k views

Need to validate two fields in go-playground/validator/v10

need to check atleast one of field should be present email, phone atleast one is mandatory currently I have custom validator func validateEmailPhone(fl validator.FieldLevel) bool { user := fl.Top()...
Arul Ranjith's user avatar
3 votes
3 answers
6k views

How to validate allowed fields in json body in go validation

I have a go struct which I'm using for my POST of an entity type Student struct { ID string `json:"id" firestore:"id"` Name string `json:"name&...
Sid P Tkf's user avatar
2 votes
1 answer
384 views

golang pic.ShowImage why is it not generating the image but sending me the base64 value

i use golang study golang, Is there something wrong with my goland? Need to change configuration information? my code package main import ( "golang.org/x/tour/pic" "image" ...
xin.chen's user avatar
  • 986
-1 votes
1 answer
1k views

Golang create custom validator that executes method of an interface

I am trying to create my own validator for gin, but I want it to be "generic", so let's say, I want to have an interface IsValid type IsValid interface { IsValid() bool } , and make ...
Manuelarte's user avatar
  • 1,766
0 votes
1 answer
951 views

Go playground url validate

I am sending a request which has a URL and Content in the body. The validations are such that either URL or epicentre is mandatory. The program is erroring when the URL is empty as url validate on an ...
Daffodil's user avatar
1 vote
2 answers
1k views

Backspace character does not work in the Go playground

I am new to Go. Just learnt the various uses of fmt.Println(). I tried the following stuff in the official playground but got a pretty unexpected output. Please explain where I have gone wrong in my ...
justanotherguy's user avatar
1 vote
1 answer
99 views

cmd.StdoutPipe example in go pkg docs does not run in playground

cmd.StdoutPipe example at go documentation: https://pkg.go.dev/os/exec#example-Cmd.StdoutPipe does not run in playground. https://play.golang.org/p/ek7-_Xa_bN3 Error: fatal error: all goroutines are ...
Abhay Pratap Singh's user avatar
2 votes
0 answers
2k views

How to perform the parameter type check in golang gin using validator?

I have a Validator struct like this type UploadFileFormValidator struct { File []*multipart.FileHeader `form:"File" binding:"required,min=1"` InputKey string ...
JY F's user avatar
  • 49

15 30 50 per page