Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stat : no such file or directory. I don't konw the reason #2141

Open
yangyile1990 opened this issue Mar 20, 2024 · 4 comments
Open

stat : no such file or directory. I don't konw the reason #2141

yangyile1990 opened this issue Mar 20, 2024 · 4 comments

Comments

@yangyile1990
Copy link

package main

import (
	"github.com/btcsuite/btcd/rpcclient"
)

func main() {
	cfg := &rpcclient.ConnConfig{
		Host:         "go.getblock.io/0371879beb44418680721ddd4cd53f81", // 第三方 DOGE币节点的RPC地址
		User:         "",                                                // 留空或设置为一个空字符串
		Pass:         "",                                                // 留空或设置为一个空字符串
		DisableTLS:   true,                                              // DOGE币节点默认不使用TLS
		HTTPPostMode: true,                                              // DOGE币节点只支持HTTP POST模式
	}
	client, err := rpcclient.New(cfg, nil)
	if err != nil {
		panic(err)
	}

	err = client.Ping()
	if err != nil {
		panic(err)
	}
}

panic: stat : no such file or directory. why?

@guggero
Copy link
Collaborator

guggero commented Mar 20, 2024

A panic gives you a stack trace that tells you exactly where something panics and why. Without that information, we cannot help you.

@cl1ckname
Copy link

I've encountered this error when I specified an incorrect host path (such as /wallet/:walletName, where walletName does not exist) when connecting to a bitcoind node. rpcclient simply proxies this error from the node. Check the connection host

@yemmyharry
Copy link

Since you're using panic, the runtime should print the file and line number where the panic originated. The error message you showed doesn't explicitly indicate the source of error. You can as well use the log.Fatalf function to print the stack trace along with the panic error message.

@pustovalov
Copy link

Hi,

Not all providers require authentication through a password or a cookie. Given the following configuration:

cfg := &rpcclient.ConnConfig{
  Host:         "go.getblock.io/0371879beb44418680721ddd4cd53f81",
  User:         "",
  Pass:         "",
  DisableTLS:   true,
  HTTPPostMode: true,
}

func (config *ConnConfig) getAuth() (username, passphrase string, err error) {
// Try username+passphrase auth first.
if config.Pass != "" {
return config.User, config.Pass, nil
}
// If no username or passphrase is set, try cookie auth.
return config.retrieveCookie()
}

getAuth() will call config.retrieveCookie() and because there's no config.CookiePath there will be an error

st, err := os.Stat(config.CookiePath)
fmt.Println("err111", err)
err111 stat : no such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants