yann0917 / dedao-dl

得到 APP 课程下载工具,可在终端查看文章内容,可生成 PDF,音频文件,markdown 文稿,可下载电子书。
MIT License
607 stars 120 forks source link

go的语法错误,int型转float型时发生错误。 #208

Closed shunlibest closed 9 months ago

shunlibest commented 9 months ago

貌似是go的语法错误,int型转float型时发生错误。我对go语言不了解。

错误位置 cmd/app/article.go 第20行

count := info["publish_num"].(float64)

修改方式 使用float64包裹的方式进行类型转换。(PS:搞不懂,为什么页码要用float类型)

count := float64(info["publish_num"].(int))

错误日志

panic: interface conversion: interface {} is int, not float64

goroutine 1 [running]:
github.com/yann0917/dedao-dl/cmd/app.ArticleList(0x14000232a20?, {0x0, 0x0})
        /Users/shunlihan/Documents/temp/dedao-dl/cmd/app/article.go:20 +0x300
github.com/yann0917/dedao-dl/cmd.articleList(0x0?)
        /Users/shunlihan/Documents/temp/dedao-dl/cmd/article.go:44 +0x2c
github.com/yann0917/dedao-dl/cmd.glob..func1(0x14000239600?, {0x140002ac0a0?, 0x4?, 0x10076fcd5?})
        /Users/shunlihan/Documents/temp/dedao-dl/cmd/article.go:24 +0x38
github.com/spf13/cobra.(*Command).execute(0x100fe9be0, {0x140002ac060, 0x2, 0x2})
        /Users/shunlihan/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0x82c
github.com/spf13/cobra.(*Command).ExecuteC(0x100fe9900)
        /Users/shunlihan/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/shunlihan/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/yann0917/dedao-dl/cmd.Execute(...)
        /Users/shunlihan/Documents/temp/dedao-dl/cmd/root.go:30
main.main()
        /Users/shunlihan/Documents/temp/dedao-dl/main.go:17 +0x28

版本信息

shunlibest commented 9 months ago

貌似又没问题了,有点懵