Skip to content

Commit

Permalink
GO: allow package main;; closes #544
Browse files Browse the repository at this point in the history
  • Loading branch information
kiritofeng committed Nov 9, 2019
1 parent 9791337 commit 82f0a37
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dmoj/executors/GO.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

reinline_comment = re.compile(br'//.*?(?=[\r\n])')
recomment = re.compile(br'/\*.*?\*/', re.DOTALL)
repackage = re.compile(br'\s*package\s+main\b')


def decomment(x):
Expand Down Expand Up @@ -51,6 +52,6 @@ def get_version_flags(cls, command):

def create_files(self, problem_id, source_code, *args, **kwargs):
source_lines = decomment(source_code).strip().split(b'\n')
if source_lines[0].strip().split() != [b'package', b'main']:
if not repackage.match(source_lines[0]):
raise CompileError(b'Your code must be defined in package main.\n')
super().create_files(problem_id, source_code, *args, **kwargs)

0 comments on commit 82f0a37

Please sign in to comment.