golang-relative path problem

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

Clarify the meaning of a few parameters in the Golang before the understanding of the error, causing yourself to write the path of some problems have been confused for a long time hereby record

Os. ARGS[0] This parameter is not what the project execution path gets is the first sentence of the command-line execution statement with a space-delimited delimiter that has no relation to the project execution path---it's a shame to understand wrong.

Os. GETWD () Gets the path where you are currently running

For example, in the/etc directory to run the/usr/main file eventually obtained by the GETWD value is/etc
The relative path in Golang is relative to this execution path.

That explains my go run and Idea startup, and the reason why the supervisor startup is not always found because the execution path is not necessarily the same.

So the general thing I do now is if go run directly into the directory underground go Run

If idea and supervisor are started, add a more project path parameter to the command line

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.