refactor(router): replace temporary variable pointer pattern with new() builtin
Simplify page number and chapter number pointer creation in reader route registration by using inline new() instead of local variable + address-of.
This commit is contained in:
1 parent
8ac6e1ac79
commit
9b141d75e8
1 file changed
+2
-4
@@ -123,14 +123,12 @@ func registerReaderRoutes(cfg *Config) {
|
|||||||
|
|
||||||
var pageNumber *int
|
var pageNumber *int
|
||||||
if b.PageNumber.Valid {
|
if b.PageNumber.Valid {
|
||||||
pn := int(b.PageNumber.Int32)
|
pageNumber = new(int(b.PageNumber.Int32))
|
||||||
pageNumber = &pn
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var chapterNumber *int
|
var chapterNumber *int
|
||||||
if b.ChapterNumber.Valid {
|
if b.ChapterNumber.Valid {
|
||||||
cn := int(b.ChapterNumber.Int32)
|
chapterNumber = new(int(b.ChapterNumber.Int32))
|
||||||
chapterNumber = &cn
|
|
||||||
}
|
}
|
||||||
|
|
||||||
templateBookmarks[i] = templates.Bookmark{
|
templateBookmarks[i] = templates.Bookmark{
|
||||||
|
|||||||
Reference in new issue
Block a user