diff --git a/example/a+b/go-WA/SOLUTION b/example/a+b/go-WA/SOLUTION new file mode 100644 index 0000000..4b47200 --- /dev/null +++ b/example/a+b/go-WA/SOLUTION @@ -0,0 +1,3 @@ +# -*- coding: utf-8; mode: python -*- + +go_solution(src='main.go', challenge_cases=[]) diff --git a/example/a+b/go-WA/main.go b/example/a+b/go-WA/main.go new file mode 100644 index 0000000..8399d98 --- /dev/null +++ b/example/a+b/go-WA/main.go @@ -0,0 +1,9 @@ +package main + +import "fmt" + +func main() { + var a, b int + fmt.Scan(&a, &b) + fmt.Println(a - b) +} diff --git a/example/a+b/go-correct/SOLUTION b/example/a+b/go-correct/SOLUTION new file mode 100644 index 0000000..3f37ef6 --- /dev/null +++ b/example/a+b/go-correct/SOLUTION @@ -0,0 +1,3 @@ +# -*- coding: utf-8; mode: python -*- + +go_solution(src='main.go') diff --git a/example/a+b/go-correct/main.go b/example/a+b/go-correct/main.go new file mode 100644 index 0000000..4c77283 --- /dev/null +++ b/example/a+b/go-correct/main.go @@ -0,0 +1,9 @@ +package main + +import "fmt" + +func main() { + var a, b int + fmt.Scan(&a, &b) + fmt.Println(a + b) +} diff --git a/rime/basic/codes.py b/rime/basic/codes.py index 9215a0d..be6c8df 100644 --- a/rime/basic/codes.py +++ b/rime/basic/codes.py @@ -208,6 +208,21 @@ def __init__(self, src_name, src_dir, out_dir, flags=[]): run_args=[os.path.join(out_dir, exe_name)]) +class GoCode(CodeBase): + PREFIX = 'go' + EXTENSIONS = ['go'] + + def __init__(self, src_name, src_dir, out_dir, flags=[]): + exe_name = os.path.splitext(src_name)[0] + consts.EXE_EXT + goc = 'go' + super(GoCode, self).__init__( + src_name=src_name, src_dir=src_dir, out_dir=out_dir, + compile_args=([goc, 'build', + '-o', os.path.join(out_dir, exe_name)] + + flags + [src_name]), + run_args=[os.path.join(out_dir, exe_name)]) + + class ScriptCode(CodeBase): QUIET_COMPILE = True PREFIX = 'script' @@ -298,4 +313,5 @@ def Clean(self): codes.registry.Add(KotlinCode) codes.registry.Add(JavaCode) codes.registry.Add(RustCode) +codes.registry.Add(GoCode) codes.registry.Add(ScriptCode) diff --git a/rime/plugins/plus/commands.py b/rime/plugins/plus/commands.py index 6b1c91d..261f401 100644 --- a/rime/plugins/plus/commands.py +++ b/rime/plugins/plus/commands.py @@ -180,6 +180,7 @@ def Add(self, args, ui): #java_solution(src='Main.java', encoding='UTF-8', mainclass='Main', # challenge_cases=['10_corner*.in']) #rust_solution(src='main.rs') # Rust (rustc) +#go_solution(src='main.go') # Go #script_solution(src='main.sh') # shebang line is required #script_solution(src='main.pl') # shebang line is required #script_solution(src='main.py') # shebang line is required @@ -207,6 +208,7 @@ def Add(self, args, ui): #cxx_generator(src='generator.cc', dependency=['testlib.h']) #java_generator(src='Generator.java', encoding='UTF-8', mainclass='Generator') #rust_generator(src='generator.rs') +#go_generator(src='generator.go') #script_generator(src='generator.pl') ## Input validators. @@ -215,6 +217,7 @@ def Add(self, args, ui): #java_validator(src='Validator.java', encoding='UTF-8', # mainclass='tmp/validator/Validator') #rust_validator(src='validator.rs') +#go_validator(src='validator.go') #script_validator(src='validator.pl') ## Output judges. @@ -223,6 +226,7 @@ def Add(self, args, ui): # variant=testlib_judge_runner) #java_judge(src='Judge.java', encoding='UTF-8', mainclass='Judge') #rust_judge(src='judge.rs') +#go_judge(src='judge.go') #script_judge(src='judge.py') ## Reactives. @@ -231,6 +235,7 @@ def Add(self, args, ui): # variant=kupc_reactive_runner) #java_reactive(src='Reactive.java', encoding='UTF-8', mainclass='Judge') #rust_reactive(src='reactive.rs') +#go_reactive(src='reactive.go') #script_reactive(src='reactive.py') ## Extra Testsets.