Compare commits

..

8 Commits

Author SHA1 Message Date
627aa5d27f fix: Update version to v2.9.3 (#4417)
Change all references from v2.9.2 to v2.9.3 and update the release name
accordingly.
2025-09-03 12:48:06 +08:00
47db44843e fix(os/gtime): fix gtime time string handle logic (#4409)
1、gtime的StrToTime方法优化对时间字段格式兼容处理,并且针对时间越界抛出异常。
2、移除部分无用代码:
<img width="697" height="282" alt="image"
src="https://github.com/user-attachments/assets/92a88140-37c0-4ee1-aef7-c6418e9edd06"
/>

Fixes #4394

---------

Signed-off-by: Zjmainstay <hzgdys@163.com>
Co-authored-by: hailaz <739476267@qq.com>
2025-09-03 12:19:27 +08:00
a39498f74f fix: update gf cli to v2.9.3-rc4 (#4416)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action

Co-authored-by: hailaz <hailaz@users.noreply.github.com>
2025-09-03 11:51:14 +08:00
80b866e11c fix: Update dependencies and exclude test data from go.mod processing (#4415)
Update dependencies and ensure that go.mod files in the test data
directory are excluded from processing during the tag creation for the
CLI tool.
2025-09-03 11:42:44 +08:00
2a77d3203e fix: Improve the typeMap check logic of "gf gen dao" (#4410)
Let it can support such as "Array(UInt256)", "Array(FixedString(25))".
Now we can typeMap as:
"array(uint256)": []big.Int
"array(fixedstring(25))": [25]string
"array(fixedstring)": []string
"array": []any

Now it will first match more precise rules. So it will match
array(uint256) and array(fixedstring(25)) first. Then the
"array(fixedstring)", the last is "array"
2025-09-03 11:16:38 +08:00
3c451bef82 fix: path ./cmd/gf (#4414) 2025-09-03 10:53:50 +08:00
5073f25691 chore: chmod +x update_version.sh (#4413) 2025-09-03 10:36:56 +08:00
40e97f1325 fix: #4269 (#4412)
fixed #4269
2025-09-02 22:49:05 +08:00
39 changed files with 282 additions and 101 deletions

View File

@ -47,9 +47,9 @@ jobs:
# Service containers to run with `code-test`
services:
# Etcd service.
# docker run -d --name etcd -p 2379:2379 -e ALLOW_NONE_AUTHENTICATION=yes bitnami/etcd:3.4.24
# docker run -d --name etcd -p 2379:2379 -e ALLOW_NONE_AUTHENTICATION=yes bitnamilegacy/etcd:3.4.24
etcd:
image: bitnami/etcd:3.4.24
image: bitnamilegacy/etcd:3.4.24
env:
ALLOW_NONE_AUTHENTICATION: yes
ports:

View File

@ -52,7 +52,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
name: GoFrame Release ${{ github.ref }}
name: GoFrame Release ${{ github.ref_name }}
draft: false
prerelease: false

50
.github/workflows/scripts/update_version.sh vendored Executable file
View File

@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Check if the number of parameters is 2
if [ $# -ne 2 ]; then
echo "Invalid parameters, please execute in format: version.sh [directory] [version]"
echo "Example: version.sh ./contrib v1.0.0"
exit 1
fi
# Check if the first parameter is a directory and exists
if [ ! -d "$1" ]; then
echo "Error: Directory does not exist"
exit 1
fi
# Check if the second parameter starts with 'v'
if [[ "$2" != v* ]]; then
echo "Error: Version number does not start with 'v'"
exit 1
fi
workdir=$1
newVersion=$2
echo "Preparing to replace version numbers in all go.mod files under ${workdir} directory to ${newVersion}"
# Check if file exists
if [ -f "go.work" ]; then
# File exists, rename it
mv go.work go.work.${newVersion}
echo "Backup go.work file to avoid affecting the upgrade"
fi
for file in `find ${workdir} -name go.mod`; do
goModPath=$(dirname $file)
echo ""
echo "processing dir: $goModPath"
cd $goModPath
go mod tidy
go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion}{{end}}" -m all | grep "^github.com/gogf/gf"
go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion}{{end}}" -m all | grep "^github.com/gogf/gf" | xargs -L1 go get -v
go mod tidy
cd -
done
if [ -f "go.work.${newVersion}" ]; then
# File exists, rename it back
mv go.work.${newVersion} go.work
echo "Restore go.work file"
fi

View File

@ -4,13 +4,12 @@ on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
env:
TZ: Asia/Shanghai
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: Auto Creating Tags
@ -18,22 +17,43 @@ jobs:
steps:
- name: Checkout Github Code
uses: actions/checkout@v5
- name: Auto Creating Tags For Contrib Packages
run: |
git config --global user.email "tagrobot@goframe.org"
git config --global user.name "TagRobot"
# auto create tags for contrib packages.
for file in `find contrib -name go.mod`; do
tag=$(dirname $file)/$GITHUB_REF_NAME
tag=$(dirname $file)/${{ github.ref_name }}
git tag $tag
git push origin $tag
done
- name: update dependencies
run: |
go env -w GOPRIVATE=github.com/gogf/gf
.github/workflows/scripts/update_version.sh ./cmd/gf ${{ github.ref_name }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
commit-message: 'update gf cli to ${{ github.ref_name }}'
title: 'fix: update gf cli to ${{ github.ref_name }}'
base: master
branch: fix/${{ github.ref_name }}
delete-branch: true
- name: Commit & Push changes
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: fix/${{ github.ref_name }}
author_name: TagRobot
author_email: tagrobot@goframe.org
message: 'fix: update gf cli to ${{ github.ref_name }}'
- name: Auto Creating Tags For cli tool
run: |
git config --global user.email "tagrobot@goframe.org"
git config --global user.name "TagRobot"
# auto create tag for cli tool
for file in `find cmd -name go.mod`; do
tag=$(dirname $file)/$GITHUB_REF_NAME
for file in `find cmd -name go.mod -not -path "*/testdata/*"`; do
tag=$(dirname $file)/${{ github.ref_name }}
git tag $tag
git push origin $tag
done

View File

@ -1,4 +1,19 @@
#!/usr/bin/env bash
# Function to detect OS and set sed parameters
setup_sed() {
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
SED_INPLACE="sed -i ''"
else
# Linux/Windows Git Bash
SED_INPLACE="sed -i"
fi
}
# Initialize sed command
setup_sed
if [ $# -ne 2 ]; then
echo "Parameter exception, please execute in the format of $0 [directory] [version number]"
echo "PS$0 ./ v2.4.0"
@ -28,10 +43,10 @@ fi
if [[ true ]]; then
# Use sed to replace the version number in version.go
sed -i '' 's/VERSION = ".*"/VERSION = "'${newVersion}'"/' version.go
$SED_INPLACE 's/VERSION = ".*"/VERSION = "'${newVersion}'"/' version.go
# Use sed to replace the version number in README.MD
sed -i '' 's/version=[^"]*/version='${newVersion}'/' README.MD
$SED_INPLACE 's/version=[^"]*/version='${newVersion}'/' README.MD
fi
if [ -f "go.work" ]; then
@ -67,7 +82,7 @@ for file in `find ${workdir} -name go.mod`; do
fi
go mod tidy
# Remove toolchain line if exists
sed -i '' '/^toolchain/d' go.mod
$SED_INPLACE '/^toolchain/d' go.mod
# Upgrading only GoFrame related libraries, sometimes even if a version number is specified,
# it may not be possible to successfully upgrade. Please confirm before submitting the code
@ -75,7 +90,7 @@ for file in `find ${workdir} -name go.mod`; do
go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion}{{end}}" -m all | grep "^github.com/gogf/gf" | xargs -L1 go get -v
go mod tidy
# Remove toolchain line if exists
sed -i '' '/^toolchain/d' go.mod
$SED_INPLACE '/^toolchain/d' go.mod
if [ $goModPath = "./cmd/gf" ]; then
go mod edit -dropreplace github.com/gogf/gf/v2
go mod edit -dropreplace github.com/gogf/gf/contrib/drivers/clickhouse/v2

View File

@ -38,7 +38,7 @@ A powerful framework for faster, easier, and more efficient project development.
💖 [Thanks to all the contributors who made GoFrame possible](https://github.com/gogf/gf/graphs/contributors) 💖
<a href="https://github.com/gogf/gf/graphs/contributors">
<img src="https://goframe.org/img/contributors.svg?version=v2.9.0" alt="goframe contributors"/>
<img src="https://goframe.org/img/contributors.svg?version=v2.9.3" alt="goframe contributors"/>
</a>
# License

View File

@ -3,13 +3,13 @@ module github.com/gogf/gf/cmd/gf/v2
go 1.23.0
require (
github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.9.2
github.com/gogf/gf/contrib/drivers/mssql/v2 v2.9.2
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.9.2
github.com/gogf/gf/contrib/drivers/oracle/v2 v2.9.2
github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.9.2
github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.9.3
github.com/gogf/gf/contrib/drivers/mssql/v2 v2.9.3
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.9.3
github.com/gogf/gf/contrib/drivers/oracle/v2 v2.9.3
github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.9.3
github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.9.3
github.com/gogf/gf/v2 v2.9.3
github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f
github.com/olekukonko/tablewriter v1.0.9
github.com/schollz/progressbar/v3 v3.15.0

View File

@ -55,7 +55,7 @@ func TestGenPbIssue3882(t *testing.T) {
func TestGenPbIssue3953(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
var (
outputPath = gfile.Temp(guid.S())
outputPath = gfile.Temp("f" + guid.S())
outputApiPath = filepath.Join(outputPath, "api")
outputCtrlPath = filepath.Join(outputPath, "controller")

View File

@ -59,6 +59,37 @@ func generateStructDefinition(ctx context.Context, in generateStructDefinitionIn
return buffer.String(), appendImports
}
func getTypeMappingInfo(
ctx context.Context, fieldType string, inTypeMapping map[DBFieldTypeName]CustomAttributeType,
) (typeNameStr, importStr string) {
if typeMapping, ok := inTypeMapping[strings.ToLower(fieldType)]; ok {
typeNameStr = typeMapping.Type
importStr = typeMapping.Import
return
}
tryTypeMatch, _ := gregex.MatchString(`(.+?)\(([^\(\)]+)\)([\s\)]*)`, fieldType)
var (
tryTypeName string
moreTry bool
)
if len(tryTypeMatch) == 4 {
tryTypeMatch3, _ := gregex.ReplaceString(`\s+`, "", tryTypeMatch[3])
tryTypeName = gstr.Trim(tryTypeMatch[1]) + tryTypeMatch3
moreTry = tryTypeMatch3 != ""
} else {
tryTypeName = gstr.Split(fieldType, " ")[0]
}
if tryTypeName != "" {
if typeMapping, ok := inTypeMapping[strings.ToLower(tryTypeName)]; ok {
typeNameStr = typeMapping.Type
importStr = typeMapping.Import
} else if moreTry {
typeNameStr, importStr = getTypeMappingInfo(ctx, tryTypeName, inTypeMapping)
}
}
return
}
// generateStructFieldDefinition generates and returns the attribute definition for specified field.
func generateStructFieldDefinition(
ctx context.Context, field *gdb.TableField, in generateStructDefinitionInput,
@ -71,21 +102,7 @@ func generateStructFieldDefinition(
)
if in.TypeMapping != nil && len(in.TypeMapping) > 0 {
var (
tryTypeName string
)
tryTypeMatch, _ := gregex.MatchString(`(.+?)\((.+)\)`, field.Type)
if len(tryTypeMatch) == 3 {
tryTypeName = gstr.Trim(tryTypeMatch[1])
} else {
tryTypeName = gstr.Split(field.Type, " ")[0]
}
if tryTypeName != "" {
if typeMapping, ok := in.TypeMapping[strings.ToLower(tryTypeName)]; ok {
localTypeNameStr = typeMapping.Type
appendImport = typeMapping.Import
}
}
localTypeNameStr, appendImport = getTypeMappingInfo(ctx, field.Type, in.TypeMapping)
}
if localTypeNameStr == "" {

View File

@ -1,12 +1,15 @@
module github.com/gogf/gf/cmd/gf/cmd/gf/testdata/vardump/v2
go 1.22
go 1.23.0
require github.com/gogf/gf/v2 v2.8.2
toolchain go1.24.6
require github.com/gogf/gf/v2 v2.9.3-rc4
require (
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
go.opentelemetry.io/otel v1.37.0 // indirect
go.opentelemetry.io/otel/trace v1.37.0 // indirect
golang.org/x/text v0.28.0 // indirect
)
replace github.com/gogf/gf/v2 => ../../../../../../../

View File

@ -1,31 +1,62 @@
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc=
github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE=
github.com/magiconair/properties v1.8.10/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/olekukonko/errors v1.1.0 h1:RNuGIh15QdDenh+hNvKrJkmxxjV4hcS50Db478Ou5sM=
github.com/olekukonko/errors v1.1.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y=
github.com/olekukonko/ll v0.0.9 h1:Y+1YqDfVkqMWuEQMclsF9HUR5+a82+dxJuL1HHSRpxI=
github.com/olekukonko/ll v0.0.9/go.mod h1:En+sEW0JNETl26+K8eZ6/W4UQ7CYSrrgg/EdIYT2H8g=
github.com/olekukonko/tablewriter v1.0.9 h1:XGwRsYLC2bY7bNd93Dk51bcPZksWZmLYuaTHR0FqfL8=
github.com/olekukonko/tablewriter v1.0.9/go.mod h1:5c+EBPeSqvXnLLgkm9isDdzR3wjfBkHR9Nhfp3NWrzo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ=
go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I=
go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE=
go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E=
go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI=
go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg=
go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4=
go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0=
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -4,7 +4,7 @@ go 1.23.0
require (
github.com/apolloconfig/agollo/v4 v4.3.1
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
)
require (

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/consul/v2
go 1.23.0
require (
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
github.com/hashicorp/consul/api v1.24.0
github.com/hashicorp/go-cleanhttp v0.5.2
)

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/kubecm/v2
go 1.24.0
require (
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
k8s.io/api v0.33.4
k8s.io/apimachinery v0.33.4
k8s.io/client-go v0.33.4

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/nacos/v2
go 1.23.0
require (
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
github.com/nacos-group/nacos-sdk-go/v2 v2.2.5
)

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/polaris/v2
go 1.23.0
require (
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
github.com/polarismesh/polaris-go v1.6.1
)

View File

@ -4,7 +4,7 @@ go 1.23.0
require (
github.com/ClickHouse/clickhouse-go/v2 v2.0.15
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
github.com/google/uuid v1.6.0
github.com/shopspring/decimal v1.3.1
)

View File

@ -6,7 +6,7 @@ replace github.com/gogf/gf/v2 => ../../../
require (
gitee.com/chunanyong/dm v1.8.12
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
)
require (

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/mssql/v2
go 1.23.0
require (
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
github.com/microsoft/go-mssqldb v1.7.1
)

View File

@ -4,7 +4,7 @@ go 1.23.0
require (
github.com/go-sql-driver/mysql v1.7.1
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
)
require (

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/oracle/v2
go 1.23.0
require (
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
github.com/sijms/go-ora/v2 v2.7.10
)

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/pgsql/v2
go 1.23.0
require (
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
github.com/lib/pq v1.10.9
)

View File

@ -4,7 +4,7 @@ go 1.23.0
require (
github.com/glebarez/go-sqlite v1.21.2
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
)
require (

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/sqlitecgo/v2
go 1.23.0
require (
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
github.com/mattn/go-sqlite3 v1.14.17
)

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/metric/otelmetric/v2
go 1.23.0
require (
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
github.com/prometheus/client_golang v1.23.0
go.opentelemetry.io/contrib/instrumentation/runtime v0.62.0
go.opentelemetry.io/otel v1.37.0

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/nosql/redis/v2
go 1.23.0
require (
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
github.com/redis/go-redis/v9 v9.12.1
go.opentelemetry.io/otel v1.37.0
go.opentelemetry.io/otel/trace v1.37.0

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/consul/v2
go 1.23.0
require (
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
github.com/hashicorp/consul/api v1.26.1
)

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/etcd/v2
go 1.23.0
require (
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
go.etcd.io/etcd/client/v3 v3.5.17
google.golang.org/grpc v1.59.0
)

View File

@ -2,7 +2,7 @@ module github.com/gogf/gf/contrib/registry/file/v2
go 1.23.0
require github.com/gogf/gf/v2 v2.9.2
require github.com/gogf/gf/v2 v2.9.3
require (
github.com/BurntSushi/toml v1.5.0 // indirect

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/nacos/v2
go 1.23.0
require (
github.com/gogf/gf/v2 v2.9.0
github.com/gogf/gf/v2 v2.9.2
github.com/nacos-group/nacos-sdk-go/v2 v2.2.7
)

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/polaris/v2
go 1.23.0
require (
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
github.com/polarismesh/polaris-go v1.6.1
)

View File

@ -4,7 +4,7 @@ go 1.23.0
require (
github.com/go-zookeeper/zk v1.0.3
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
golang.org/x/sync v0.16.0
)

View File

@ -3,8 +3,8 @@ module github.com/gogf/gf/contrib/rpc/grpcx/v2
go 1.23.0
require (
github.com/gogf/gf/contrib/registry/file/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/contrib/registry/file/v2 v2.9.3
github.com/gogf/gf/v2 v2.9.3
go.opentelemetry.io/otel v1.37.0
go.opentelemetry.io/otel/trace v1.37.0
google.golang.org/grpc v1.64.1

View File

@ -2,7 +2,7 @@ module github.com/gogf/gf/contrib/sdk/httpclient/v2
go 1.23.0
require github.com/gogf/gf/v2 v2.9.2
require github.com/gogf/gf/v2 v2.9.3
require (
github.com/BurntSushi/toml v1.5.0 // indirect

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/otlpgrpc/v2
go 1.23.0
require (
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
go.opentelemetry.io/otel v1.37.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.37.0

View File

@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/otlphttp/v2
go 1.23.0
require (
github.com/gogf/gf/v2 v2.9.2
github.com/gogf/gf/v2 v2.9.3
go.opentelemetry.io/otel v1.37.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.37.0

View File

@ -222,14 +222,13 @@ func StrToTime(str string, format ...string) (*Time, error) {
} else if match = timeRegex2.FindStringSubmatch(str); len(match) > 0 && match[1] != "" {
year, month, day = parseDateStr(match[1])
} else if match = timeRegex3.FindStringSubmatch(str); len(match) > 0 && match[1] != "" {
s := strings.ReplaceAll(match[2], ":", "")
if len(s) < 6 {
s += strings.Repeat("0", 6-len(s))
}
hour, _ = strconv.Atoi(match[1])
min, _ = strconv.Atoi(match[2])
sec, _ = strconv.Atoi(match[3])
nsec, _ = strconv.Atoi(match[4])
if hour > 23 || min > 59 || sec > 59 {
return nil, gerror.NewCodef(gcode.CodeInvalidParameter, `invalid time string "%s"`, str)
}
for i := 0; i < 9-len(match[4]); i++ {
nsec *= 10
}
@ -240,13 +239,19 @@ func StrToTime(str string, format ...string) (*Time, error) {
// Time
if len(match[2]) > 0 {
s := strings.ReplaceAll(match[2], ":", "")
if len(s) < 6 {
s += strings.Repeat("0", 6-len(s))
parts := strings.Split(match[2], ":")
if len(parts) >= 1 && parts[0] != "" {
hour, _ = strconv.Atoi(parts[0])
}
if len(parts) >= 2 && parts[1] != "" {
min, _ = strconv.Atoi(parts[1])
}
if len(parts) >= 3 && parts[2] != "" {
sec, _ = strconv.Atoi(parts[2])
}
if hour > 23 || min > 59 || sec > 59 {
return nil, gerror.NewCodef(gcode.CodeInvalidParameter, `invalid time string "%s"`, str)
}
hour, _ = strconv.Atoi(s[0:2])
min, _ = strconv.Atoi(s[2:4])
sec, _ = strconv.Atoi(s[4:6])
}
// Nanoseconds, check and perform bits filling
if len(match[3]) > 0 {

View File

@ -183,6 +183,46 @@ func Test_StrToTime(t *testing.T) {
}
}
// test special time string
var testSpecialDateTimes = []string{
"2006-01-02 8:04:05",
"2006-01-02 8:4:05",
"2006-01-02 8:4:5",
"2006-01-02 8:04:05.000",
"2006/01/02 8:4:5",
"2006.01.02 8:4:5.000",
"2006.01.02 - 8:4:5",
"2006.01.02 8:4:5 +0800 CST",
"2006-01-02T5:5:5+05:01",
"2006-01-01T19:3:5-05:01",
"2006-01-02T8:4:5",
"02-jan-2006 8:4:5",
"02/jan/2006 8:4:5",
"02.jan.2006 8:4:5",
"02.jan.2006:8:4:5",
}
for _, item := range testSpecialDateTimes {
timeTemp, err := gtime.StrToTime(item)
t.AssertNil(err)
t.Assert(timeTemp.Time.Local().Format("2006-01-02 15:04:05"), "2006-01-02 08:04:05")
}
// test error time string
var testErrorDateTimes = []string{
"2006-01-02 28:4:5",
"2006-01-02 8:60:5",
"2006-01-02 8:4:60",
"28:20:20",
"8:60:20",
"8:20:60",
}
for _, item := range testErrorDateTimes {
_, err := gtime.StrToTime(item)
if err == nil {
t.Error("test fail")
}
}
// test err
_, err := gtime.StrToTime("2006-01-02 15:04:05", "aabbccdd")
if err == nil {

View File

@ -2,5 +2,5 @@ package gf
const (
// VERSION is the current GoFrame version.
VERSION = "v2.9.2"
VERSION = "v2.9.3"
)