Skip to content

Commit 12710c1

Browse files
committed
chore: reorder readme
Signed-off-by: Christian Stewart <christian@aperture.us>
1 parent 7c40dca commit 12710c1

File tree

1 file changed

+68
-67
lines changed

1 file changed

+68
-67
lines changed

README.md

Lines changed: 68 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ goscript compile --package . --output ./dist
6666

6767
## 📦 Using Generated Code in Your Project
6868

69-
After compiling your Go code to TypeScript, you'll need to set up your project to consume the generated files.
69+
After compiling your Go code to TypeScript, you'll need to set up your project appropriately.
7070

7171
### TypeScript Configuration
7272

@@ -99,6 +99,73 @@ Create or update your `tsconfig.json` with these settings:
9999

100100
You should be able to use any TypeScript bundler to compile the generated TypeScript.
101101

102+
## 🛠️ Integration & Usage
103+
104+
### Command Line
105+
106+
```bash
107+
goscript compile --package ./my-go-code --output ./dist
108+
```
109+
110+
**Options:**
111+
- `--package <path>` - Go package to compile (default: ".")
112+
- `--output <dir>` - Output directory for TypeScript files
113+
114+
### Programmatic API
115+
116+
**Go:**
117+
```go
118+
import "github.com/aperturerobotics/goscript/compiler"
119+
120+
conf := &compiler.Config{OutputPath: "./dist"}
121+
comp, err := compiler.NewCompiler(conf, logger, nil)
122+
_, err = comp.CompilePackages(ctx, "your/package/path")
123+
```
124+
125+
**Node.js:**
126+
```typescript
127+
import { compile } from 'goscript'
128+
129+
await compile({
130+
pkg: './my-go-package',
131+
output: './dist'
132+
})
133+
```
134+
135+
### Frontend Frameworks
136+
137+
**React + GoScript:**
138+
```typescript
139+
import { NewCalculator } from '@goscript/myapp/calculator'
140+
141+
function CalculatorApp() {
142+
const [calc] = useState(() => NewCalculator())
143+
144+
const handleAdd = () => {
145+
const result = calc.Add(5, 3)
146+
setResult(result)
147+
}
148+
149+
return <button onClick={handleAdd}>Add 5 + 3</button>
150+
}
151+
```
152+
153+
**Vue + GoScript:**
154+
```vue
155+
<script setup lang="ts">
156+
import { NewUser, FindUserByEmail } from '@goscript/myapp/user'
157+
158+
const users = ref([
159+
NewUser(1, "Alice", "alice@example.com")
160+
])
161+
162+
const searchUser = (email: string) => {
163+
return FindUserByEmail(users.value, email)
164+
}
165+
</script>
166+
```
167+
168+
102169
## 💡 See It In Action
103170

104171
### Example: User Management
@@ -231,72 +298,6 @@ async function handleMessages() {
231298
}
232299
```
233300

234-
## 🛠️ Integration & Usage
235-
236-
### Command Line
237-
238-
```bash
239-
goscript compile --package ./my-go-code --output ./dist
240-
```
241-
242-
**Options:**
243-
- `--package <path>` - Go package to compile (default: ".")
244-
- `--output <dir>` - Output directory for TypeScript files
245-
246-
### Programmatic API
247-
248-
**Go:**
249-
```go
250-
import "github.com/aperturerobotics/goscript/compiler"
251-
252-
conf := &compiler.Config{OutputPath: "./dist"}
253-
comp, err := compiler.NewCompiler(conf, logger, nil)
254-
_, err = comp.CompilePackages(ctx, "your/package/path")
255-
```
256-
257-
**Node.js:**
258-
```typescript
259-
import { compile } from 'goscript'
260-
261-
await compile({
262-
pkg: './my-go-package',
263-
output: './dist'
264-
})
265-
```
266-
267-
### Frontend Frameworks
268-
269-
**React + GoScript:**
270-
```typescript
271-
import { NewCalculator } from '@goscript/myapp/calculator'
272-
273-
function CalculatorApp() {
274-
const [calc] = useState(() => NewCalculator())
275-
276-
const handleAdd = () => {
277-
const result = calc.Add(5, 3)
278-
setResult(result)
279-
}
280-
281-
return <button onClick={handleAdd}>Add 5 + 3</button>
282-
}
283-
```
284-
285-
**Vue + GoScript:**
286-
```vue
287-
<script setup lang="ts">
288-
import { NewUser, FindUserByEmail } from '@goscript/myapp/user'
289-
290-
const users = ref([
291-
NewUser(1, "Alice", "alice@example.com")
292-
])
293-
294-
const searchUser = (email: string) => {
295-
return FindUserByEmail(users.value, email)
296-
}
297-
</script>
298-
```
299-
300301
## 🚀 What's Next?
301302

302303
**Current Status:**

0 commit comments

Comments
 (0)