Goland Cannot convert expression of type string to type []byte

Viewed 2178

I am using Goland for golang code and the convert check seems working with a bug while I transfer a "string" type to a "[]byte" type.

It can be complied correctly with a expecting result, but the tip still shows in the editor. Maybe there is something wrong in my setting? Anyone can help me?

package main

import (
  "crypto/sha1"
  "encoding/hex"
  "fmt"
)

func Sha1(data string) string {
  encrypts := sha1.New()
  encrypts.Write([]byte(data)) // Cannot convert expression of type string to type []byte
  return hex.EncodeToString(encrypts.Sum([]byte("")))
}

func main() {
  fmt.Println(Sha1("123456"))
}

Here is my Goland editor screenshot

1 Answers

I posted an issue on Jetbrains track, and got replied. Only to find that my GoLand inspector works well if I pasted the same code in a brand new project. So maybe there is something wrong in my "old" project, and I will post more information if I find what's wrong in my "odd" project.

Related