evgenyigumnov / rustsn

This Rust-based tool generates, compiles, and tests code using LLMs, resolves dependencies, and provides explanations of existing code through embeddings.
Apache License 2.0
60 stars 15 forks source link

Add Go support #12

Open evgenyigumnov opened 1 month ago

evgenyigumnov commented 1 month ago

Launch example

rustsn --lang=go

Example query:

take 2 params and add them and return result

Example generation:

go.mod

module solution

go 1.20

require (
    github.com/stretchr/testify v1.8.0
)

main.go

package main

import "fmt"

// Solution adds two integers and returns the result
func Solution(a, b int) int {
    return a + b
}

func main() {
    result := Solution(1, 2)
    fmt.Println("Result:", result)
}

main_test.go

package main

import (
    "testing"

    "github.com/stretchr/testify/assert"
)

func TestSolution(t *testing.T) {
    assert.Equal(t, 3, Solution(1, 2), "1 + 2 should be 3")
    assert.Equal(t, -3, Solution(-1, -2), "-1 + -2 should be -3")
    // Note: To handle different types, you might need to adjust the function or tests accordingly
}

Example install dependencies

go mod tidy

Example build the project

go build -o solution

Example run tests

go test