# Golang

## Installation

```bash
go get -u github.com/Implex-ltd/crapsolver/crapsolver
```

***

## Example

```go
package main

import (
	"fmt"
	"time"
	"github.com/Implex-ltd/crapsolver/crapsolver"
)

var (
	KEY    = "4c672d35-0701-42b2-88c3-78380b0db560"
	DOMAIN = "discord.com"
)

func main() {
	Crap, err := crapsolver.NewSolver("user:superapikey")
	if err != nil {
		panic(err)
	}

	Crap.SetWaitTime(time.Second * 3) // check for complete task every 3s (reduce our load + make less req on your side..)

	// get restriction for the current sitekey
	restrictions, err := crapsolver.GetRestrictions(KEY)
	if err != nil {
		panic(err)
	}

	log.Println(restrictions)

	/**
	 * Use the function "Crap.SolveUntil(config, max_retry...)" to retry if error spawn (leave 0 = infinite) / return list of spawned errors
	 */
	resp, err := Crap.Solve(&crapsolver.TaskConfig{
		SiteKey:  KEY,
		Domain:   DOMAIN,
		TaskType: crapsolver.TASKTYPE_ENTERPRISE,
		A11YTfe:  true,
		Turbo:    true,
		TurboSt:  3200,
	})

	if err != nil {
		panic(err)
	}

	log.Println("solved:", resp.Data.Token)
	log.Println("submit this key using user-agent: ", resp.Data.UserAgent)
}
```

***

## Get site-key restrictions

```go
restrictions, err := crapsolver.GetRestrictions("4c672d35-0701-42b2-88c3-78380b0db560")
if err != nil {
	panic(err)
}

log.Println(restrictions)
```

***

### Get account informations

```go
response, err := crapsolver.GetUser("user:superidofyouraccakaapikey")
if err != nil {
	panic(err)
}

log.Println(response.balance, response.solved_hcaptcha)
```


---

# Agent Instructions: 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:

```
GET https://crapsolver.gitbook.io/readme/packages/golang.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
