gv

package module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2025 License: MIT Imports: 23 Imported by: 0

README

Discord

🚀 GV (Go Vite)

GV is a blazing-fast, browser-native development server and build tool written in Go. It’s inspired by Vite but designed to run without Node.js, using the power of native ESM in modern browsers and CDN-based dependency resolution.

⚡ Powered by Go. 🔌 Plugin-friendly. 🧠 Node-free.


💎 Philosophy

We should be able to use JavaScript frameworks, without 'node' or any runtime, just your browser.


✨ Features

  • Native ESM support in modern browsers
  • CDN-based module fetching (e.g., esm.sh, skypack)
  • Local caching of remote modules
  • Hot Module Replacement (HMR)
  • Zero-config dev server
  • esbuild-based transpilation
  • babel-based transpilation
  • Plugin system (inspired by Vite/Rollup)
  • Written in Go with extensibility in mind
  • No Node.js required — ever
  • TypeScript support
  • Adapter to support any http server

Installation

For Linux, MacOS and Windows

curl -fsSL https://raw.githubusercontent.com/struckchure/gv/main/scripts/install.sh | bash

For Windows

irm https://raw.githubusercontent.com/struckchure/gv/main/scripts/install.ps1 | iex

🔧 Getting Started

git clone https://github.com/struckchure/gv
cd gv/examples/react
go run .

Then open your browser to http://localhost:3000.


📦 How It Works

  • 📜 Transpiling: Uses babel internally for .ts, .jsx, .tsx, etc.
  • 🌐 CDN Resolution: Bare imports (like react) are rewritten to point to https://esm.sh/react and cached locally.
  • 🔥 HMR: WebSocket server pushes updates to the browser with minimal reloads.
  • 🧩 Plugins: Extend GV with hooks like transform, resolveId, and load.

📁 Project Structure

Well, your project structure can be anyhow you want, but here's a sample react project

.
├── index.html
├── main.go
├── main.jsx
├── router.js
└── routes
    ├── layout.jsx
    ├── login
    │   └── page.jsx
    ├── page.jsx
    └── register
        └── page.jsx

Import from CDNs or local files directly:

import { createRoot } from "https://esm.sh/react-dom@19.1.0/client";
import { RouterProvider } from "https://esm.sh/react-router@7.5.0";
import React from "https://esm.sh/react@19.1.0";

import { router } from "./router.js";

createRoot(document.getElementById("root")).render(
  <RouterProvider router={router} />
);

🔌 Plugin API

Check here.


📜 License

MIT © 2025 Mohammed Al-Ameen

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HmrBroadcast = make(chan string)
View Source
var HmrClientBroadcast = make(chan HmrResult)

Functions

func CopyFile

func CopyFile(src, dst string) error

func ExecCommand

func ExecCommand(command string, args []string) (string, error)

ExecCommand executes a command with arguments and returns the combined output

func ExecCommandWithCallback

func ExecCommandWithCallback(command string, args []string, callback func(output string)) error

ExecCommandWithCallback executes a command and calls the callback with the output

func ExecStringCommand

func ExecStringCommand(cmdString string) (string, error)

ExecStringCommand executes a command from a string with space-separated arguments

func Hmr added in v0.0.4

func Hmr(rootHtml string) func(*ContainerPlugin)

Types

type Cdn added in v0.0.6

type Cdn struct {
	Name string `yaml:"name"`
	URL  string `yaml:"url"`
}

type ContainerPlugin added in v0.0.4

type ContainerPlugin struct {
	// contains filtered or unexported fields
}

func NewContainerPlugin added in v0.0.4

func NewContainerPlugin(filter string) *ContainerPlugin

func (*ContainerPlugin) Compose added in v0.0.4

func (pc *ContainerPlugin) Compose() api.Plugin

func (*ContainerPlugin) OnHMR added in v0.0.4

func (pc *ContainerPlugin) OnHMR(callback HmrCallback) *ContainerPlugin

func (*ContainerPlugin) OnLoad added in v0.0.4

func (pc *ContainerPlugin) OnLoad(name, filter string, callback LoadCallback) *ContainerPlugin

func (*ContainerPlugin) OnResolve added in v0.0.4

func (pc *ContainerPlugin) OnResolve(name, filter string, callback ResolveCallback) *ContainerPlugin

func (*ContainerPlugin) Setup added in v0.0.4

func (pc *ContainerPlugin) Setup(modifier ...func(*ContainerPlugin)) *ContainerPlugin

func (*ContainerPlugin) WithHmr added in v0.0.4

func (pc *ContainerPlugin) WithHmr(opts HmrOptions) *ContainerPlugin

type DependencyConfig

type DependencyConfig struct {
	Cdns     []Cdn     `yaml:"cdns"`
	Packages []Package `yaml:"packages"`
	Types    []string  `yaml:"types"`
}

type FileCallback added in v0.0.4

type FileCallback func(path string)

type HmrCallback added in v0.0.4

type HmrCallback func(string) (*HmrResult, error)

type HmrOptions added in v0.0.4

type HmrOptions struct {
	RootHtml          string
	WatchPath         string
	WatchExcludePaths []string
}

type HmrResult added in v0.0.4

type HmrResult struct {
	Type HmrType `json:"type"`
	Path string  `json:"path"`
}

type HmrType added in v0.0.4

type HmrType string
const (
	HmrReloadType HmrType = "reload"
	HmrUpdateType HmrType = "update"
)

type LoadCallback added in v0.0.4

type LoadCallback func(api.OnLoadArgs) (api.OnLoadResult, error)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(opts ManagerOptions) *Manager

func (*Manager) Add added in v0.0.6

func (m *Manager) Add(packages ...string) error

func (*Manager) Sync

func (m *Manager) Sync(depsFile string)

type ManagerOptions added in v0.0.6

type ManagerOptions struct {
	ConfigFile string
}

type Package

type Package struct {
	Name string `yaml:"name"`
	URL  string `yaml:"url"`
}

type PackageMeta

type PackageMeta struct {
	Name              string                         `json:"name"`
	Version           string                         `json:"version"`
	Main              string                         `json:"main"`
	Types             string                         `json:"types"`
	TypesVersions     map[string]map[string][]string `json:"typesVersions"`
	Exports           map[string]any                 `json:"exports"`
	Dependencies      map[string]string              `json:"dependencies"`
	PeerDependencies  map[string]string              `json:"peerDependencies"`
	TypeScriptVersion string                         `json:"typeScriptVersion"`
}

type ResolveCallback added in v0.0.4

type ResolveCallback func(api.OnResolveArgs) (api.OnResolveResult, error)

type RpcError

type RpcError struct {
	Code    RpcErrorCode `json:"code"`
	Message string       `json:"message"`
	Data    any          `json:"data"`
}

type RpcErrorCode

type RpcErrorCode int
const (
	RpcErrorCodeParseError     RpcErrorCode = -32700
	RpcErrorCodeInvalidRequest RpcErrorCode = -32600
	RpcErrorCodeMethodNotFound RpcErrorCode = -32601
	RpcErrorCodeInvalidParams  RpcErrorCode = -32602
	RpcErrorCodeInternalError  RpcErrorCode = -32603
	RpcErrorCodeServerError    RpcErrorCode = -32000
)

type RpcMethod

type RpcMethod struct {
	Name    string
	Handler func(RpcRequest) RpcResponse
}

type RpcRequest

type RpcRequest struct {
	Jsonrpc string `json:"jsonrpc"`
	Method  string `json:"method"`
	Params  any    `json:"params"`
	Id      string `json:"id"`
}

type RpcResponse

type RpcResponse struct {
	Jsonrpc string    `json:"jsonrpc"`
	Result  *any      `json:"result,omitempty"`
	Error   *RpcError `json:"error,omitempty"`
	Id      string    `json:"id"`
}

type RpcServer

type RpcServer struct{}

func NewRpcServer

func NewRpcServer() *RpcServer

func (*RpcServer) Handle

func (r *RpcServer) Handle()

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg ServerConfig) *Server

func (*Server) Build added in v0.0.4

func (s *Server) Build() error

func (*Server) HandleHMR added in v0.0.4

func (s *Server) HandleHMR() error

func (*Server) Server

func (s *Server) Server() *echo.Echo

func (*Server) Start

func (s *Server) Start() error

func (*Server) Watch

func (s *Server) Watch() error

type ServerConfig

type ServerConfig struct {
	Host string
	Port int

	EsBuildOptions    api.BuildOptions
	WatchPath         *string
	WatchExcludePaths *[]string
}

type Watcher added in v0.0.4

type Watcher struct {
	// contains filtered or unexported fields
}

func NewWatcher added in v0.0.4

func NewWatcher(rootPath string, ignorePaths []string, cb FileCallback) (*Watcher, error)

func (*Watcher) Close added in v0.0.4

func (w *Watcher) Close() error

func (*Watcher) Start added in v0.0.4

func (w *Watcher) Start() error

Directories

Path Synopsis
_templates
blank command
react command
svelte command
vue command
examples
react command
svelte command
todo-app command
vue command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL