File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -59,11 +59,12 @@ func Work(rc RunConfig) error {
5959
6060// validateGoVersion checks if goVersion is valid Go release version
6161// according to the go.work file syntax:
62- // a positive integer followed by a dot and a non-negative integer
63- // (for example, 1.19, 1.20).
62+ // a positive integer followed by a dot and a non-negative integer,
63+ // optionally followed by a dot and another non-negative integer (patch version)
64+ // (for example, 1.19, 1.20, 1.23.0).
6465// More: https://go.dev/ref/mod#workspaces.
6566func validateGoVersion (goVersion string ) error {
66- matched , err := regexp .MatchString (`^[1-9]+[0-9]*\.(0|[1-9]+[0-9]*)$` , goVersion )
67+ matched , err := regexp .MatchString (`^[1-9]+[0-9]*\.(0|[1-9]+[0-9]*)(\.(0|[1-9]+[0-9]*))? $` , goVersion )
6768 if err != nil {
6869 return err
6970 }
Original file line number Diff line number Diff line change @@ -132,6 +132,11 @@ func TestGoVersionValid(t *testing.T) {
132132 "1.21" ,
133133 "21.0" ,
134134 "10.0" ,
135+ "1.23.0" ,
136+ "1.24.0" ,
137+ "1.0.0" ,
138+ "1.21.10" ,
139+ "10.5.100" ,
135140 }
136141 for _ , goVersion := range goVersions {
137142 t .Run (goVersion , func (t * testing.T ) {
@@ -145,12 +150,15 @@ func TestGoVersionInvalid(t *testing.T) {
145150 goVersions := []string {
146151 "1.-0" ,
147152 "a.1" ,
148- "1.2.3" ,
153+ "1.2.3.4 " ,
149154 "0.0" ,
150155 "1" ,
151156 "-1.2" ,
152157 "01.2" ,
153158 "1.02" ,
159+ "1.2.03" ,
160+ "0.0.0" ,
161+ "1.2.-1" ,
154162 }
155163 for _ , goVersion := range goVersions {
156164 t .Run (goVersion , func (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments