diff --git a/modules/compiler_v2/go_compiler_v2/go_compiler.go b/modules/compiler_v2/go_compiler_v2/go_compiler.go index cb9cdf9e7b02a3b51c48ff7fa5d010e2a42730fc..5d4f3028e43ef36f8bbc6960542f0f8e062058ee 100644 --- a/modules/compiler_v2/go_compiler_v2/go_compiler.go +++ b/modules/compiler_v2/go_compiler_v2/go_compiler.go @@ -10,10 +10,18 @@ const fileName = "main.go" type GoCompiler struct{} +// NewGoCompiler creates a new GoCompiler func NewGoCompiler() *GoCompiler { return &GoCompiler{} } +// CheckCompileErrors takes Go source code and checks for compile errors. +// +// The dependencies are handled automatically by go mod and go tidy. +// +// NOTE: Make sure you have an up-to-date Go installed on the system +// +// Returns the output of the compilation and an error if any func (gb *GoCompiler) CheckCompileErrors(srcCode []byte) ([]byte, error) { // Make temp folders utils.SetupTempFolders(consts.TempOutputDir) diff --git a/modules/compiler_v2/platform/platform.go b/modules/compiler_v2/platform/platform.go index 9d23851bd8365dd15d83021c817db4fabb1a0e91..7ca146514fece1c8f6aa0fb6358f36897296d8b9 100644 --- a/modules/compiler_v2/platform/platform.go +++ b/modules/compiler_v2/platform/platform.go @@ -1,7 +1,9 @@ package platform +// OS Operating system type type OS = string +// Platform enums const ( Windows OS = "windows" Linux OS = "linux" diff --git a/modules/compiler_v2/rust_compiler_v2/rust_compiler.go b/modules/compiler_v2/rust_compiler_v2/rust_compiler.go index 6b3883c23e11370b52e09ce01d82389b17c6f5cc..9078256e54b1b1d5a341cf40518bd50ff3a47a8b 100644 --- a/modules/compiler_v2/rust_compiler_v2/rust_compiler.go +++ b/modules/compiler_v2/rust_compiler_v2/rust_compiler.go @@ -11,10 +11,17 @@ const fileName = "main.rs" type RustCompiler struct{} +// NewRustCompiler creates a new RustCompiler func NewRustCompiler() *RustCompiler { return &RustCompiler{} } +// CheckCompileErrors takes Rust source code and the dependencies it requires and checks for compile errors. +// +// The dependencies are optional, and should be name only, not version. +// For instance "rand" and not "rand:0.8.3". Cargo will automatically fetch the latest version. +// +// Returns the output of the compilation and an error if any func (gb *RustCompiler) CheckCompileErrors(srcCode []byte, dependencies ...string) ([]byte, error) { // Make temp folders utils.SetupTempFolders(consts.TempOutputDir) @@ -45,6 +52,7 @@ func (gb *RustCompiler) CheckCompileErrors(srcCode []byte, dependencies ...strin return cmd.CombinedOutput() } +// initCargo initializes a cargo project func initCargo() error { // Init cargo cmd := utils.MakeCommand("cargo init --bin")