golang使用iconv報undefined:XXX的問題處理方案
golang使用iconv報錯問題處理

在使用github.com/qiniu/iconv做字符集轉換時
會報錯:undefined
通過查詢文檔,猜測應該是windows環(huán)境沒有安裝libiconv
報錯信息
如下:
PS D:\gosrc\dbutiils> go run .\main.go
# github.com/qiniu/iconv
D:\gopath\pkg\mod\github.com\qiniu\iconv@v1.2.0\reader.go:11:11: undefined: Iconv
D:\gopath\pkg\mod\github.com\qiniu\iconv@v1.2.0\reader.go:19:19: undefined: Iconv
D:\gopath\pkg\mod\github.com\qiniu\iconv@v1.2.0\reader.go:21:13: undefined: DefaultBufSize
D:\gopath\pkg\mod\github.com\qiniu\iconv@v1.2.0\reader.go:49:14: undefined: EILSEQ
D:\gopath\pkg\mod\github.com\qiniu\iconv@v1.2.0\writer.go:12:11: undefined: Iconv
D:\gopath\pkg\mod\github.com\qiniu\iconv@v1.2.0\writer.go:19:19: undefined: Iconv
D:\gopath\pkg\mod\github.com\qiniu\iconv@v1.2.0\writer.go:21:13: undefined: DefaultBufSize
D:\gopath\pkg\mod\github.com\qiniu\iconv@v1.2.0\writer.go:70:15: undefined: EILSEQ
D:\gopath\pkg\mod\github.com\qiniu\iconv@v1.2.0\writer.go:102:15: undefined: EILSEQ
可以從如下網站下載:LibIconv for Windows (sourceforge.net)
選擇安裝包版本的:

安裝完成后,修改環(huán)境變量。
我的軟件安裝在D盤,環(huán)境變量設置為D:/Program Files (x86)/GnuWin32/bin,即軟件的可執(zhí)行文件所在的文件夾路徑。
總結
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Go語言如何在Web服務中實現(xiàn)優(yōu)雅關機
在這篇文章中,我們將通過一個簡單的例子來演示如何在 Go 語言中使用 Gin 框架實現(xiàn)優(yōu)雅關機,感興趣的小伙伴可以跟隨小編一起學習一下2024-11-11
golang框架gin的日志處理和zap lumberjack日志使用方式
這篇文章主要介紹了golang框架gin的日志處理和zap lumberjack日志使用方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-01-01

