From b3845871b5dfb85131554ce5344ac3bb10549da8 Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Tue, 30 May 2023 14:24:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=89=AB=E6=8F=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=A4=84=E7=90=86=20(#3)=20(#4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- local-doc.sh | 1 + planner/configexport/internal/field_types.go | 46 ++++++++++++++++++++ tools/natapp/linux.sh | 1 + tools/natapp/mac.sh | 1 + 4 files changed, 49 insertions(+) diff --git a/local-doc.sh b/local-doc.sh index cf28bbd..7ae31e7 100644 --- a/local-doc.sh +++ b/local-doc.sh @@ -1,2 +1,3 @@ +#!/bin/bash echo Open: http://localhost:9998/pkg/github.com/kercylan98/minotaur/ godoc -http=:9998 -play \ No newline at end of file diff --git a/planner/configexport/internal/field_types.go b/planner/configexport/internal/field_types.go index c754804..eec05d9 100644 --- a/planner/configexport/internal/field_types.go +++ b/planner/configexport/internal/field_types.go @@ -3,6 +3,7 @@ package internal import ( "github.com/kercylan98/minotaur/utils/str" "github.com/tidwall/gjson" + "math" "strconv" "strings" ) @@ -147,16 +148,31 @@ func withIntType(fieldValue string) any { func withInt8Type(fieldValue string) any { value, _ := strconv.Atoi(fieldValue) + if value < 0 { + return int8(0) + } else if value > math.MaxInt8 { + return int8(math.MaxInt8) + } return int8(value) } func withInt16Type(fieldValue string) any { value, _ := strconv.Atoi(fieldValue) + if value < 0 { + return int16(0) + } else if value > math.MaxInt16 { + return int16(math.MaxInt16) + } return int16(value) } func withInt32Type(fieldValue string) any { value, _ := strconv.Atoi(fieldValue) + if value < 0 { + return int32(0) + } else if value > math.MaxInt32 { + return int32(math.MaxInt32) + } return int32(value) } @@ -167,21 +183,41 @@ func withInt64Type(fieldValue string) any { func withUintType(fieldValue string) any { value, _ := strconv.Atoi(fieldValue) + if value < 0 { + return uint(0) + } else if value > math.MaxUint { + return uint(math.MaxUint) + } return uint(value) } func withUint8Type(fieldValue string) any { value, _ := strconv.Atoi(fieldValue) + if value < 0 { + return uint8(0) + } else if value > math.MaxUint8 { + return uint8(math.MaxUint8) + } return uint8(value) } func withUint16Type(fieldValue string) any { value, _ := strconv.Atoi(fieldValue) + if value < 0 { + return uint16(0) + } else if value > math.MaxUint16 { + return uint16(math.MaxUint16) + } return uint16(value) } func withUint32Type(fieldValue string) any { value, _ := strconv.Atoi(fieldValue) + if value < 0 { + return uint32(0) + } else if value > math.MaxUint32 { + return uint32(math.MaxUint32) + } return uint32(value) } @@ -202,11 +238,21 @@ func withFloat64Type(fieldValue string) any { func withByteType(fieldValue string) any { value, _ := strconv.Atoi(fieldValue) + if value < 0 { + return byte(0) + } else if value > math.MaxUint8 { + return byte(math.MaxInt8) + } return byte(value) } func withRuneType(fieldValue string) any { value, _ := strconv.Atoi(fieldValue) + if value < math.MinInt32 { + return rune(0) + } else if value > math.MaxInt32 { + return rune(math.MaxInt32) + } return rune(value) } diff --git a/tools/natapp/linux.sh b/tools/natapp/linux.sh index 755ea85..36eab39 100644 --- a/tools/natapp/linux.sh +++ b/tools/natapp/linux.sh @@ -1 +1,2 @@ +#!/bin/bash linux -authtoken=530800a5794d7c8c \ No newline at end of file diff --git a/tools/natapp/mac.sh b/tools/natapp/mac.sh index a4dbf2a..1588371 100644 --- a/tools/natapp/mac.sh +++ b/tools/natapp/mac.sh @@ -1 +1,2 @@ +#!/bin/bash mac -authtoken=530800a5794d7c8c \ No newline at end of file