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 9153939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:21:12+00:00 2026-06-17T12:21:12+00:00

Go compiler complain about unused variable and imports. So go scripts can’t be run

  • 0

Go compiler complain about unused variable and imports. So go scripts can’t be run within gwan if any unused var/script is detected.

gwan provide a 404 error in this case if running … or simply can’t be start

There is a way to avoid this behavior?

  • 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-17T12:21:13+00:00Added an answer on June 17, 2026 at 12:21 pm

    No really easy way exists. There’s nothing like a compiler flag to turn this behavior off. I guess it’s just better to pass around code which the compiler can swallow in the first place.

    EDIT: C/P from the FAQ: Can I stop these complaints about my unused variable/import?

    The presence of an unused variable may indicate a bug, while unused imports just slow down compilation. Accumulate enough unused imports in your code tree and things can get very slow. For these reasons, Go allows neither.

    When developing code, it’s common to create these situations temporarily and it can be annoying to have to edit them out before the program will compile.

    Some have asked for a compiler option to turn those checks off or at least reduce them to warnings. Such an option has not been added, though, because compiler options should not affect the semantics of the language and because the Go compiler does not report warnings, only errors that prevent compilation.

    There are two reasons for having no warnings. First, if it’s worth complaining about, it’s worth fixing in the code. (And if it’s not worth fixing, it’s not worth mentioning.) Second, having the compiler generate warnings encourages the implementation to warn about weak cases that can make compilation noisy, masking real errors that should be fixed.

    It’s easy to address the situation, though. Use the blank identifier to let unused things persist while you’re developing.

    import "unused"
    
    // This declaration marks the import as used by referencing an
    // item from the package.
    var _ = unused.Item  // TODO: Delete before committing!
    
    func main() {
            debugData := debug.Profile()
            _ = debugData // Used only during debugging.
            ....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In other words, why does the compiler complain about things like this: class Integer
Why does the compiler (g++) complain about this line of code? XalanNode *docElement =
I wrote the following java code, and i expected the compiler would complain about
in this code, compiler complain about undefined MyClassB , which is understandable : class
The C# 4.0 compiler does not complain about this (not even a warning): if(10.0
Is there a way to tell the Java compiler to not complain about a
The compiler complains about this, after I activated all kind of warnings: For MyApp_Prefix.pch
The compiler complains about this code: HashMap<String,int> userName2ind = new HashMap<String,int>(); for (int i=0;
g++ compiler complains about conversions between related types (from int to enum, from void*
Why does the C# compiler not even complain with a warning on this code?

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.