english_bible

package module
v0.0.0-...-8fa6e93 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: MIT Imports: 8 Imported by: 1

README

English Bible

This package provides a simple Go-based tool for looking up passages of scripture. It presently uses the King James Version, otherwise known as the Authorized Version, and includes books often referred to as deuterocanonical or apocryphal. The books names are expected to follow the Orthodox and Catholic naming conventions. For instance, a Protestant reference to 1 Samuel will need to be 1 Kings and 1 Kings will need to be 3 Kings.

    if bibledb, e = sql.Open("sqlite3", "english.db"); e != nil {
        log.Printf("Got error opening database: %#v. Exiting.", e)
        os.Exit(1)
    }
    defer bibledb.Close()

    bible := english_bible.NewBible(bibledb)
  
    passage := bible.Lookup("Matt 1.1-25")
    
    // passage is a list of verses
    // Each verse has Chapter, Verse, Book, and Content attributes
    for _, verse := range passage) {
        fmt.Printf("%d. %s\n", verse.Verse, verse.Content)
    }

A reference includes a book name and a verse specification. A specification can include multiple verse ranges separated by commas, where a range is a collection of 1 or more contiguous verses. Chapter specification can be implicit. A reference can look like any of the following:

  • Matt 1.1-25
  • Matt 4.25-5.13
  • Matt 10.32-36, 11.1
  • Matt 6.31-34, 7.9-11
  • Matt 10.1, 5-8
  • Mark 15.22, 25, 33-41
  • 1 John 2.7-17
  • Jude 1-10
  • 1 Cor 5.6-8; Gal 3.13-14
  • Prov 10, 3, 8
  • Matt 26:2-20; John 13:3-17; Matt 26:21-39; Luke 22:43-45; Matt 26:40-27:2
  • Baruch 3.35-4.4
  • Wis 3.1-9

Warning: this function directly interpolates values from the reference into SQL. This is safe as long as the provided reference is coming from the database. In other words, this method might be unsafe when used to lookup user-provided references.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BookNames = map[string]string{}/* 150 elements not displayed */
View Source
var (
	ReferenceParseError = errors.New("Error parsing scripture reference")
)

Functions

func NormalizeBookName

func NormalizeBookName(name string) string

Types

type Bible

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

func NewBible

func NewBible(db *sql.DB) *Bible

func (*Bible) Lookup

func (self *Bible) Lookup(reference string) orthocal.Passage

Parse a scripture reference and return the scripture passage. A reference includes a book name and a verse specification. A specification can include multiple verse ranges separated by commas, where a range is a collection of 1 or more contiguous verses. Chapter specification can be implicit. A reference can look like any of the following:

Matt 1.1-25 Matt 4.25-5.13 Matt 10.32-36, 11.1 Matt 6.31-34, 7.9-11 Matt 10.1, 5-8 Mark 15.22, 25, 33-41 1 John 2.7-17 Jude 1-10 1 Cor 5.6-8; Gal 3.13-14 Prov 10, 3, 8

NOTE: this function directly interpolates values from the reference into SQL. This is safe as long as the provided reference is coming from the database. In other words, this method might be unsafe when used to lookup user-provided references.

func (*Bible) LookupWithContext

func (self *Bible) LookupWithContext(ctx context.Context, reference string) orthocal.Passage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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