> For the complete documentation index, see [llms.txt](https://gauntletlang.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gauntletlang.gitbook.io/docs/readme.md).

# 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://gauntletlang.gitbook.io/docs/readme.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
