Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 2 additions & 194 deletions public/projects/go-piml.txt
Original file line number Diff line number Diff line change
@@ -1,205 +1,13 @@
# go-piml

**Spec version**: v1.1.0

`go-piml` is a Go package that provides functionality to marshal and unmarshal data to and from the PIML (Parenthesis Intended Markup Language) format. PIML is a human-readable, indentation-based data serialization format designed for configuration files and simple data structures.

## Features

- **Intuitive Syntax:** Easy-to-read key-value pairs, supporting nested structures.
- **Go-like Tagging:** Uses `piml:"tag"` struct tags for flexible field mapping.
- **Primitive Types:** Supports strings, integers, floats, and booleans.
- **Complex Types:** Handles structs, slices (arrays), and maps.
- **Nil Handling:** Explicitly represents `nil` for pointers, empty slices, and empty maps.
- **Multi-line Strings:** Supports multi-line string values with indentation.
- **Comments:** Allows single-line comments using `#` (only lines starting with `#` are treated as comments).
- **Time Support:** Marshals and unmarshals `time.Time` values using RFC3339Nano format.

## PIML Format Overview

PIML uses a simple key-value structure. Keys are enclosed in parentheses `()` and values follow. Indentation defines nesting.

```piml
(site_name) PIML Demo
(port) 8080
(is_production) false
(version) 1.2

(database)
(host) localhost
(port) 5432

(admins)
> (User)
(id) 1
(name) Alice
> (User)
(id) 2
(name) Bob

(features)
> auth
> logging
> metrics

(description)
This is a sample product description.
It spans multiple lines.

With an empty line in between.

(metadata)
(related_ids) nil
```

## Installation

To use `go-piml` in your Go project, simply run:

```bash
go get github.com/fezcode/go-piml
```

## Usage

### Marshalling Go Structs to PIML
## Go Integration

Define your Go struct with `piml` tags:

```go
package main

import (
"fmt"
time "time"
"github.com/fezcode/go-piml"
)

type User struct {
ID int `piml:"id"`
Name string `piml:"name"`
}

type Config struct {
SiteName string `piml:"site_name"`
Port int `piml:"port"`
IsProduction bool `piml:"is_production"`
Admins []*User `piml:"admins"`
LastUpdated time.Time `piml:"last_updated"`
Description string `piml:"description"`
}

func main() {
cfg := Config{
SiteName: "My Awesome Site",
Port: 8080,
IsProduction: true,
Admins: []*User{
{ID: 1, Name: "Admin One"},
{ID: 2, Name: "Admin Two"},
},
LastUpdated: time.Date(2023, time.November, 10, 15, 30, 0, 0, time.UTC),
Description: "This is a multi-line\ndescription for the site.",
}

pimlData, err := piml.Marshal(cfg)
if err != nil {
fmt.Println("Error marshalling:", err)
return
}
fmt.Println(string(pimlData))
}
```

Output:

```piml
(site_name) My Awesome Site
(port) 8080
(is_production) true
(admins)
> (User)
(id) 1
(name) Admin One
> (User)
(id) 2
(name) Admin Two
(last_updated) 2023-11-10T15:30:00Z
(description)
This is a multi-line
description for the site.
```

### Unmarshalling PIML to Go Structs

```go
package main

import (
"fmt"
time "time"
"github.com/fezcode/go-piml"
)

type User struct {
ID int `piml:"id"`
Name string `piml:"name"`
}

type Config struct {
SiteName string `piml:"site_name"`
Port int `piml:"port"`
IsProduction bool `piml:"is_production"`
Admins []*User `piml:"admins"`
LastUpdated time.Time `piml:"last_updated"`
Description string `piml:"description"`
}

func main() {
pimlData := []byte(`
(site_name) My Awesome Site
(port) 8080
(is_production) true
(admins)
> (User)
(id) 1
(name) Admin One
> (User)
(id) 2
(name) Admin Two
(last_updated) 2023-11-10T15:30:00Z
(description)
This is a multi-line
description for the site.
`)

var cfg Config
err := piml.Unmarshal(pimlData, &cfg)
if err != nil {
fmt.Println("Error unmarshalling:", err)
return
}

fmt.Printf("%+v\n", cfg)
for _, admin := range cfg.Admins {
fmt.Printf("Admin: ID=%d, Name=%s\n", admin.ID, admin.Name)
}
}
```

Output:

```
{SiteName:My Awesome Site Port:8080 IsProduction:true Admins:[0xc0000a4000 0xc0000a4020] LastUpdated:2023-11-10 15:30:00 +0000 UTC Description:This is a multi-line
description for the site.}
Admin: ID=1, Name:Admin One
Admin: ID:2, Name:Admin Two
```

## Contributing

Contributions are welcome! Please open an issue or submit a pull request.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
```
11 changes: 11 additions & 0 deletions public/projects/go-piml/features.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
LABEL: Powerful Logic
SUBTEXT: FEATURES

- **Intuitive Syntax:** Easy-to-read key-value pairs, supporting nested structures.
- **Go-like Tagging:** Uses `piml:"tag"` struct tags for flexible field mapping.
- **Primitive Types:** Supports strings, integers, floats, and booleans.
- **Complex Types:** Handles structs, slices (arrays), and maps.
- **Nil Handling:** Explicitly represents `nil` for pointers, empty slices, and empty maps.
- **Multi-line Strings:** Supports multi-line string values with indentation.
- **Comments:** Allows single-line comments using `#` (only lines starting with `#` are treated as comments).
- **Time Support:** Marshals and unmarshals `time.Time` values using RFC3339Nano format.
8 changes: 8 additions & 0 deletions public/projects/go-piml/installation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
LABEL: Getting Started
SUBTEXT: INSTALLATION

To use `go-piml` in your Go project, simply run:

```bash
go get github.com/fezcode/go-piml
```
60 changes: 60 additions & 0 deletions public/projects/go-piml/overview.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# go-piml

**Spec version**: v1.1.0

`go-piml` is a high-performance, production-ready Go package for marshalling and unmarshalling PIML data. It is designed to feel native to Go developers, leveraging the standard library's idioms and providing a powerful reflection-based API similar to `encoding/json`.

As the PIML specification evolves, `go-piml` serves as the reference implementation for compiled languages, ensuring that performance and type safety are never compromised.

## Core Principles

- **Developer Ergonomics**: Use standard Go struct tags (`piml:"key_name"`) to map your data structures effortlessly.
- **Strict Typing**: Seamlessly convert PIML primitives into Go's rich type system, including support for `time.Time`, custom pointers, and nested slices.
- **Performant Parsing**: The recursive descent parser is optimized for minimal allocations and high throughput.

## Struct Tagging & Mapping

PIML allows for clean separation between your code's data structures and the serialized format:

```go
type Project struct {
ID int `piml:"id"`
Title string `piml:"title"`
Tags []string `piml:"tags"`
Released bool `piml:"is_released"`
Maintenance struct {
Active bool `piml:"active"`
} `piml:"maintenance"`
}
```

## Advanced PIML Example

```piml
(project_registry)
> (Project)
(id) 101
(title) Warp Drive Engine
(tags)
> physics
> propulsion
(is_released) true
(maintenance)
(active) true

(system_metrics)
(uptime) 14500
(load_averages)
> 0.15
> 0.22
> 0.08

(description)
Go implementation allows for deep nesting
of structures without losing the
human-readable quality of the file.
```

## Go Ecosystem Integration

`go-piml` is built to fit into the Go ecosystem. Whether you are building a CLI tool that needs a readable config file, or a microservice that processes structured data, `go-piml` provides the reliability and speed expected of Go software.
7 changes: 7 additions & 0 deletions public/projects/go-piml/see_also.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
LABEL: Related Artifacts
SUBTEXT: SEE ALSO

- [piml](/projects/piml) - The core specification.
- [piml.js](/projects/piml.js) - PIML for the JS ecosystem.
- [PIML Highlighter](/projects/piml-highlighter) - VS Code extension.
- [PIML Lab](/apps/piml-lab) - Interactive playground.
8 changes: 8 additions & 0 deletions public/projects/go-piml/technical.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
LABEL: Architecture
SUBTEXT: High Performance

- **Spec Version**: v1.1.0
- **Serialization**: Efficient reflection-based marshaling/unmarshaling.
- **Reflection**: Uses custom `piml` struct tags for mapping.
- **Concurrency**: Thread-safe operations for high-load environments.
- **Standards**: Native support for `time.Time` and RFC3339Nano.
21 changes: 21 additions & 0 deletions public/projects/go-piml/usage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
LABEL: Practical Implementation
SUBTEXT: USAGE

### Marshalling Go Structs to PIML

```go
cfg := Config{
SiteName: "My Awesome Site",
Port: 8080,
IsProduction: true,
}

pimlData, err := piml.Marshal(cfg)
```

### Unmarshalling PIML to Go Structs

```go
var cfg Config
err := piml.Unmarshal(pimlData, &cfg)
```
Loading