From ba68246cb42e206c8bb4bbe74deb0bccfa533bab Mon Sep 17 00:00:00 2001
From: Aleksander Einarsen <aleksace@stud.ntnu.no>
Date: Thu, 10 Oct 2024 11:30:41 +0200
Subject: [PATCH] Added comments

---
 modules/compiler_v2/go_compiler_v2/go_compiler.go     | 8 ++++++++
 modules/compiler_v2/platform/platform.go              | 2 ++
 modules/compiler_v2/rust_compiler_v2/rust_compiler.go | 8 ++++++++
 3 files changed, 18 insertions(+)

diff --git a/modules/compiler_v2/go_compiler_v2/go_compiler.go b/modules/compiler_v2/go_compiler_v2/go_compiler.go
index cb9cdf9..5d4f302 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 9d23851..7ca1465 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 6b3883c..9078256 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")
-- 
GitLab