update setup for new Go SDK (#2500)

This commit is contained in:
Mohammed Nafees
2025-11-06 21:17:14 +01:00
committed by GitHub
parent 7fe9806f5d
commit 17dc738ae3
3 changed files with 15 additions and 68 deletions
+2 -1
View File
@@ -94,7 +94,8 @@ export default function InstallCommand({
return (
<CodeBlock source={{
language: "bash",
raw: `go get -u github.com/hatchet-dev/hatchet/sdks/go@latest`,
raw: `go get -u github.com/hatchet-dev/hatchet/sdks/go@latest
go mod tidy`,
}} />
);
}
+8 -32
View File
@@ -5,7 +5,7 @@ import InstallCommand from "@/components/InstallCommand";
#### Cd into your project directory
```bash copy
cd path-to-your-project
cd /path/to/your-project
```
#### Create project directories
@@ -13,56 +13,32 @@ cd path-to-your-project
By convention it is recommended to create your workflows in the `workflows` directory and your workers in the `workers` directory.
```bash copy
mkdir workflows &&
mkdir workers
```
#### Instantiate your Hatchet Client
It is recommended to instantiate a shared Hatchet Client Factory in a separate file.
Create a new directory called `hatchet_client` and a new file called `main.go` in it.
```bash copy
mkdir hatchet_client &&
touch hatchet_client/main.go
```
Add the following code to the file:
```go copy
package hatchet
import (
"github.com/hatchet-dev/hatchet/pkg/client"
)
func Client() (client.Client, error) {
return client.New()
}
mkdir workflows && mkdir workers
```
#### Install the Hatchet SDK and required dependencies
<InstallCommand installOnly />
#### Import the Hatchet Client Factory
#### Instantiate your Hatchet Client
You can now import the Hatchet Client Factory in any file that needs it.
In the `workers` directory, create a Hatchet client
```go copy
package main
import (
"log"
hatchet "hatchet-tutorial/src/hatchet_client"
hatchet "github.com/hatchet-dev/hatchet/sdks/go"
)
func main() {
hatchet, err := hatchet.Client()
client, err := hatchet.NewClient()
if err != nil {
log.Fatal(err)
log.Fatalf("failed to create hatchet client: %v", err)
}
}
```
+5 -35
View File
@@ -17,42 +17,12 @@ go mod init hatchet-tutorial
#### Create project directories
```bash copy
mkdir workflows &&
mkdir workers
mkdir workflows && mkdir workers
```
#### Instantiate your Hatchet Client
It is recommended to instantiate a shared Hatchet Client Factory in a separate file.
Create a new directory called `hatchet_client` and a new file called `main.go` in it.
```bash copy
mkdir hatchet_client &&
touch hatchet_client/main.go
```
Add the following code to the file:
```go copy
package hatchet
import (
"github.com/hatchet-dev/hatchet/pkg/client"
)
func Client() (client.Client, error) {
return client.New()
}
```
#### Install the Hatchet SDK and required dependencies
<InstallCommand installOnly />
#### Import the Hatchet Client Factory
You can now import the Hatchet Client Factory in any file that needs it.
In the `workers` directory, create a Hatchet client
```go copy
package main
@@ -60,13 +30,13 @@ package main
import (
"log"
hatchet "hatchet-tutorial/hatchet_client"
hatchet "github.com/hatchet-dev/hatchet/sdks/go"
)
func main() {
hatchet, err := hatchet.Client()
client, err := hatchet.NewClient()
if err != nil {
log.Fatal(err)
log.Fatalf("failed to create hatchet client: %v", err)
}
}
```