Skip to content

Commit

Permalink
Merge pull request #75 from ktateish/add-support-for-go
Browse files Browse the repository at this point in the history
Add support for Go
  • Loading branch information
not522 authored Aug 14, 2020
2 parents eeb665d + 82b3d58 commit 44aae08
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions example/a+b/go-WA/SOLUTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8; mode: python -*-

go_solution(src='main.go', challenge_cases=[])
9 changes: 9 additions & 0 deletions example/a+b/go-WA/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import "fmt"

func main() {
var a, b int
fmt.Scan(&a, &b)
fmt.Println(a - b)
}
3 changes: 3 additions & 0 deletions example/a+b/go-correct/SOLUTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8; mode: python -*-

go_solution(src='main.go')
9 changes: 9 additions & 0 deletions example/a+b/go-correct/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import "fmt"

func main() {
var a, b int
fmt.Scan(&a, &b)
fmt.Println(a + b)
}
16 changes: 16 additions & 0 deletions rime/basic/codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
5 changes: 5 additions & 0 deletions rime/plugins/plus/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 44aae08

Please sign in to comment.