-1

I got accused of not knowing how to ask a question:

926 rep and you can still not ask a question?

and got hit with several downvotes.

But I'm not getting any feedback after asking for it, so I would really like to know: what is the problem with my question?

1
  • 8
    I see two unrelated questions there. I also don't see your efforts (i.e. what you tried and what didn't work) - in short not much of the how to ask a good question guide.
    – Oded
    Oct 4, 2014 at 15:35

2 Answers 2

13

How do I embed a channel in a struct in go?

Okay, are you looking for the syntax struct { x chan int }? Are you looking for exact semantics? Other syntax? Something else? No idea.

Why the inconsistency between the map syntax:

 var m map[string]int

and channel,

 var m chan int

How is this relevant to embedding channels in structs? What do maps have to do with this? This in particular raises confusion.

Are these two different questions? How are they related?

10
  • 2
    I am asking about how to embed a channel in a go struct. Its really that simple. And no, struct {x chan int} is not embedding, you can see my comments to one of the answers to my question. And if you understand what embedding is it should be obvious why the chan int` syntax, which specifies a channel of ints type, is directly related to the question.
    – user1941755
    Oct 4, 2014 at 16:10
  • 3
    It's related to the question but it's a different question. What are you actually trying to do though? Extend channels? Oct 4, 2014 at 16:15
  • 1
    @BenjaminGruenbaum I think erjoalgo expressed what he was hoping to do in the comment of this answer: stackoverflow.com/a/26194639/6309
    – VonC
    Oct 4, 2014 at 16:21
  • 2
    @VonC Which is also indicates that the question indeed is unclear.
    – BartoszKP
    Oct 5, 2014 at 13:00
  • 1
    @BartoszKP Could you please tell me what part of my question is unclear?
    – user1941755
    Oct 6, 2014 at 4:00
  • @erjoalgo No, I can't, nor do I have to. The fact that even the author of the only answer perceives your comment as useful in terms of understanding the question is just another indication that the question would be better if it would include this information.
    – BartoszKP
    Oct 6, 2014 at 9:10
  • 1
    Of course you can't, because my question is perfectly clear. Whether I feel like expressing my intent or not is irrelevant to whether the question has a clear spec and has an objective answer. What the accepted answer's author is pointing out is where I've expressed my intent, in response to a question of "What are you actually trying to do though?". But you don't actually need any of this information to answer the question objectively, indeed as the answer's author did way before I mentioned anything about my intent.
    – user1941755
    Oct 6, 2014 at 13:17
  • 1
    @erjoalgo If you know for sure that your question is perfectly clear (which involves the ability to look into other peoples' minds...), why have you even bothered to create this meta discussion? I'll just stop here, cheers.
    – BartoszKP
    Oct 6, 2014 at 15:05
  • 1
    I asked here but despite my question being perfectly clear, I received downvotes, votes to close, and was told I didn't know how to ask a question (by a user who later removed his comment). So I wanted to hear from those people as to why they thought the question was bad. Since you're one of them, I'd still like you to explain why you think the question is bad/unclear.
    – user1941755
    Oct 6, 2014 at 15:12
  • 1
    How the syntax of maps is even remotely relevant to embedding channels is still a mystery to me.
    – user1804599
    Oct 6, 2014 at 15:14
10

Let's break down your question (as originally asked, since you posted on meta when the original version was live).

How do I embed a channel in a struct in go? Why the inconsistency between the map syntax:

var m map[string]int

and channel,

var m chan int

First, as has been pointed out, this is two questions, not one. Yes, I know StackOverflow imposes a character limit that you view as "arbitrary". Like most restrictions on the site, it exists for a reason. In this case, because very very few quality questions can be asked in so few characters.

But let's assume you'd been able to post what you had wanted to:

How do I embed a channel in a struct in go?

This is not a good question. It is on-topic, and perfectly clear what you want to do, but it shows exactly zero effort on your part before asking - and you don't have to be an expert in Go to figure that out. Given that you have several other questions in the Go tag which could have been answered by just looking up the syntax, this is a poor trend. Not showing effort is guaranteed to earn you downvotes.

So, what could you have done to demonstrate that you had put in effort? Assuming the question isn't actually about syntax (because you should be able to answer syntax questions with your own research), then you would have tried the obvious syntax and found that it failed in some way. (I'm not familiar with Go, so the below is my best attempt at getting the idea across.)

How do I embed a channel in a struct in go? I tried the obvious way:

   type MyType struct {
       *Channel
   }

But when I do this I get an error:

   func (x chan int) m2() {}
   invalid receiver type chan int (chan int is an unnamed type)

This is a question which is on-topic, answerable, and shows that you've put in some effort. Had you posted this originally, you would not have received so many downvotes and you could have moved on, happy with VonC's excellent answer.

You must log in to answer this question.