Resources - craterdog/go-component-framework GitHub Wiki

Overview

A resource is a primitive element that represents a uniform resource identifier (aka URI). Each resource has the following string format:

$resource: '<' SCHEME ':' ("//" AUTHORITY)? '/' PATH ('?' QUERY)? ('#' FRAGMENT)? '>'

The source of this format is Bali Document Notation™ (Bali) defined here.

UML Diagram

A Quick Example

To whet your appetite, here is some short example code that demonstrates the use of resources.

package main

import (
	fmt "fmt"
	fra "github.com/craterdog/go-component-framework/v7"
)

func main() {
	// Create some new resources using the module level constructor shortcuts.
	var email = fra.Resource("<mailto:[email protected]>")
	fmt.Println("Resource:", email)
	var craterdog = fra.Resource("<https://craterdog.com/About.html?sourceId=123#History>")
	fmt.Println("Resource:", craterdog)

	// Retrieve the parts.
	fmt.Println("Scheme:", craterdog.GetScheme())
	fmt.Println("Authority:", craterdog.GetAuthority())
	fmt.Println("Path:", craterdog.GetPath())
	fmt.Println("Query:", craterdog.GetQuery())
	fmt.Println("Fragment:", craterdog.GetFragment())
}

Try it out in the Go Playground...