from SublimeLinter.lint import Linter, util


class Govet(Linter):
    cmd = ('go', 'tool', 'vet')
    regex = r'.+?:(?P<line>\d+):((?P<col>\d+):)?\s+(?P<message>.+)'
    tempfile_suffix = 'go'
    error_stream = util.STREAM_STDERR
    defaults = {
        'selector': 'source.go'
    }

from SublimeLinter.lint import Linter, util


class Govet(Linter):
    cmd = ('go', 'vet', '${file_path}')

    regex = r'(?P<filename>^.+?):(?P<line>\d+):((?P<col>\d+):)?\s+(?P<message>(.|\n\t)+)'

    tempfile_suffix = '-'
    multiline = True
    error_stream = util.STREAM_STDERR
    defaults = {
        'selector': 'source.go'
    }

    def split_match(self, match):
        if self.filename.find(match.group('filename')) > 0:  # self.filename is an absolute path
            error = super().split_match(match)
            flat_message = ' '.join(line.strip() for line in error.message.split('\n'))
            return error._replace(message=flat_message)

Handle multiline go vet messages.
Handle multiline go vet messages.

  from SublimeLinter.lint import Linter, util
  
  
  class Govet(Linter):
-     cmd = ('go', 'tool', 'vet')
+     cmd = ('go', 'vet', '${file_path}')
+ 
-     regex = r'.+?:(?P<line>\d+):((?P<col>\d+):)?\s+(?P<message>.+)'
+     regex = r'(?P<filename>^.+?):(?P<line>\d+):((?P<col>\d+):)?\s+(?P<message>(.|\n\t)+)'
+ 
-     tempfile_suffix = 'go'
+     tempfile_suffix = '-'
+     multiline = True
      error_stream = util.STREAM_STDERR
      defaults = {
          'selector': 'source.go'
      }
  
+     def split_match(self, match):
+         if self.filename.find(match.group('filename')) > 0:  # self.filename is an absolute path
+             error = super().split_match(match)
+             flat_message = ' '.join(line.strip() for line in error.message.split('\n'))
+             return error._replace(message=flat_message)
+ 
Handle multiline go vet messages.
## Code Before:
from SublimeLinter.lint import Linter, util


class Govet(Linter):
    cmd = ('go', 'tool', 'vet')
    regex = r'.+?:(?P<line>\d+):((?P<col>\d+):)?\s+(?P<message>.+)'
    tempfile_suffix = 'go'
    error_stream = util.STREAM_STDERR
    defaults = {
        'selector': 'source.go'
    }

## Instruction:
Handle multiline go vet messages.
## Code After:
from SublimeLinter.lint import Linter, util


class Govet(Linter):
    cmd = ('go', 'vet', '${file_path}')

    regex = r'(?P<filename>^.+?):(?P<line>\d+):((?P<col>\d+):)?\s+(?P<message>(.|\n\t)+)'

    tempfile_suffix = '-'
    multiline = True
    error_stream = util.STREAM_STDERR
    defaults = {
        'selector': 'source.go'
    }

    def split_match(self, match):
        if self.filename.find(match.group('filename')) > 0:  # self.filename is an absolute path
            error = super().split_match(match)
            flat_message = ' '.join(line.strip() for line in error.message.split('\n'))
            return error._replace(message=flat_message)
