@@ -801,21 +801,36 @@ export class WorkspaceTagsService implements IWorkspaceTagsService {
801
801
const goModPromises = getFilePromises ( 'go.mod' , this . fileService , this . textFileService , content => {
802
802
// TODO: Richard to write the code for parsing the go.mod file
803
803
// look for everything in require() and get the string value only discard version
804
- const dependencies : string [ ] = splitLines ( content . value ) ;
805
- for ( const dependency of dependencies ) {
806
- // Dependencies in requirements.txt can have 3 formats: `foo==3.1, foo>=3.1, foo`
807
- const format1 = dependency . split ( '==' ) ;
808
- const format2 = dependency . split ( '>=' ) ;
809
- const packageName = ( format1 . length === 2 ? format1 [ 0 ] : format2 [ 0 ] ) . trim ( ) ;
804
+ const lines : string [ ] = splitLines ( content . value ) ;
805
+ let firstRequireBlockFound : boolean = false ;
806
+
807
+ for ( let i = 0 ; i < lines . length ; i ++ ) {
808
+ const line : string = lines [ i ] . trim ( ) ;
809
+
810
+ if ( line . startsWith ( 'require (' ) ) {
811
+ if ( ! firstRequireBlockFound ) {
812
+ firstRequireBlockFound = true ;
813
+ continue ;
814
+ } else {
815
+ break ;
816
+ }
817
+ }
810
818
811
- // copied from line 728 function addPythonTags
812
- if ( GoModulesToLookFor . indexOf ( packageName ) > - 1 ) {
813
- tags [ 'workspace.go.mod' + packageName ] = true ;
819
+ if ( line . startsWith ( ')' ) ) {
820
+ break ;
814
821
}
815
- // not sure if we should keep this
816
- for ( const metaModule of GoMetaModulesToLookFor ) {
817
- if ( packageName . startsWith ( metaModule ) ) {
818
- tags [ 'workspace.go.mod' + metaModule ] = true ;
822
+
823
+ if ( firstRequireBlockFound && line !== '' ) {
824
+ const packageName : string = line . split ( ' ' ) [ 0 ] . trim ( ) ;
825
+ // copied from line 728 function addPythonTags
826
+ if ( GoModulesToLookFor . indexOf ( packageName ) > - 1 ) {
827
+ tags [ 'workspace.go.mod' + packageName ] = true ;
828
+ }
829
+ // not sure if we should keep this
830
+ for ( const metaModule of GoMetaModulesToLookFor ) {
831
+ if ( packageName . startsWith ( metaModule ) ) {
832
+ tags [ 'workspace.go.mod' + metaModule ] = true ;
833
+ }
819
834
}
820
835
}
821
836
}
0 commit comments