Golang Concurrency: Ignoring request from channel

In summary, the conversation is about the speaker's attempt to learn the programming language Golang. They mention wanting to ignore a request to get a result from a channel and provide a link to their code. They also mention a side question about their gold status. In the end, they found a solution but still wonder if there is a way to do what they were originally asking for.
  • #1

TheDemx27

Gold Member
169
13
I'm going back to basics again in an attempt to add golang to my list of "pretty well learned" languages. What I need to do should have a pretty simple solution: I want to ignore a request to get a result from a channel in golang, if you need to know the particular situation I have a link to my code here, where I want to "ignore" floatchan2 in main().

Now I know that it will print out every other ratio when working so you don't need to point that out. :P

Edit: Also, as a side question, why do I still have gold status? I thought my six months expired in November 2014.
 
Technology news on Phys.org
  • #2
Well, I found a solution that works around it and is less confusing than the original code, so I guess I don't need anyone's help now. Still there should be a way to do what I was asking in the OP, and if someone would find it for me I would be grateful.
 

1. What is Golang concurrency?

Golang concurrency refers to the ability of the Go programming language to handle multiple tasks simultaneously. This is achieved through the use of goroutines, which are lightweight threads that can run concurrently with other goroutines.

2. What is a channel in Golang?

A channel in Golang is a communication mechanism that allows goroutines to send and receive values to and from each other. It is used to synchronize concurrent operations and ensure safe communication between goroutines.

3. What does it mean to ignore a request from a channel in Golang?

Ignoring a request from a channel means that a goroutine is not actively listening for any values sent through that channel. This can happen when a goroutine has exited or when a select statement does not have a case for that particular channel.

4. Why would a request from a channel be ignored in Golang?

A request from a channel may be ignored in Golang for a few reasons. One possible reason is that the goroutine that was supposed to receive the value has already exited. Another reason could be that the select statement does not have a case for that particular channel, causing the request to be ignored.

5. How can I prevent requests from being ignored in Golang?

To prevent requests from being ignored in Golang, make sure that the goroutine that is supposed to receive the value is still running and actively listening for values on the channel. Also, ensure that the select statement has a case for the channel that is being used to send the value.

Suggested for: Golang Concurrency: Ignoring request from channel

Back
Top