Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8540149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:31:57+00:00 2026-06-11T11:31:57+00:00

I have a default cause in a select statement that I want to do

  • 0

I have a default cause in a select statement that I want to do nothing, just continue, but leaving the line blank stops anything in the statement from happening

        select {
        case quit_status := <-quit:
            if quit_status == true {
                fmt.Printf("********************* GOROUTINE [%d] Received QUIT MSG\n", id)
                return
            }
        default:
            fmt.Printf("GOROUTINE [%d] step: %d, NO QUIT MSG\n", id, i)
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:31:58+00:00Added an answer on June 11, 2026 at 11:31 am

    The default case in a select statement is intended to provide non-blocking I/O for channel reads and writes. The code in the default case is executed whenever none of the channels in any of the cases are ready to be read/written to.

    So in your case, the default block is executed if the quit channel has nothing to say.
    You can simply remove the default case and it will block on the quit_status := <-quit case until a value is available in quit.. which is probably what you are after in this instance.

    If you want to immediately continue executing code after the select statement, you should run this select statement in a separate goroutine:

    go func() {
        select {
        case quit_status := <-quit:
            ...
    
        }
    }()
    
    // Execution continues here immediately.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a select statement that is used in a gridview via a stored
What I want to achieve is really simple. I have a Select statement where
I want to be able to have default text like Enter content here... appear
here's a tricky question... I have default styled input fields (no css added, just
I have some default values for testing my code, but for security reasons those
I have a default ListView that i have added my custom views for the
I have a little app that have by default youtube as homepage. You can
I have an application that has been running fine for quite awhile, but recently
I have a select statement which generates a Type and quantity: I normally have
I am writing some code in VB.NET that uses a switch statement but in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.