diff --git a/judge/languages.py b/judge/languages.py index 7cd51cca..93d2e482 100644 --- a/judge/languages.py +++ b/judge/languages.py @@ -437,6 +437,33 @@ _py3_lang_config = { } } +_go_lang_config = { + "template": """//PREPEND BEGIN +//PREPEND END + +//TEMPLATE BEGIN +//TEMPLATE END + +//APPEND BEGIN +//APPEND END""", + "compile": { + "src_name": "main.go", + "exe_name": "main", + "max_cpu_time": 3000, + "max_real_time": 5000, + "max_memory": 1024 * 1024 * 1024, + "compile_command": "/usr/bin/go build -o {exe_path} {src_path}", + "env": ["GOCACHE=/tmp"] + }, + "run": { + "command": "{exe_path}", + "seccomp_rule": "", + # 降低内存占用 + "env": ["GODEBUG=madvdontneed=1"] + default_env, + "memory_limit_check_only": 1 + } +} + languages = [ {"config": _c_lang_config, "spj": {"compile": _c_lang_spj_compile, "config": _c_lang_spj_config}, "name": "C", "description": "GCC 9.2.1", "content_type": "text/x-csrc"}, @@ -453,4 +480,5 @@ languages = [ {"config": _java_lang_config, "name": "Java", "description": "OpenJDK 1.8", "content_type": "text/x-java"}, {"config": _py2_lang_config, "name": "Python2", "description": "Python 2.7.15+", "content_type": "text/x-python"}, {"config": _py3_lang_config, "name": "Python3", "description": "Python 3.5.2", "content_type": "text/x-python"}, + {"config": _go_lang_config, "name": "Golang 1.14", "description": "Golang 1.14", "content_type": "text/x-go"}, ] diff --git a/problem/views/admin.py b/problem/views/admin.py index b6fd9b26..87623c12 100644 --- a/problem/views/admin.py +++ b/problem/views/admin.py @@ -676,6 +676,10 @@ class FPSProblemImport(CSRFExemptAPIView): with tempfile.NamedTemporaryFile("wb") as tf: for chunk in file.chunks(4096): tf.file.write(chunk) + + tf.file.flush() + os.fsync(tf.file) + problems = FPSParser(tf.name).parse() else: return self.error("Parse upload file error")