Data types for validation
Posted
by nevalu
on Stack Overflow
See other posts from Stack Overflow
or by nevalu
Published on 2010-04-14T10:12:53Z
Indexed on
2010/04/14
10:23 UTC
Read the original article
Hit count: 156
go
|validation
How to create a new data type which to can check/validate its schema when is created a new variable (of that type)?
By example, to validate if a string has 20 characters, I tried:
{{{ // Format: 2006-01-12T06:06:06Z func date(str string) { if len(str) != 20 { fmt.Println("error") } } var Date = date()
type Account struct { domain string username string created Date } }}}
but it faills because Date is not a type.
© Stack Overflow or respective owner