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

@Keithcat1 Keithcat1 commented May 30, 2020

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 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 May 30, 2020
@Keithcat1
Copy link
Author

@Keithcat1 Keithcat1 commented May 30, 2020

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

@mvdan
Copy link
Member

@mvdan mvdan commented May 30, 2020

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

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.