Skip to content

Commit 17dc738

Browse files
authored
update setup for new Go SDK (#2500)
1 parent 7fe9806 commit 17dc738

File tree

3 files changed

+15
-68
lines changed

3 files changed

+15
-68
lines changed

frontend/docs/components/InstallCommand.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ export default function InstallCommand({
9494
return (
9595
<CodeBlock source={{
9696
language: "bash",
97-
raw: `go get -u github.com/hatchet-dev/hatchet/sdks/go@latest`,
97+
raw: `go get -u github.com/hatchet-dev/hatchet/sdks/go@latest
98+
go mod tidy`,
9899
}} />
99100
);
100101
}

frontend/docs/pages/_setup/_existing/go.mdx

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,64 +5,40 @@ import InstallCommand from "@/components/InstallCommand";
55
#### Cd into your project directory
66

77
```bash copy
8-
cd path-to-your-project
8+
cd /path/to/your-project
99
```
1010

1111
#### Create project directories
1212

1313
By convention it is recommended to create your workflows in the `workflows` directory and your workers in the `workers` directory.
1414

1515
```bash copy
16-
mkdir workflows &&
17-
mkdir workers
18-
```
19-
20-
#### Instantiate your Hatchet Client
21-
22-
It is recommended to instantiate a shared Hatchet Client Factory in a separate file.
23-
24-
Create a new directory called `hatchet_client` and a new file called `main.go` in it.
25-
26-
```bash copy
27-
mkdir hatchet_client &&
28-
touch hatchet_client/main.go
29-
```
30-
31-
Add the following code to the file:
32-
33-
```go copy
34-
package hatchet
35-
36-
import (
37-
"github.com/hatchet-dev/hatchet/pkg/client"
38-
)
39-
40-
func Client() (client.Client, error) {
41-
return client.New()
42-
}
16+
mkdir workflows && mkdir workers
4317
```
4418

4519
#### Install the Hatchet SDK and required dependencies
4620

4721
<InstallCommand installOnly />
4822

49-
#### Import the Hatchet Client Factory
23+
#### Instantiate your Hatchet Client
5024

5125
You can now import the Hatchet Client Factory in any file that needs it.
5226

27+
In the `workers` directory, create a Hatchet client
28+
5329
```go copy
5430
package main
5531

5632
import (
5733
"log"
5834

59-
hatchet "hatchet-tutorial/src/hatchet_client"
35+
hatchet "github.com/hatchet-dev/hatchet/sdks/go"
6036
)
6137

6238
func main() {
63-
hatchet, err := hatchet.Client()
39+
client, err := hatchet.NewClient()
6440
if err != nil {
65-
log.Fatal(err)
41+
log.Fatalf("failed to create hatchet client: %v", err)
6642
}
6743
}
6844
```

frontend/docs/pages/_setup/_new/go.mdx

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,56 +17,26 @@ go mod init hatchet-tutorial
1717
#### Create project directories
1818

1919
```bash copy
20-
mkdir workflows &&
21-
mkdir workers
20+
mkdir workflows && mkdir workers
2221
```
2322

2423
#### Instantiate your Hatchet Client
2524

26-
It is recommended to instantiate a shared Hatchet Client Factory in a separate file.
27-
28-
Create a new directory called `hatchet_client` and a new file called `main.go` in it.
29-
30-
```bash copy
31-
mkdir hatchet_client &&
32-
touch hatchet_client/main.go
33-
```
34-
35-
Add the following code to the file:
36-
37-
```go copy
38-
package hatchet
39-
40-
import (
41-
"github.com/hatchet-dev/hatchet/pkg/client"
42-
)
43-
44-
func Client() (client.Client, error) {
45-
return client.New()
46-
}
47-
```
48-
49-
#### Install the Hatchet SDK and required dependencies
50-
51-
<InstallCommand installOnly />
52-
53-
#### Import the Hatchet Client Factory
54-
55-
You can now import the Hatchet Client Factory in any file that needs it.
25+
In the `workers` directory, create a Hatchet client
5626

5727
```go copy
5828
package main
5929

6030
import (
6131
"log"
6232

63-
hatchet "hatchet-tutorial/hatchet_client"
33+
hatchet "github.com/hatchet-dev/hatchet/sdks/go"
6434
)
6535

6636
func main() {
67-
hatchet, err := hatchet.Client()
37+
client, err := hatchet.NewClient()
6838
if err != nil {
69-
log.Fatal(err)
39+
log.Fatalf("failed to create hatchet client: %v", err)
7040
}
7141
}
7242
```

0 commit comments

Comments
 (0)