Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Golang Illegal rune literal error when splitting string

I am trying to split string based on split function in golang. But getting illegal rune literal error for r == ‘/–/’ && r == ‘/-iN-/’ && r == ‘/–/’

func Split(r rune) bool {
    return r == '/--/' && r == '/-iN-/' && r == '/--/'
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

In Go, you can use single quotes for literal values that consist of a single character.

If you want to write a string literal, you should use double quotes or backticks :

'/'      // <- a single character
"/--/"   // <- a string
`/--/`   // <- also a string

You would also have to change your Split function because a rune cannot be compared to a string.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading