Skip to content

Commit 3168aa8

Browse files
Fixing version issue
1 parent 6dcc746 commit 3168aa8

File tree

2 files changed

+0
-25
lines changed

2 files changed

+0
-25
lines changed

compiler/astutil/astutil.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,6 @@ func FinalizeRemovals(file *ast.File) {
492492
// build constraints or any file level directives, but simply append
493493
// the tail comments as is. This may cause issues when formatting
494494
// the resulting file including extra newlines or invalid code.
495-
// - The file end will be set to the end of the last tail file that
496-
// will be from a different file according to the FileSet.
497495
func ConcatenateFiles(file *ast.File, tails ...*ast.File) error {
498496
// Populate the imports map from the target file.
499497
// This map will be used to check for duplicate imports.
@@ -518,15 +516,6 @@ func ConcatenateFiles(file *ast.File, tails ...*ast.File) error {
518516
return fmt.Errorf("can not concatenate files with different package names: %q != %q", file.Name.Name, tail.Name.Name)
519517
}
520518

521-
// Check go version from build constraints, e.g. `//go:build go1.18`
522-
// We probably could merge different versions of Go,
523-
// but it's better to know when it happens and handle it.
524-
if len(file.GoVersion) == 0 {
525-
file.GoVersion = tail.GoVersion
526-
} else if len(tail.GoVersion) > 0 && file.GoVersion != tail.GoVersion {
527-
return fmt.Errorf("can not concatenate files with different Go versions: %q != %q", file.GoVersion, tail.GoVersion)
528-
}
529-
530519
// Concatenate the imports.
531520
for _, imp := range tail.Imports {
532521
path := imp.Path.Value
@@ -560,9 +549,6 @@ func ConcatenateFiles(file *ast.File, tails ...*ast.File) error {
560549
file.Package = tail.Package
561550
file.Name.NamePos = tail.Name.NamePos
562551
}
563-
564-
// Update the file end to the new end.
565-
file.FileEnd = tail.FileEnd
566552
}
567553

568554
// Update the target file's declarations with all the imports

compiler/astutil/astutil_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,17 +1058,6 @@ func TestConcatenateFiles(t *testing.T) {
10581058
srcTail: `package otherTestPackage
10591059
func bar() {}`,
10601060
expErr: `can not concatenate files with different package names: "testpackage" != "otherTestPackage"`,
1061-
}, {
1062-
name: `packages with go versions`,
1063-
srcHead: `//go:build go1.18
1064-
1065-
package testpackage
1066-
func foo() {}`,
1067-
srcTail: `//go:build go1.20
1068-
1069-
package testpackage
1070-
func bar() {}`,
1071-
expErr: `can not concatenate files with different Go versions: "go1.18" != "go1.20"`,
10721061
}, {
10731062
name: `import mismatch with one named`,
10741063
srcHead: `package testpackage

0 commit comments

Comments
 (0)