fix go.mod

This commit is contained in:
2026-08-11 15:36:08 +08:00
parent 581a503883
commit e0d7827da2
6 changed files with 45 additions and 67 deletions

View File

@@ -3,12 +3,9 @@ package main
import (
"context"
"flag"
"fmt"
"net/http"
"os"
"os/signal"
"regexp"
"strings"
"syscall"
"time"
@@ -16,24 +13,16 @@ import (
"bsm/full/all/internal/impl"
allserver "bsm/full/all/internal/server"
"bsm/full/all/internal/service"
"git.apinb.com/bsm-sdk/core/utils"
)
var ServiceKey = "default"
var workspacePattern = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$`)
func normalizeWorkspace(value string) (string, error) {
value = strings.ToLower(strings.TrimSpace(value))
if !workspacePattern.MatchString(value) {
return "", fmt.Errorf("workspace must match %s", workspacePattern.String())
}
return value, nil
}
func main() {
workspace := flag.String("workspace", ServiceKey, "workspace used to select etc/{workspace}_{runtime}.yaml")
flag.Parse()
value, err := normalizeWorkspace(*workspace)
value, err := utils.MustString(*workspace)
if err != nil {
panic(err)
}

View File

@@ -1,26 +0,0 @@
package main
import "testing"
func TestNormalizeWorkspace(t *testing.T) {
tests := []struct {
input string
want string
ok bool
}{
{input: "default", want: "default", ok: true},
{input: " Tenant_01 ", want: "tenant_01", ok: true},
{input: "../prod", ok: false},
{input: "", ok: false},
{input: "tenant.name", ok: false},
}
for _, test := range tests {
got, err := normalizeWorkspace(test.input)
if (err == nil) != test.ok {
t.Fatalf("normalizeWorkspace(%q) error = %v", test.input, err)
}
if got != test.want {
t.Fatalf("normalizeWorkspace(%q) = %q, want %q", test.input, got, test.want)
}
}
}

View File

@@ -2,6 +2,25 @@ module bsm/full/all
go 1.26.5
replace (
bsm/full/module/base/ads => ../module/base/ads
bsm/full/module/base/cloud => ../module/base/cloud
bsm/full/module/base/cms => ../module/base/cms
bsm/full/module/base/feedback => ../module/base/feedback
bsm/full/module/base/fts => ../module/base/fts
bsm/full/module/base/initial => ../module/base/initial
bsm/full/module/base/logs => ../module/base/logs
bsm/full/module/base/mgt => ../module/base/mgt
bsm/full/module/base/passport => ../module/base/passport
bsm/full/module/base/sender => ../module/base/sender
bsm/full/module/ec/address => ../module/ec/address
bsm/full/module/ec/mall => ../module/ec/mall
bsm/full/module/ec/market => ../module/ec/market
bsm/full/module/ec/order => ../module/ec/order
bsm/full/module/finance/wallet => ../module/finance/wallet
git.apinb.com/bsm-sdk/core => ../../../bsm-sdk/core
)
require (
bsm/full/module/base/ads v0.0.0
bsm/full/module/base/cloud v0.0.0
@@ -131,7 +150,6 @@ require (
golang.org/x/sys v0.47.0 // indirect
golang.org/x/text v0.40.0 // indirect
golang.org/x/tools v0.48.0 // indirect
google.golang.org/genproto v0.0.0-20260807164820-c8921c73eeea // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260807164820-c8921c73eeea // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260807164820-c8921c73eeea // indirect
google.golang.org/protobuf v1.36.11 // indirect
@@ -140,21 +158,3 @@ require (
gorm.io/driver/mysql v1.6.0 // indirect
gorm.io/driver/postgres v1.6.2 // indirect
)
replace (
bsm/full/module/base/ads => ../module/base/ads
bsm/full/module/base/cloud => ../module/base/cloud
bsm/full/module/base/cms => ../module/base/cms
bsm/full/module/base/feedback => ../module/base/feedback
bsm/full/module/base/fts => ../module/base/fts
bsm/full/module/base/initial => ../module/base/initial
bsm/full/module/base/logs => ../module/base/logs
bsm/full/module/base/mgt => ../module/base/mgt
bsm/full/module/base/passport => ../module/base/passport
bsm/full/module/base/sender => ../module/base/sender
bsm/full/module/ec/address => ../module/ec/address
bsm/full/module/ec/mall => ../module/ec/mall
bsm/full/module/ec/market => ../module/ec/market
bsm/full/module/ec/order => ../module/ec/order
bsm/full/module/finance/wallet => ../module/finance/wallet
)

View File

@@ -1,8 +1,6 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo=
filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc=
git.apinb.com/bsm-sdk/core v0.2.1 h1:1kpbdij3qOlf1DmKTq3coIXSgLth5iJHJ3LvVZnjaXM=
git.apinb.com/bsm-sdk/core v0.2.1/go.mod h1:BL/aGHujCWdxrKZrWaiebmLx69J0OrTVv5XfugbbyhE=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
@@ -256,7 +254,6 @@ github.com/oklog/ulid/v2 v2.1.2/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNs
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY=
github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
@@ -490,8 +487,6 @@ google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9Ywl
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20260807164820-c8921c73eeea h1:EoNao6AiKb+bftjR8vFOxqtY1A4zLnvnfea+FBQicBo=
google.golang.org/genproto v0.0.0-20260807164820-c8921c73eeea/go.mod h1:MVqdGj2rFowpxM1nWJoGZmKI3TGThZsWENFz9uc4l1g=
google.golang.org/genproto/googleapis/api v0.0.0-20260807164820-c8921c73eeea h1:Jifw/kjs/r3B0uszvls/m3c3tmZs2YHGM9C+rvxP9gY=
google.golang.org/genproto/googleapis/api v0.0.0-20260807164820-c8921c73eeea/go.mod h1:K/+WGbmBY7aNW1HDw1fJnKYo10i0DkAX6pows00dLig=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260807164820-c8921c73eeea h1:kVhQEPTpKQahD5+JSBTfBB19wcgQTTjAIn45MBqnyHk=