Categorygithub.com/diagram-code-generator/resources

# README

resources

GitHub tag Code coverage Go Report Card GoDoc

Made with Golang Using Diagrams

BuyMeACoffee

Overview

The resources repository is a collection designed to define a structure for resources in a system, providing interfaces, generic implementations, and helper methods for resource and resource collection management. It gives you different ways to handle resources and collections, with handy shortcuts for managing relationships and spotting differences between sets.

How to Use

$ go get github.com/diagram-code-generator/resources@latest

Core Components

Resource Interface

The Resource interface defines the basic contract for a resource in the system. Any resource must implement this interface to be considered valid within the context of this framework.

GenericResource Generic Implementation

GenericResource is a generic implementation that can be extended to create specific resources. It provides a basic implementation of common methods required for resource manipulation.

ResourceCollection

ResourceCollection is a structure for storing and managing collections of resources. It offers methods for adding, removing, and manipulating resources within the collection.

Example Usage

package main

import (
	"fmt"

	"github.com/diagram-code-generator/resources/pkg/resources"
)

func main() {
	// Create some resources
	resource1 := resources.NewGenericResource("1", "Value 1", "Type A")
	resource2 := resources.NewGenericResource("2", "Value 2", "Type B")
	resource3 := resources.NewGenericResource("3", "Value 3", "Type A")

	// Create a resource collection
	collection1 := resources.NewResourceCollection()

	// Add resources to the collection
	collection1.AddResource(resource1)
	collection1.AddResource(resource2)
	collection1.AddResource(resource3)

	// Establish relationships between resources
	collection1.AddRelationship(resource1, resource2)
	collection1.AddRelationship(resource2, resource3)

	// Print information about the resources and relationships
	fmt.Println("Resources:")
	for _, resource := range collection1.Resources {
		fmt.Printf("ID: %s, Value: %s, Type: %s\n", resource.ID(), resource.Value(), resource.ResourceType())
	}

	fmt.Println("\nRelationships:")
	for _, relationship := range collection1.Relationships {
		fmt.Printf("Source: %s, Target: %s\n", relationship.Source.ID(), relationship.Target.ID())
	}

    // Create a resource collection
	collection2 := resources.NewResourceCollection()

    // Print differences between the collections
	availableTypes := []resources.ResourceType{"Type A", "Type B"}
	resources.PrintDiff(collection1, collection2, availableTypes)
}

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to create an issue or submit a pull request. Your contribution is much appreciated. See Contributing.

open - Contributing

License

This project is licensed under the MIT License.

# Packages

No description provided by the author