Read Surah
To read a Surah, you can use the ReadSurah method:
package main
import (
"fmt"
"log"
"github.com/Omar-Belghaouti/miracle"
"github.com/Omar-Belghaouti/miracle/suar"
)
func main() {
// initialize the Quran struct and set the language to English
quran := miracle.Book()
quran.SetLanguage("en")
// read the Surah Al-Fatiha
surah, err := quran.ReadSurah(suar.AL_FATIHA)
if err != nil {
log.Fatal(err.Error())
}
fmt.Println(surah.Name)
for k, v := range surah.Verse {
fmt.Printf("%s: %s\n", k, v)
}
}
The surah is returned as a *miracle.Surah struct.
The Surah.Verse map contains the verses of the surah. The keys are the verse numbers and the values are the verse text.
The parameter of the ReadSurah method is the surah number which must be between 1 and 114. For that there is a suar package that provides the surah numbers.
Surah struct
type Surah struct {
Index string `json:"index"`
Name string `json:"name"`
Verse map[string]string `json:"verse"`
Count uint `json:"count"`
Juz []JuzInSurah `json:"juz"`
}
type JuzInSurah struct {
Index string `json:"index"`
Verse `json:"verse"`
}
type Verse struct {
Start string `json:"start"`
End string `json:"end"`
}