Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM docker.io/library/node:20.13.0-alpine

ENV PYTHONUNBUFFERED=1
RUN set -ex && \
apk add --no-cache gcc g++ musl-dev python3 openjdk17 ruby iptables ip6tables
apk add --no-cache gcc g++ musl-dev python3 openjdk17 ruby iptables ip6tables go

RUN set -ex && \
apk add --no-cache chromium lsof
Expand Down
9 changes: 8 additions & 1 deletion configs/language.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { CPP, C, PYTHON, JAVA, NODEJS, RUBY, PROMPTV1, PROMPTV2 } = require('../enums/supportedLanguages')
const { CPP, C, PYTHON, JAVA, NODEJS, RUBY, PROMPTV1, PROMPTV2, GO } = require('../enums/supportedLanguages')
const ONE_MB = 1024 // ulimit uses Kilobyte as base unit
const ALLOWED_RAM = process.env.ALLOWED_RAM || 512

Expand Down Expand Up @@ -51,6 +51,13 @@ const LANGUAGES_CONFIG = {
[PROMPTV2]: {
model: 'gpt-3.5-turbo-1106',
},
[GO]: {
compile: 'go build solution.go',
run: './solution',
timeout: 2,
filename: 'solution.go',
memory: ALLOWED_RAM * ONE_MB,
},
}

module.exports = { LANGUAGES_CONFIG }
1 change: 1 addition & 0 deletions enums/supportedLanguages.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ module.exports = {
PROMPTV2: 'promptv2',
MULTIFILE: 'multifile',
SQLITE3: 'sqlite3',
GO: 'go',
}
45 changes: 45 additions & 0 deletions tests/data/testJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,51 @@ const testCases = [
error: 0,
},
},
{
name: 'go : hello world',
reqObject: {
language: 'go',
script:
'package main\n\n' +
'import "fmt"\n\n' +
'func main() {\n' +
' fmt.Println("hello world")\n' +
'}\n'
},
expectedResponse: {
val: 'hello world\n',
status: 200,
error: 0,
},
},
{
name: 'go : print stdin',
reqObject: {
language: 'go',
script:
'package main\n\n' +
'import (\n' +
' "fmt"\n' +
' "bufio"\n' +
' "os"\n' +
')\n\n' +
'func main() {\n' +
' scanner := bufio.NewScanner(os.Stdin)\n' +
' for scanner.Scan() {\n' +
' fmt.Println(scanner.Text())\n' +
' }\n' +
' if err := scanner.Err(); err != nil {\n' +
' fmt.Fprintln(os.Stderr, "reading standard input:", err)\n' +
' }\n' +
'}\n',
stdin: '1 2 3'
},
expectedResponse: {
val: '1 2 3\n',
status: 200,
error: 0,
},
},
]

module.exports = { testCases }