@@ -37,7 +37,9 @@ import { testCurrentFile } from '../../src/goTest';
37
37
import {
38
38
getBinPath ,
39
39
getCurrentGoPath ,
40
+ getGoVersion ,
40
41
getImportPath ,
42
+ GoVersion ,
41
43
handleDiagnosticErrors ,
42
44
ICheckResult ,
43
45
isVendorSupported
@@ -57,6 +59,7 @@ const testAll = (isModuleMode: boolean) => {
57
59
let generateFunctionTestSourcePath : string ;
58
60
let generatePackageTestSourcePath : string ;
59
61
let previousEnv : any ;
62
+ let goVersion : GoVersion ;
60
63
61
64
suiteSetup ( async ( ) => {
62
65
previousEnv = Object . assign ( { } , process . env ) ;
@@ -69,6 +72,8 @@ const testAll = (isModuleMode: boolean) => {
69
72
assert . ok ( gopath , 'Cannot run tests if GOPATH is not set as environment variable' ) ;
70
73
return ;
71
74
}
75
+ goVersion = await getGoVersion ( ) ;
76
+
72
77
console . log ( `Using GOPATH: ${ gopath } ` ) ;
73
78
74
79
repoPath = isModuleMode ? fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'legacy' ) ) : path . join ( gopath , 'src' , 'test' ) ;
@@ -225,13 +230,16 @@ standard output. Spaces are always added between operands and a newline is
225
230
appended. It returns the number of bytes written and any write error
226
231
encountered.
227
232
` ;
233
+ const printlnSig = goVersion . lt ( '1.18' )
234
+ ? 'Println(a ...interface{}) (n int, err error)'
235
+ : 'Println(a ...any) (n int, err error)' ;
228
236
229
237
const testCases : [ vscode . Position , string , string , string [ ] ] [ ] = [
230
238
[
231
239
new vscode . Position ( 19 , 13 ) ,
232
- 'Println(a ...interface{}) (n int, err error)' ,
240
+ printlnSig ,
233
241
printlnDoc ,
234
- [ ' a ...interface{}']
242
+ [ goVersion . lt ( '1.18' ) ? ' a ...interface{}' : 'a ...any ']
235
243
] ,
236
244
[
237
245
new vscode . Position ( 23 , 7 ) ,
@@ -272,12 +280,16 @@ encountered.
272
280
Spaces are always added between operands and a newline is appended.
273
281
It returns the number of bytes written and any write error encountered.
274
282
` ;
283
+ const printlnSig = goVersion . lt ( '1.18' )
284
+ ? 'Println(a ...interface{}) (n int, err error)'
285
+ : 'Println(a ...any) (n int, err error)' ;
286
+
275
287
const testCases : [ vscode . Position , string , string , string [ ] ] [ ] = [
276
288
[
277
289
new vscode . Position ( 19 , 13 ) ,
278
- 'Println(a ...interface{}) (n int, err error)' ,
290
+ printlnSig ,
279
291
printlnDoc ,
280
- [ ' a ...interface{}']
292
+ [ goVersion . lt ( '1.18' ) ? ' a ...interface{}' : 'a ...any ']
281
293
] ,
282
294
[
283
295
new vscode . Position ( 23 , 7 ) ,
@@ -314,6 +326,10 @@ standard output. Spaces are always added between operands and a newline is
314
326
appended. It returns the number of bytes written and any write error
315
327
encountered.
316
328
` ;
329
+ const printlnSig = goVersion . lt ( '1.18' )
330
+ ? 'Println func(a ...interface{}) (n int, err error)'
331
+ : 'Println func(a ...any) (n int, err error)' ;
332
+
317
333
const testCases : [ vscode . Position , string | null , string | null ] [ ] = [
318
334
// [new vscode.Position(3,3), '/usr/local/go/src/fmt'],
319
335
[ new vscode . Position ( 0 , 3 ) , null , null ] , // keyword
@@ -322,7 +338,7 @@ encountered.
322
338
[ new vscode . Position ( 28 , 16 ) , null , null ] , // inside a number
323
339
[ new vscode . Position ( 22 , 5 ) , 'main func()' , '\n' ] ,
324
340
[ new vscode . Position ( 40 , 23 ) , 'import (math "math")' , null ] ,
325
- [ new vscode . Position ( 19 , 6 ) , 'Println func(a ...interface{}) (n int, err error)' , printlnDoc ] ,
341
+ [ new vscode . Position ( 19 , 6 ) , printlnSig , printlnDoc ] ,
326
342
[
327
343
new vscode . Position ( 23 , 4 ) ,
328
344
'print func(txt string)' ,
@@ -350,6 +366,10 @@ encountered.
350
366
Spaces are always added between operands and a newline is appended.
351
367
It returns the number of bytes written and any write error encountered.
352
368
` ;
369
+ const printlnSig = goVersion . lt ( '1.18' )
370
+ ? 'func Println(a ...interface{}) (n int, err error)'
371
+ : 'func Println(a ...any) (n int, err error)' ;
372
+
353
373
const testCases : [ vscode . Position , string | null , string | null ] [ ] = [
354
374
[ new vscode . Position ( 0 , 3 ) , null , null ] , // keyword
355
375
[ new vscode . Position ( 23 , 11 ) , null , null ] , // inside a string
@@ -366,7 +386,7 @@ It returns the number of bytes written and any write error encountered.
366
386
'package math' ,
367
387
'Package math provides basic constants and mathematical functions.\n\nThis package does not guarantee bit-identical results across architectures.\n'
368
388
] ,
369
- [ new vscode . Position ( 19 , 6 ) , 'func Println(a ...interface{}) (n int, err error)' , printlnDoc ] ,
389
+ [ new vscode . Position ( 19 , 6 ) , printlnSig , printlnDoc ] ,
370
390
[
371
391
new vscode . Position ( 27 , 14 ) ,
372
392
'type ABC struct {\n a int\n b int\n c int\n}' ,
@@ -384,7 +404,13 @@ It returns the number of bytes written and any write error encountered.
384
404
await testHoverProvider ( config , testCases ) ;
385
405
} ) ;
386
406
387
- test ( 'Linting - concurrent process cancelation' , async ( ) => {
407
+ test ( 'Linting - concurrent process cancelation' , async function ( ) {
408
+ if ( ! goVersion . lt ( '1.18' ) ) {
409
+ // TODO(hyangah): reenable test when staticcheck for go1.18 is released
410
+ // https://github.com/dominikh/go-tools/issues/1145
411
+ this . skip ( ) ;
412
+ }
413
+
388
414
const util = require ( '../../src/util' ) ;
389
415
const processutil = require ( '../../src/utils/processUtils' ) ;
390
416
sinon . spy ( util , 'runTool' ) ;
@@ -413,7 +439,12 @@ It returns the number of bytes written and any write error encountered.
413
439
) ;
414
440
} ) ;
415
441
416
- test ( 'Linting - lint errors with multiple open files' , async ( ) => {
442
+ test ( 'Linting - lint errors with multiple open files' , async function ( ) {
443
+ if ( ! goVersion . lt ( '1.18' ) ) {
444
+ // TODO(hyangah): reenable test when staticcheck for go1.18 is released
445
+ // https://github.com/dominikh/go-tools/issues/1145
446
+ this . skip ( ) ;
447
+ }
417
448
// handleDiagnosticErrors may adjust the lint errors' ranges to make the error more visible.
418
449
// This adjustment applies only to the text documents known to vscode. This test checks
419
450
// the adjustment is made consistently across multiple open text documents.
@@ -448,7 +479,13 @@ It returns the number of bytes written and any write error encountered.
448
479
assert . deepStrictEqual ( file1Diagnostics [ 0 ] , file2Diagnostics [ 0 ] ) ;
449
480
} ) ;
450
481
451
- test ( 'Error checking' , async ( ) => {
482
+ test ( 'Error checking' , async function ( ) {
483
+ if ( ! goVersion . lt ( '1.18' ) ) {
484
+ // TODO(hyangah): reenable test when staticcheck for go1.18 is released
485
+ // https://github.com/dominikh/go-tools/issues/1145
486
+ this . skip ( ) ;
487
+ }
488
+
452
489
const config = Object . create ( getGoConfig ( ) , {
453
490
vetOnSave : { value : 'package' } ,
454
491
vetFlags : { value : [ '-all' ] } ,
@@ -901,10 +938,14 @@ standard output. Spaces are always added between operands and a newline is
901
938
appended. It returns the number of bytes written and any write error
902
939
encountered.
903
940
` ;
941
+ const printlnSig = goVersion . lt ( '1.18' )
942
+ ? 'func(a ...interface{}) (n int, err error)'
943
+ : 'func(a ...any) (n int, err error)' ;
944
+
904
945
const provider = new GoCompletionItemProvider ( ) ;
905
946
const testCases : [ vscode . Position , string , string | null , string | null ] [ ] = [
906
947
[ new vscode . Position ( 7 , 4 ) , 'fmt' , 'fmt' , null ] ,
907
- [ new vscode . Position ( 7 , 6 ) , 'Println' , 'func(a ...interface{}) (n int, err error)' , printlnDoc ]
948
+ [ new vscode . Position ( 7 , 6 ) , 'Println' , printlnSig , printlnDoc ]
908
949
] ;
909
950
const uri = vscode . Uri . file ( path . join ( fixturePath , 'baseTest' , 'test.go' ) ) ;
910
951
const textDocument = await vscode . workspace . openTextDocument ( uri ) ;
@@ -980,7 +1021,10 @@ encountered.
980
1021
if ( ! item1 ) {
981
1022
assert . fail ( 'Suggestion with label "Print" not found in test case withFunctionSnippet.' ) ;
982
1023
}
983
- assert . equal ( ( < vscode . SnippetString > item1 . insertText ) . value , 'Print(${1:a ...interface{\\}})' ) ;
1024
+ assert . equal (
1025
+ ( < vscode . SnippetString > item1 . insertText ) . value ,
1026
+ goVersion . lt ( '1.18' ) ? 'Print(${1:a ...interface{\\}})' : 'Print(${1:a ...any})'
1027
+ ) ;
984
1028
} ) ;
985
1029
const withFunctionSnippetNotype = provider
986
1030
. provideCompletionItemsInternal (
0 commit comments