I am trying to upload files to cloud storage from my local build of go app. Issue is that I am always getting this error: ```panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x18e71e1]
cloud.google.com/go/storage.(*Writer).open.func1(0xc000146480, 0xc00000c1e0, 0xc000206010, 0xc000512070, 0x1, 0x1)
/Users/adamlukacka/go/pkg/mod/cloud.google.com/go/[email protected]/writer.go:128 +0xe1
created by cloud.google.com/go/storage.(*Writer).open
/Users/adamlukacka/go/pkg/mod/cloud.google.com/go/[email protected]/writer.go:118 +0x412
exit status 2
This is my code:
bucket := "my-unique-bucket-name"
object := i.Name
ctx := context.Background()
fmt.Println("ctx", ctx)
client, err := storage.NewClient(ctx)
if client == nil {
fmt.Println("client is nil")
}
When I try to get new client it returns nil.
This implementation works fine on production but I can not work it out what am I doing wrong locally.
I can upload images from terminal and I have my project set to default. All settings seems OK but it does not work. I tried to clone my project on another Mac and I saw same issue.
question from:
https://stackoverflow.com/questions/65874001/can-not-upload-any-file-to-google-cloud-storage 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…