last-chap.go (449B)
1 package fetch 2 3 import ( 4 q "git.hanabi.in/gitbox/quran-go/src/quran-com" 5 t "git.hanabi.in/gitbox/quran-go/src/types" 6 ) 7 8 // Fetch the ID of the last chapter in Qur'an. 9 func LastChapter() (res t.Chap, err error) { 10 11 var chapterList t.ChaptersList 12 uri := q.API + "/chapters" 13 14 err = q.HttpGet(uri, &chapterList) 15 if err != nil { 16 return res, err 17 } 18 19 chapters := chapterList.Chapters 20 res = t.Chap(chapters[len(chapters)-1].ID) 21 22 return res, err 23 24 }