GoScript is a full-stack web development framework written in Go, designed to provide a complete solution for building modern web, mobile, and AR/VR applications. It combines the performance of Go with the flexibility of modern web technologies, offering a unified approach to frontend, backend, and database development.
GoScript aims to be the most comprehensive Go-based web development framework, combining the best features of modern web frameworks with the performance and type safety of Go. It provides a complete solution for building web applications, from frontend to backend, with built-in support for CSS, 3D rendering, API development, database integration, and performance monitoring.
GoScript consists of several integrated components that work together to provide a complete development experience:
GoScript provides a familiar experience for TypeScript and React developers:
-
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 Framework Features
- Server-side rendering (SSR)
- Client-side hydration
- Global state management
- Routing with middleware support
- Static asset management
- Hot-reloading for development
- CLI for component generation
Gocsx is a Tailwind-inspired CSS framework that provides a utility-first approach to styling web applications. 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 dev
type 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 framework:
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 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 API for React developers, but requires Go knowledge
- Ecosystem: React has a larger ecosystem, but 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
- 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