golang The system cannot find the file specified

Posted 杰哥的技术杂货铺

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了golang The system cannot find the file specified相关的知识,希望对你有一定的参考价值。

使用io/ioutil包读取文件时报错:open abi: The system cannot find the file specified.

原因是:ioutil.ReadFile()这个方法需要传入决绝路径的文件名

代码:

abiStr, err := ioutil.ReadFile("abi")
	if err != nil 
		return "", fmt.Errorf("ioutil.ReadFile abi err:%v", err.Error())
	

ioutil.ReadFile(“abi”)

我之前认为需要读取的abi文件,与代码文件在同一层目录,所以为绝对路径即可。但是经过证实,此处需要写绝对路径,即:

abiStr, err := ioutil.ReadFile("router/nft/erc1155/abi")
	if err != nil 
		return "", fmt.Errorf("ioutil.ReadFile abi err:%v", err.Error())
	

以上是关于golang The system cannot find the file specified的主要内容,如果未能解决你的问题,请参考以下文章

用FTP上传文件时出现The system cannot find the file specified怎么回事?.

RTSP协议视频结构化平台EasyNVR调用串口接口报错The system cannot find the file specified

cx_Freeze: 'The system cannot find the file specified' during build [win10] [PyQt4] [python2.7] 错误

Atom打开报错:"Cannot load the system dictionary for zh-CN"

Cannot initiate the connection to ports.ubuntu.com:80

Cannot find the system java compiler. Check that your class path includes tools.jar报错处理