Fix most compiler errors
Cette révision appartient à :
Parent
4c8306a6fc
révision
e139f5e4db
23 fichiers modifiés avec 52 ajouts et 203 suppressions
|
@ -10,7 +10,7 @@ import (
|
|||
elastic "gopkg.in/olivere/elastic.v5"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/config"
|
||||
"github.com/NyaaPantsu/nyaa/model"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/NyaaPantsu/nyaa/util/log"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
|
@ -6,8 +6,9 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/service/activity"
|
||||
"github.com/NyaaPantsu/nyaa/service/user/permission"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/NyaaPantsu/nyaa/models/activities"
|
||||
"github.com/NyaaPantsu/nyaa/util/cookies"
|
||||
"github.com/NyaaPantsu/nyaa/util/log"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
|
@ -8,17 +8,14 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/config"
|
||||
"github.com/NyaaPantsu/nyaa/db"
|
||||
"github.com/NyaaPantsu/nyaa/model"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/NyaaPantsu/nyaa/models/torrents"
|
||||
"github.com/NyaaPantsu/nyaa/service"
|
||||
"github.com/NyaaPantsu/nyaa/service/api"
|
||||
"github.com/NyaaPantsu/nyaa/service/torrent"
|
||||
"github.com/NyaaPantsu/nyaa/service/user"
|
||||
"github.com/NyaaPantsu/nyaa/service/user/form"
|
||||
"github.com/NyaaPantsu/nyaa/util/cookies"
|
||||
"github.com/NyaaPantsu/nyaa/util/crypto"
|
||||
"github.com/NyaaPantsu/nyaa/util/log"
|
||||
msg "github.com/NyaaPantsu/nyaa/util/messages"
|
||||
"github.com/NyaaPantsu/nyaa/util/modelHelper"
|
||||
"github.com/NyaaPantsu/nyaa/util/search"
|
||||
"github.com/NyaaPantsu/nyaa/util/upload"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/model"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/NyaaPantsu/nyaa/util/log"
|
||||
"github.com/NyaaPantsu/nyaa/util/metainfo"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
|
|
@ -2,8 +2,8 @@ package controllers
|
|||
|
||||
import (
|
||||
"github.com/NyaaPantsu/nyaa/common"
|
||||
"github.com/NyaaPantsu/nyaa/model"
|
||||
"github.com/NyaaPantsu/nyaa/service/user"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/NyaaPantsu/nyaa/util/cookies"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package controllers
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/service/user/permission"
|
||||
"github.com/NyaaPantsu/nyaa/util/cookies"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
|
|
|
@ -8,17 +8,13 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/config"
|
||||
"github.com/NyaaPantsu/nyaa/db"
|
||||
"github.com/NyaaPantsu/nyaa/model"
|
||||
"github.com/NyaaPantsu/nyaa/service"
|
||||
"github.com/NyaaPantsu/nyaa/service/activity"
|
||||
"github.com/NyaaPantsu/nyaa/service/api"
|
||||
"github.com/NyaaPantsu/nyaa/service/comment"
|
||||
"github.com/NyaaPantsu/nyaa/service/report"
|
||||
"github.com/NyaaPantsu/nyaa/service/torrent"
|
||||
"github.com/NyaaPantsu/nyaa/service/user"
|
||||
"github.com/NyaaPantsu/nyaa/service/user/permission"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/NyaaPantsu/nyaa/models/activities"
|
||||
"github.com/NyaaPantsu/nyaa/models/comments"
|
||||
"github.com/NyaaPantsu/nyaa/models/reports"
|
||||
"github.com/NyaaPantsu/nyaa/models/torrents"
|
||||
"github.com/NyaaPantsu/nyaa/util/categories"
|
||||
"github.com/NyaaPantsu/nyaa/util/cookies"
|
||||
"github.com/NyaaPantsu/nyaa/util/log"
|
||||
msg "github.com/NyaaPantsu/nyaa/util/messages"
|
||||
"github.com/NyaaPantsu/nyaa/util/search"
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"net/url"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/config"
|
||||
"github.com/NyaaPantsu/nyaa/service/user"
|
||||
"github.com/NyaaPantsu/nyaa/util/cookies"
|
||||
msg "github.com/NyaaPantsu/nyaa/util/messages"
|
||||
"github.com/NyaaPantsu/nyaa/util/publicSettings"
|
||||
"github.com/NyaaPantsu/nyaa/util/timeHelper"
|
||||
|
|
|
@ -11,9 +11,9 @@ import (
|
|||
"sort"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/config"
|
||||
"github.com/NyaaPantsu/nyaa/model"
|
||||
userService "github.com/NyaaPantsu/nyaa/service/user"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/NyaaPantsu/nyaa/util/categories"
|
||||
userService "github.com/NyaaPantsu/nyaa/util/cookies"
|
||||
"github.com/NyaaPantsu/nyaa/util/feeds"
|
||||
"github.com/NyaaPantsu/nyaa/util/publicSettings"
|
||||
"github.com/NyaaPantsu/nyaa/util/search"
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/model"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/NyaaPantsu/nyaa/util/log"
|
||||
"github.com/NyaaPantsu/nyaa/util/search"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"path"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/config"
|
||||
"github.com/NyaaPantsu/nyaa/model"
|
||||
userForms "github.com/NyaaPantsu/nyaa/service/user/form"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
userForms "github.com/NyaaPantsu/nyaa/util/cookies"
|
||||
"github.com/NyaaPantsu/nyaa/util/filelist"
|
||||
"github.com/NyaaPantsu/nyaa/util/messages"
|
||||
"github.com/NyaaPantsu/nyaa/util/publicSettings"
|
||||
|
|
|
@ -10,12 +10,12 @@ import (
|
|||
|
||||
"github.com/CloudyKit/jet"
|
||||
"github.com/NyaaPantsu/nyaa/config"
|
||||
"github.com/NyaaPantsu/nyaa/model"
|
||||
"github.com/NyaaPantsu/nyaa/service/activity"
|
||||
"github.com/NyaaPantsu/nyaa/service/torrent"
|
||||
"github.com/NyaaPantsu/nyaa/service/user/permission"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/NyaaPantsu/nyaa/models/activities"
|
||||
"github.com/NyaaPantsu/nyaa/models/torrents"
|
||||
"github.com/NyaaPantsu/nyaa/util"
|
||||
"github.com/NyaaPantsu/nyaa/util/categories"
|
||||
"github.com/NyaaPantsu/nyaa/util/cookies"
|
||||
"github.com/NyaaPantsu/nyaa/util/filelist"
|
||||
"github.com/NyaaPantsu/nyaa/util/publicSettings"
|
||||
"github.com/NyaaPantsu/nyaa/util/torrentLanguages"
|
||||
|
|
|
@ -6,12 +6,11 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/db"
|
||||
"github.com/NyaaPantsu/nyaa/model"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/NyaaPantsu/nyaa/models/torrents"
|
||||
"github.com/NyaaPantsu/nyaa/service/api"
|
||||
"github.com/NyaaPantsu/nyaa/service/torrent"
|
||||
"github.com/NyaaPantsu/nyaa/service/user/permission"
|
||||
"github.com/NyaaPantsu/nyaa/util/captcha"
|
||||
"github.com/NyaaPantsu/nyaa/util/cookies"
|
||||
"github.com/NyaaPantsu/nyaa/util/log"
|
||||
msg "github.com/NyaaPantsu/nyaa/util/messages"
|
||||
"github.com/NyaaPantsu/nyaa/util/publicSettings"
|
||||
|
|
|
@ -6,15 +6,12 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/model"
|
||||
"github.com/NyaaPantsu/nyaa/service/notifier"
|
||||
"github.com/NyaaPantsu/nyaa/service/user"
|
||||
"github.com/NyaaPantsu/nyaa/service/user/form"
|
||||
"github.com/NyaaPantsu/nyaa/service/user/permission"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/NyaaPantsu/nyaa/models/notifications"
|
||||
"github.com/NyaaPantsu/nyaa/util/captcha"
|
||||
"github.com/NyaaPantsu/nyaa/util/cookies"
|
||||
"github.com/NyaaPantsu/nyaa/util/crypto"
|
||||
msg "github.com/NyaaPantsu/nyaa/util/messages"
|
||||
"github.com/NyaaPantsu/nyaa/util/modelHelper"
|
||||
"github.com/NyaaPantsu/nyaa/util/publicSettings"
|
||||
"github.com/NyaaPantsu/nyaa/util/search"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
|
|
@ -12,17 +12,15 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/config"
|
||||
"github.com/NyaaPantsu/nyaa/db"
|
||||
"github.com/NyaaPantsu/nyaa/model"
|
||||
"github.com/NyaaPantsu/nyaa/service"
|
||||
"github.com/NyaaPantsu/nyaa/service/activity"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/NyaaPantsu/nyaa/models/activities"
|
||||
"github.com/NyaaPantsu/nyaa/models/notifications"
|
||||
"github.com/NyaaPantsu/nyaa/models/reports"
|
||||
"github.com/NyaaPantsu/nyaa/models/torrents"
|
||||
"github.com/NyaaPantsu/nyaa/service/api"
|
||||
"github.com/NyaaPantsu/nyaa/service/notifier"
|
||||
"github.com/NyaaPantsu/nyaa/service/report"
|
||||
"github.com/NyaaPantsu/nyaa/service/torrent"
|
||||
"github.com/NyaaPantsu/nyaa/service/user/permission"
|
||||
"github.com/NyaaPantsu/nyaa/util"
|
||||
"github.com/NyaaPantsu/nyaa/util/captcha"
|
||||
"github.com/NyaaPantsu/nyaa/util/cookies"
|
||||
"github.com/NyaaPantsu/nyaa/util/filelist"
|
||||
msg "github.com/NyaaPantsu/nyaa/util/messages"
|
||||
"github.com/NyaaPantsu/nyaa/util/publicSettings"
|
||||
|
|
3
main.go
3
main.go
|
@ -11,8 +11,7 @@ import (
|
|||
|
||||
"github.com/NyaaPantsu/nyaa/config"
|
||||
"github.com/NyaaPantsu/nyaa/controllers"
|
||||
"github.com/NyaaPantsu/nyaa/db"
|
||||
"github.com/NyaaPantsu/nyaa/service/user"
|
||||
"github.com/NyaaPantsu/nyaa/util/cookies"
|
||||
"github.com/NyaaPantsu/nyaa/util/log"
|
||||
"github.com/NyaaPantsu/nyaa/util/publicSettings"
|
||||
"github.com/NyaaPantsu/nyaa/util/search"
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"nyaa-master/util/log"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strconv"
|
||||
|
@ -19,6 +18,7 @@ import (
|
|||
|
||||
"github.com/NyaaPantsu/nyaa/config"
|
||||
"github.com/NyaaPantsu/nyaa/util"
|
||||
"github.com/NyaaPantsu/nyaa/util/log"
|
||||
"github.com/bradfitz/slice"
|
||||
)
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ package torrents
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/NyaaPantsu/nyaa/util/log"
|
||||
"net/http"
|
||||
"nyaa-master/util/log"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@ package models
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"nyaa-master/util/log"
|
||||
"github.com/NyaaPantsu/nyaa/util/log"
|
||||
"time"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/config"
|
||||
|
|
|
@ -3,7 +3,7 @@ package filelist
|
|||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/model"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/bradfitz/slice"
|
||||
)
|
||||
|
||||
|
|
|
@ -9,10 +9,9 @@ import (
|
|||
|
||||
"github.com/NyaaPantsu/nyaa/common"
|
||||
"github.com/NyaaPantsu/nyaa/config"
|
||||
"github.com/NyaaPantsu/nyaa/db"
|
||||
"github.com/NyaaPantsu/nyaa/model"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
"github.com/NyaaPantsu/nyaa/models/torrents"
|
||||
"github.com/NyaaPantsu/nyaa/service"
|
||||
"github.com/NyaaPantsu/nyaa/service/torrent"
|
||||
"github.com/NyaaPantsu/nyaa/util/log"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"net/url"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/config"
|
||||
"github.com/NyaaPantsu/nyaa/model"
|
||||
"github.com/NyaaPantsu/nyaa/models"
|
||||
)
|
||||
|
||||
// CheckTrackers : Check if there is good trackers in torrent
|
||||
|
|
|
@ -4,153 +4,16 @@ import (
|
|||
"reflect"
|
||||
"strconv"
|
||||
|
||||
"github.com/asaskevich/govalidator"
|
||||
"github.com/NyaaPantsu/nyaa/util/log"
|
||||
msg "github.com/NyaaPantsu/nyaa/util/messages"
|
||||
)
|
||||
|
||||
// TODO: Rewrite module
|
||||
// Functions are highly complex and require a lot of additional error handling
|
||||
|
||||
func IsZeroOfUnderlyingType(x interface{}) bool {
|
||||
return x == reflect.Zero(reflect.TypeOf(x)).Interface()
|
||||
}
|
||||
|
||||
// AssignValue assign form values to model.
|
||||
func AssignValue(model interface{}, form interface{}) {
|
||||
modelIndirect := reflect.Indirect(reflect.ValueOf(model))
|
||||
formElem := reflect.ValueOf(form).Elem()
|
||||
typeOfTForm := formElem.Type()
|
||||
for i := 0; i < formElem.NumField(); i++ {
|
||||
tag := typeOfTForm.Field(i).Tag
|
||||
if tag.Get("omit") != "true" {
|
||||
modelField := modelIndirect.FieldByName(typeOfTForm.Field(i).Name)
|
||||
if modelField.IsValid() {
|
||||
formField := formElem.Field(i)
|
||||
modelField.Set(formField)
|
||||
} else {
|
||||
log.Warnf("modelField : %s - %s", typeOfTForm.Field(i).Name, modelField)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BindValueForm assign populate form from a request
|
||||
/* Deprecated, we use gin.Bind
|
||||
func BindValueForm(form interface{}, c *gin.Context) {
|
||||
formElem := reflect.ValueOf(form).Elem()
|
||||
for i := 0; i < formElem.NumField(); i++ {
|
||||
typeField := formElem.Type().Field(i)
|
||||
tag := typeField.Tag
|
||||
switch typeField.Type.Name() {
|
||||
case "string":
|
||||
formElem.Field(i).SetString(c.PostForm(tag.Get("form")))
|
||||
case "int":
|
||||
nbr, _ := strconv.Atoi(c.PostForm(tag.Get("form")))
|
||||
formElem.Field(i).SetInt(int64(nbr))
|
||||
case "float":
|
||||
nbr, _ := strconv.Atoi(c.PostForm(tag.Get("form")))
|
||||
formElem.Field(i).SetFloat(float64(nbr))
|
||||
case "bool":
|
||||
nbr, _ := strconv.ParseBool(c.PostForm(tag.Get("form")))
|
||||
formElem.Field(i).SetBool(nbr)
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
/
|
||||
|
||||
// ValidateForm : Check if a form is valid according to its tags
|
||||
func ValidateForm(form interface{}, mes *msg.Messages) {
|
||||
formElem := reflect.ValueOf(form).Elem()
|
||||
for i := 0; i < formElem.NumField(); i++ {
|
||||
typeField := formElem.Type().Field(i)
|
||||
tag := typeField.Tag
|
||||
inputName := typeField.Name
|
||||
if tag.Get("hum_name") != "" { // For more human input name than gibberish
|
||||
inputName = tag.Get("hum_name")
|
||||
}
|
||||
if tag.Get("len_min") != "" && (tag.Get("needed") != "" || formElem.Field(i).Len() > 0) { // Check minimum length
|
||||
checkMinLength(formElem.Field(i), tag, inputName, mes)
|
||||
}
|
||||
if tag.Get("len_max") != "" && (tag.Get("needed") != "" || formElem.Field(i).Len() > 0) { // Check maximum length
|
||||
checkMaxLength(formElem.Field(i), tag, inputName, mes)
|
||||
}
|
||||
if tag.Get("equalInput") != "" && (tag.Get("needed") != "" || formElem.Field(i).Len() > 0) {
|
||||
checkEqualValue(formElem, i, tag, inputName, mes)
|
||||
}
|
||||
checksOnFieldTypes(formElem.Field(i), inputName, typeField, tag, mes)
|
||||
}
|
||||
}
|
||||
|
||||
func checkMinLength(fieldElem reflect.Value, tag reflect.StructTag, inputName string, mes *msg.Messages) {
|
||||
lenMin, _ := strconv.Atoi(tag.Get("len_min"))
|
||||
if fieldElem.Len() < lenMin {
|
||||
mes.AddErrorTf(tag.Get("form"), "error_min_length", strconv.Itoa(lenMin), inputName)
|
||||
}
|
||||
}
|
||||
func checkMaxLength(fieldElem reflect.Value, tag reflect.StructTag, inputName string, mes *msg.Messages) {
|
||||
lenMax, _ := strconv.Atoi(tag.Get("len_max"))
|
||||
if fieldElem.Len() > lenMax {
|
||||
mes.AddErrorTf(tag.Get("form"), "error_max_length", strconv.Itoa(lenMax), inputName)
|
||||
}
|
||||
}
|
||||
|
||||
func checkEqualValue(formElem reflect.Value, i int, tag reflect.StructTag, inputName string, mes *msg.Messages) {
|
||||
otherInput := formElem.FieldByName(tag.Get("equalInput"))
|
||||
if formElem.Field(i).Interface() != otherInput.Interface() {
|
||||
mes.AddErrorTf(tag.Get("form"), "error_same_value", inputName)
|
||||
}
|
||||
}
|
||||
|
||||
func checksOnFieldTypes(fieldElem reflect.Value, inputName string, typeField reflect.StructField, tag reflect.StructTag, mes *msg.Messages) {
|
||||
switch typeField.Type.Name() {
|
||||
case "string":
|
||||
if tag.Get("equal") != "" && fieldElem.String() != tag.Get("equal") {
|
||||
mes.AddErrorTf(tag.Get("form"), "error_wrong_value", inputName)
|
||||
}
|
||||
if tag.Get("needed") != "" && fieldElem.String() == "" {
|
||||
mes.AddErrorTf(tag.Get("form"), "error_field_needed", inputName)
|
||||
}
|
||||
if fieldElem.String() == "" && tag.Get("default") != "" {
|
||||
fieldElem.SetString(tag.Get("default"))
|
||||
}
|
||||
case "int":
|
||||
if tag.Get("equal") != "" { // Check minimum length
|
||||
equal, _ := strconv.Atoi(tag.Get("equal"))
|
||||
if fieldElem.Int() > int64(equal) {
|
||||
mes.AddErrorTf(tag.Get("form"), "error_wrong_value", inputName)
|
||||
}
|
||||
}
|
||||
if tag.Get("needed") != "" && fieldElem.Int() == 0 {
|
||||
mes.AddErrorTf(tag.Get("form"), "error_field_needed", inputName)
|
||||
}
|
||||
if fieldElem.Int() == 0 && tag.Get("default") != "" && tag.Get("notnull") != "" {
|
||||
defaultValue, _ := strconv.Atoi(tag.Get("default"))
|
||||
fieldElem.SetInt(int64(defaultValue))
|
||||
}
|
||||
case "float":
|
||||
if tag.Get("equal") != "" { // Check minimum length
|
||||
equal, _ := strconv.Atoi(tag.Get("equal"))
|
||||
if fieldElem.Float() != float64(equal) {
|
||||
mes.AddErrorTf(tag.Get("form"), "error_wrong_value", inputName)
|
||||
}
|
||||
}
|
||||
if tag.Get("needed") != "" && fieldElem.Float() == 0 {
|
||||
mes.AddErrorTf(tag.Get("form"), "error_field_needed", inputName)
|
||||
}
|
||||
if fieldElem.Float() == 0 && tag.Get("default") != "" && tag.Get("notnull") != "" {
|
||||
defaultValue, _ := strconv.Atoi(tag.Get("default"))
|
||||
fieldElem.SetFloat(float64(defaultValue))
|
||||
}
|
||||
case "bool":
|
||||
if tag.Get("equal") != "" { // Check minimum length
|
||||
equal, _ := strconv.ParseBool(tag.Get("equal"))
|
||||
if fieldElem.Bool() != equal {
|
||||
mes.AddErrorTf(tag.Get("form"), "error_wrong_value", inputName)
|
||||
}
|
||||
}
|
||||
if !fieldElem.Bool() && tag.Get("default") != "" && tag.Get("notnull") != "" {
|
||||
defaultValue, _ := strconv.ParseBool(tag.Get("default"))
|
||||
fieldElem.SetBool(defaultValue)
|
||||
}
|
||||
result, err := govalidator.ValidateStruct(post)
|
||||
if err != nil {
|
||||
println("error: " + err.Error())
|
||||
}
|
||||
}
|
||||
|
|
Référencer dans un nouveau ticket