# What is gosfc?

> gosfc is a thin integration layer that lets the <script setup> of a Vue component, and the frontmatter and <script> of an .astro file, be real Go, compiled by goesm.

An integration layer for using real Go in the `<script setup>` of Vue Single File Components, and in the frontmatter and `<script>` of `.astro` files.

```vue
<template>
  <div>
    Total: {{ total }}
  </div>
</template>

<script setup lang="go">
import cart "example.com/app/src/features/cart/pkg"

items := []cart.Item{
	{
		Price:    100,
		Quantity: 2,
	},
}

total := cart.Total(items)
</script>
```

`.go` files are ordinary Go packages, and imports are ordinary Go imports. Go compilation is handled by [goesm](https://github.com/goesm-dev/goesm), SFCs and templates by the Vue tooling, `.astro` templates by Astro, builds by Vite, and pages and SSR by Astro. See [ARCHITECTURE.md](https://goesm.dev/gosfc/reference/architecture.md) for the design.

**Status: PoC.** What is not implemented yet is listed in ARCHITECTURE.md, section 11 ("Not yet implemented / open questions").

## Who does what

gosfc finds the Go of `.vue` and `.astro` files, turns it into ordinary Go
files, and connects what goesm compiles to Vue and Astro. Everything else is done by the tools
that already do it:

| | Does | Does not |
| --- | --- | --- |
| gosfc | finds the Go block, builds the Go file, calls goesm, exposes the bindings to the template, keeps source positions; the Vite plugin and the Astro integration | parse or type-check Go, resolve modules, compile templates or styles, bundle, render |
| goesm | Go packages and modules, parsing, type checking, Go semantics, TypeScript output with source maps to `.go` | anything about Vue or Astro |
| Vue tooling | SFC parsing, template compilation, scoped CSS, HMR | Go |
| Vite | dev server, TypeScript to JavaScript, bundling | Go, SFCs |
| Astro | pages, SSR, static builds, islands | Go, the inside of SFCs |

[The architecture](https://goesm.dev/gosfc/reference/architecture.md) describes each step.
