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

Checking if variable is less than negative integer fails to compile #39325

Closed
Keithcat1 opened this issue May 30, 2020 · 3 comments
Closed

Checking if variable is less than negative integer fails to compile #39325

Keithcat1 opened this issue May 30, 2020 · 3 comments

Comments

@Keithcat1
Copy link

The following won't compile:
package main
i mport(

)
func main() {
x:=-500
println(x< -100)
}

However, if you add a space, it works:
package main
import(

)
func main() {
x:=-500
println(x< -100)
}
I'm getting the following compile error:
.\q.go:7:11: syntax error: unexpected <-, expecting comma or )

@mvdan
Copy link
Member

mvdan commented May 30, 2020

In Go, <- is an operator. See https://golang.org/ref/spec#Operators_and_punctuation. See https://golang.org/wiki/Questions for questions in the future.

@mvdan mvdan closed this as completed May 30, 2020
@Keithcat1
Copy link
Author

Can it be implemented for ints then so it acts normally?

@mvdan
Copy link
Member

mvdan commented May 30, 2020

<- is an opeartor for channels, not integers: https://golang.org/ref/spec#Channel_types

@golang golang locked and limited conversation to collaborators May 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants