GoScript is a Go-native language and application platform for building modern web experiences without handing the language layer to JavaScript. It keeps a familiar app structure for people who know modern web frameworks, but it is not a Next.js replacement. GoScript is the Go community's path to a first-class web stack in Go.
GoScript aims to give Go developers a single language across product logic, UI logic, and backend logic. The project includes language tooling, runtime primitives, rendering systems, API support, database integration, and performance tooling, all shaped around Go instead of JavaScript.
GoScript consists of several integrated components that work together to provide a complete development experience:
GoScript provides a familiar app structure for developers coming from modern web frameworks, but the core idea is language ownership:
-
Enhanced Component System
- Class-based components with lifecycle methods
- Functional components
- Props validation
- Component state management
- Context API for state sharing
- Hooks system (useState, useEffect, useContext, useMemo, useCallback, useRef)
- JSX-like syntax parser
- Fragment support
- Component testing utilities
-
Core Platform Features
- Server-side rendering (SSR)
- Client-side hydration
- Global state management
- Routing with middleware support
- Static asset management
- Hot-reloading for development
- CLI for language and project tooling
Gocsx is a Tailwind-inspired CSS system that lets GoScript and Go projects style interfaces without leaving Go-centric tooling. It includes:
- Utility Classes: A comprehensive set of utility classes for rapid UI development
- Component System: Pre-built components with variants and responsive design
- Theme Support: Customizable themes with dark/light mode support
- Platform Adapters: Support for web, mobile, and other platforms
- CSS Generation: Efficient CSS generation with minimal output size
GoEngine provides a unified approach to 2D and 3D rendering, with support for:
- WebGPU Integration: Modern 3D graphics capabilities with:
- A Go wrapper around the WebGPU API
- Shader compilation and management
- Resource management for GPU buffers and textures
- A render pipeline abstraction
- Canvas2D API: Simplified 2D drawing and animation
- Scene Graph: Hierarchical scene management for both 2D and 3D
- Three.js-like API: Familiar API for 3D scene management
- Performance Optimization:
- Automatic detection of interactive applications
- Performance throttling based on device capabilities
- Unified API for both 2D and 3D contexts
GoScale provides a high-performance API and database system with:
- GraphQL-like Flexibility: Define schemas and queries with GraphQL-like syntax
- gRPC-like Performance: High-performance binary protocol
- Edge Computing: Distributed API processing
- Database Integration: Support for PostgreSQL, NoSQL, and time-series data
- Schema Management: Automatic schema generation and migration
GOPM is a comprehensive package manager for Go projects, with special support for the GoScript ecosystem:
- Package Management: Install, update, and manage dependencies
- Project Setup: Initialize and configure projects
- Build Tools: Build, test, and deploy applications
- Framework Integration: Special commands for Gocsx, GoEngine, GoScale, and more
Jetpack provides comprehensive performance monitoring and optimization tools:
- Real-time Metrics: Monitor FPS, memory usage, API latency, and more
- Google Lighthouse Integration: Run Lighthouse audits and track Core Web Vitals
- Performance Panel: Floating translucent panel for real-time metrics visualization
- Chrome DevTools Extension: Advanced performance monitoring in Chrome DevTools
- Security Monitoring: Track vulnerabilities, suspicious activities, and security compliance
# Install GOPM
go install github.com/davidjeba/goscript/cmd/gopm@latest
# Initialize a new project
gopm setup my-project
cd my-project
# Install dependencies
gopm get# Initialize a new web application
gopm setup --template web my-app
cd my-app
# Start the development server
gopm run devtype MyComponent struct {
goscript.LifecycleComponentBase
}
func NewMyComponent(props goscript.Props) *MyComponent {
base := goscript.NewBaseComponent(props, nil)
component := &MyComponent{}
component.LifecycleComponentBase.BaseComponent = *base
return component
}
func (c *MyComponent) Render() string {
return goscript.CreateElement("div", nil,
goscript.CreateElement("h1", nil, "Hello, World!"),
)
}func MyComponent(props goscript.Props) string {
return goscript.CreateElement("div", nil,
goscript.CreateElement("h1", nil, "Hello, World!"),
)
}package main
import (
"log"
"net/http"
"github.com/davidjeba/goscript/pkg/gocsx"
"github.com/davidjeba/goscript/pkg/gocsx/engine"
)
func main() {
// Create a new Gocsx instance
g := gocsx.New()
// Create a new engine with 2D context
e := engine.NewEngine(&engine.EngineConfig{
Context: engine.Context2D,
})
// Create a new Canvas2D
canvas := engine.NewCanvas2D("main-canvas", 800, 600, e)
// Set render callback
canvas.SetRenderCallback(func(ctx *engine.Canvas2DContext, deltaTime float64) {
// Clear the canvas
ctx.ClearRect(0, 0, 800, 600)
// Draw a rectangle
ctx.FillStyle = "#ff0000"
ctx.FillRect(100, 100, 200, 150)
})
// Start the engine
e.Start()
// Start the server
log.Fatal(http.ListenAndServe(":8080", nil))
}package main
import (
"log"
"net/http"
"github.com/davidjeba/goscript/pkg/gocsx"
"github.com/davidjeba/goscript/pkg/gocsx/engine"
)
func main() {
// Create a new Gocsx instance
g := gocsx.New()
// Create a new engine with 3D context
e := engine.NewEngine(&engine.EngineConfig{
Context: engine.Context3D,
})
// Create a new WebGPU instance
webgpu := engine.NewWebGPU()
// Create a new Three.js scene
scene := engine.NewThreeJSScene(e, webgpu)
// Create a camera
scene.CreateCamera("main-camera", "Main Camera", [3]float64{0, 0, 5}, [3]float64{0, 0, 0})
// Create a cube
scene.CreateCube("cube1", "Cube 1", [3]float64{0, 0, 0}, 1.0, [3]float64{1, 0, 0})
// Start the engine
e.Start()
// Start the server
log.Fatal(http.ListenAndServe(":8080", nil))
}package main
import (
"log"
"github.com/davidjeba/goscript/pkg/goscale/api"
"github.com/davidjeba/goscript/pkg/goscale/db"
)
func main() {
// Initialize database
database, err := db.NewGoScaleDB(&db.Config{
ConnectionString: "postgres://user:password@localhost:5432/mydb",
TimeSeriesEnabled: true,
})
if err != nil {
log.Fatalf("Failed to initialize database: %v", err)
}
// Define schema
schema := api.NewSchema()
schema.AddType("User", map[string]string{
"id": "ID!",
"name": "String!",
"email": "String!",
"posts": "[Post]",
})
schema.AddType("Post", map[string]string{
"id": "ID!",
"title": "String!",
"content": "String!",
"author": "User!",
})
// Initialize API
apiServer := api.NewGoScaleAPI(&api.Config{
Schema: schema,
DB: database,
Port: 8080,
EdgeEnabled: true,
})
// Start API server
log.Fatal(apiServer.Start())
}package main
import (
"log"
"net/http"
"github.com/davidjeba/goscript/pkg/jetpack/core"
"github.com/davidjeba/goscript/pkg/jetpack/frontend"
)
func main() {
// Initialize Jetpack
jp := core.NewJetpack()
jp.EnableDevMode()
// Create performance panel
panel := frontend.NewPerformancePanel(jp)
panel.Show()
// Register metrics
fps := 60.0
jp.RegisterMetric(
core.MetricFPS,
"fps",
"Frames per second",
"fps",
&fps,
[]string{"performance"},
)
// Initialize Lighthouse monitor
lighthouse := frontend.NewLighthouseMonitor(jp)
// Run Lighthouse audit
_, err := lighthouse.RunAudit("http://localhost:8080")
if err != nil {
log.Printf("Failed to run Lighthouse audit: %v", err)
}
// Start exporting metrics
jp.ExportEnabled = true
jp.ExportEndpoint = "http://metrics.example.com"
jp.StartExporting()
// Start HTTP server
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// Record FPS metric
jp.RecordMetric("fps", 58.5)
// Serve HTML with performance panel
html := `<!DOCTYPE html><html><body><h1>Hello World</h1></body></html>`
htmlWithPanel, _ := panel.InjectIntoHTML(html)
w.Header().Set("Content-Type", "text/html")
w.Write([]byte(htmlWithPanel))
})
log.Fatal(http.ListenAndServe(":8080", nil))
}GoScript follows a modular architecture that allows each component to be used independently or together as a complete platform:
GoScript
βββ Gocsx (CSS Framework)
β βββ Core
β β βββ Configuration
β β βββ CSS Generator
β β βββ Component System
β βββ Platforms
β β βββ Web
β β βββ Mobile
β β βββ Desktop
β βββ Components
β βββ Button
β βββ Card
β βββ ...
βββ GoEngine (2D/3D Rendering)
β βββ Core
β β βββ Engine
β β βββ Scene Graph
β βββ WebGPU
β β βββ Renderer
β β βββ Shaders
β βββ Canvas2D
β βββ Renderer
β βββ Sprites
βββ GoScale (API and Database)
β βββ API
β β βββ Schema
β β βββ Resolvers
β β βββ Edge Computing
β βββ Database
β βββ PostgreSQL
β βββ NoSQL
β βββ TimeSeries
βββ GOPM (Package Manager)
β βββ Core
β β βββ Package Management
β β βββ Dependency Resolution
β βββ Commands
β βββ CSS Commands
β βββ WebGPU Commands
β βββ API Commands
β βββ DB Commands
βββ Jetpack (Performance Monitoring)
βββ Core
β βββ Metrics
β βββ Panel
βββ Frontend
β βββ Lighthouse
β βββ Web Vitals
βββ Backend
β βββ API Monitoring
β βββ System Metrics
βββ Security
βββ Vulnerability Scanning
βββ Anomaly Detection
GoScript uses a unified configuration approach across all components:
{
"gocsx": {
"theme": "default",
"breakpoints": {
"sm": "640px",
"md": "768px",
"lg": "1024px",
"xl": "1280px"
}
},
"engine": {
"webgpu": {
"enabled": true,
"shaders": "./shaders"
},
"canvas2d": {
"enabled": true,
"sprites": "./sprites"
}
},
"goscale": {
"api": {
"port": 8080,
"edge-enabled": true
},
"db": {
"connection-string": "localhost:5432",
"time-series-enabled": true
}
},
"jetpack": {
"monitoring": {
"enabled": true,
"metrics": ["fps", "memory_usage", "api_latency"]
},
"panel": {
"enabled": true,
"position": "bottom-right",
"opacity": 0.8
}
}
}- Language: GoScript is Go-native, JavaScript is the browser's native language and ecosystem.
- Team workflow: GoScript keeps product logic and UI logic in one Go mental model.
- Performance: GoScript inherits Go's compiled, predictable runtime characteristics.
- Type safety: GoScript benefits from Go's compile-time guarantees and explicitness.
- Deployment: GoScript fits a Go-shaped delivery story instead of a JS package graph.
- Ownership: Go teams stay in one language instead of splitting the product across Go and JS/TS.
- Best fit: GoScript is for teams that want the web to feel native to Go.
- Language: GoScript uses Go, React uses JavaScript/TypeScript.
- Performance: GoScript offers better performance due to Go's efficiency.
- Type Safety: GoScript has stronger type safety through Go's type system.
- Learning Curve: Familiar app structure for React developers, but grounded in Go.
- Ecosystem: React has a larger ecosystem, while GoScript integrates with Go libraries.
- CSS Framework: GoScript includes Gocsx, React requires external libraries.
- 3D Rendering: GoScript includes WebGPU integration, React requires external libraries.
- API System: GoScript includes GoScale, React requires external libraries.
- Performance Monitoring: GoScript includes Jetpack, React requires external libraries.
- Language: Gocsx uses Go, Tailwind uses JavaScript/CSS
- Platforms: Gocsx supports web, mobile, and AR/VR, Tailwind is web-only
- Type Safety: Gocsx has type safety, Tailwind does not
- Components: Gocsx has built-in components, Tailwind requires additional libraries
- Customization: Both have powerful customization options
- Language: GoScript uses Go, Three.js uses JavaScript
- Integration: GoScript offers tighter integration with the application
- Performance: GoScript can achieve better performance through Go
- Type Safety: GoScript has stronger type safety
- Features: Three.js has more features currently, but GoScript is rapidly evolving
GoScript matters because it gives the Go community a native blessing: a way to build modern web apps without asking every team member to learn a second language just to ship the frontend.
That means less context switching, fewer seams between backend and UI, and more of the product living in the language Go developers already trust. The point is not to replace JavaScript in the browser. The point is to let Go teams own more of the stack in Go, with the same clarity and discipline that made them choose Go in the first place.
- Mobile Platform Adapter: Native mobile support for iOS and Android
- AR/VR Platform Adapter: Support for AR and VR applications
- Advanced Component Library: Expanded set of UI components
- Testing Infrastructure: Comprehensive testing tools
- IDE Integration: Integration with popular IDEs
- Animation System: Advanced animation and transition system
- Machine Learning Integration: Integration with ML frameworks
- Serverless Deployment: Support for serverless deployment
- Multi-tenant Support: Built-in multi-tenant capabilities
- Internationalization: Built-in i18n support
Check out the examples in the repository:
pkg/components/counter.go: Demonstrates class-based components with statepkg/components/home.go: Shows how to use the context API and functional components
cmd/gocsx_demo: Basic CSS framework demo
cmd/gocsx_2d_demo: 2D canvas application democmd/gocsx_3d_demo: 3D WebGPU application demo
cmd/goscale_demo: API and database demo
cmd/jetpack_demo: Performance monitoring demo
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License