# Welcome

**Welcome to the official documentation for the Gauntlet Programming Language.**

Gauntlet was made so you can overcome Golang's frustrating design choices. Have a look:

{% tabs %}
{% tab title="Gauntlet" %}

```fsharp
package main

// Seamless interop with the entire golang ecosystem
import "fmt" as fmt
import "os" as os
import "strings" as strings
import "strconv" as strconv


// Explicit export keyword
export fun getTrimmedFileLines(fileName: String): ([]String, Error) {
  // try-with syntax replaces verbose `err != nil` error handling
  let fileContent, err = try os.readFile(fileName) with (null, err)
  
  // Type conversion
  let fileContentStrVersion = (String)(fileContent) 

  let trimmedLines = 
    // Pipes feed output of last function into next one
    fileContentStrVersion
    |> strings.trimSpace(_)
    |> strings.split(_, "\n")

  // `nil` is equal to `null` in Gauntlet
  return (trimmedLines, null)
    
}


fun main(): Unit {
  // No 'unused variable' errors
  let a = 1 

  // force-with syntax will panic if err != nil
  let lines, err = force getTrimmedFileLines("example.txt") with err
  
  // Ternary operator
  let properWord = @String len(lines) > 1 ? "lines" : "line"

  let stringLength = lines |> len(_) |> strconv.itoa(_)

  fmt.println("There are " + stringLength + " " + properWord + ".")
  fmt.println("Here they are:")

  // Simplified for-loops
  for let i, line in lines {
    fmt.println("Line " + strconv.itoa(i + 1) + " is:")
    fmt.println(line)
  }

}

```

{% endtab %}

{% tab title="Transpiled" %}

```go
package main

import fmt "fmt"
import os "os"
import strings "strings"
import strconv "strconv"

func GetTrimmedFileLines(fileName string) ([]string, error) {
	fileContent, err := os.ReadFile(fileName)
	if err != nil {
		return nil, err
	}
	fileContentStrVersion := string(fileContent)
	trimmedLines := strings.Split(strings.TrimSpace(fileContentStrVersion), "\n")

	// Eliminates any 'unused variable' errors
	_, _, _, _ = err, fileContent, fileContentStrVersion, trimmedLines
	return trimmedLines, nil

}

func main() {
	a := 1
	lines, err := GetTrimmedFileLines("example.txt")
	if err != nil {
		panic(err)
	}
	properWord := (func() string {
		if len(lines) > 1 {
			return "lines"
		}
		return "line"
	})()
	stringLength := strconv.Itoa(len(lines))
	fmt.Println("There are " + stringLength + " " + properWord + ".")
	fmt.Println("Here they are:")
	for i, line := range lines {
		fmt.Println("Line " + strconv.Itoa(i+1) + " is:")
		fmt.Println(line)
		// Eliminates any 'unused variable' errors
		_, _ = i, line
	}
	// Eliminates any 'unused variable' errors
	_, _, _, _, _ = a, err, lines, properWord, stringLength

}

```

{% endtab %}

{% tab title="example.txt" %}

```
Whats
the
meaning
of 
life
```

{% endtab %}

{% tab title="Output" %}

```
There are 5 lines.
Here they are:
Line 1 is:
Whats
Line 2 is:
the
Line 3 is:
meaning
Line 4 is:
of 
Line 5 is:
life
```

{% endtab %}
{% endtabs %}

Like what you see? Hit the "Introduction To Gauntlet" button below.
