docindex

package module
v0.0.0-...-0279813 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2014 License: BSD-3-Clause Imports: 9 Imported by: 0

README

docindex

Package docindex fetches, parses, and lists text documents (with JSON metadata at the top of each file) in a directory tree.

Documentation on Sourcegraph

Build Status status authors top func funcs Total views

Installation

go get github.com/sourcegraph/docindex

Contributors

Contributions are welcome! Submit a pull request on GitHub.

Documentation

Overview

Package docindex fetches and lists text documents (with metadata "front matter" at the top of each file) in a directory tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

Types

type Index

type Index struct {
	// contains filtered or unexported fields
}

Index represents a directory containing text documents with metadata.

func Open

func Open(dir string, metadataType interface{}) (*Index, error)

Open reads all documents in dir and its subdirectories. Metadata JSON is decoded into structs whose type is pointer-to-metadataType.

If dir is not an existing directory, an error satisfying os.IsNotExist is returned.

func (*Index) AllMetadata

func (idx *Index) AllMetadata(metaMap interface{})

AllMetadata stores the metadata for each document in meta, which should be a map with string keys and values whose type is pointer-to-metadataType.

func (*Index) Doc

func (idx *Index) Doc(filename string, meta interface{}) ([]byte, error)

Doc returns the data in the document named by filename. If meta is a pointer a struct of the metadataType used in Open, the document metadata is written to that struct.

func (*Index) Filenames

func (idx *Index) Filenames() []string

Filenames returns a list of document filenames that were loaded in the last call to Open or Reload.

func (*Index) Reload

func (idx *Index) Reload() error

Reload refreshes the list of documents in the index.

Jump to

Keyboard shortcuts

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