c4

package module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2016 License: MIT Imports: 0 Imported by: 0

README

C4 - The Cinema Content Creation Cloud

Go package and cli for c4. GoDoc

Command line tool

See c4 command line tool

Go Package

Example usage to generate an c4 ID for a file.

package main

import (
  "fmt"
  "io"
  "os"

  // import 'asset' asset identification
  "github.com/etcenter/c4/asset"
)

func main() {
  file := "main.go"
  f, err := os.Open(file)
  if err != nil {
    panic(err)
  }
  defer f.Close()

  // create a ID encoder.
  e := asset.NewIDEncoder()
  // the encoder is an io.Writer
  _, err = io.Copy(e, f)
  if err != nil {
    panic(err)
  }
  // ID will return an *asset.ID.
  // Be sure to be done writing bytes before calling ID()
  id := e.ID()
  // use the *asset.ID String method to get the c4id string
  fmt.Printf("C4id of \"%s\": %s\n", file, id.String())
  return
}

Output:

>go run main.go 
C4id of "main.go": c44jVTEz8y7wCiJcXvsX66BHhZEUdmtf7TNcZPy1jdM6S14qqrzsiLyoZRSvRGcAMLnKn4zVBvAFimNg14NFKp46cC
Releases

Current release: v0.6.0

Check the release branch for the latest release, or tags to find a specific release. The master branch holds currently development.

License

This software is released under the MIT license. See LICENSE for more information.

Documentation

Overview

Package c4 contains Go implementations for core C4 concepts.

Creating IDs

To create a C4 ID, use the IDEncoder type as a hash writer.

e := c4.NewIDEncoder()
io.Copy(e, src)
id := e.ID()

Parsing IDs

To parse an ID from a string, use the ParseID function.

c4.ParseID(src)

Directories

Path Synopsis
Package asset contains Go implementations C4 asset identification.
Package asset contains Go implementations C4 asset identification.
cmd
c4

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL