Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: os: UserPublicDir #60063

Closed
ghost opened this issue May 9, 2023 · 4 comments
Closed

proposal: os: UserPublicDir #60063

ghost opened this issue May 9, 2023 · 4 comments
Labels
Proposal WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@ghost
Copy link

ghost commented May 9, 2023

A public folder seems to be cross platform, at least with Windows, macOS and Linux.

Here is an implementation below. If someone has a better function that is fine.

package os

import (
	"errors"
	"os"
	"runtime"
)

func UserPublicDir() (string, error) {
	if runtime.GOOS == "windows" {
		if v := os.Getenv("PUBLIC"); v != "" {
			return v, nil
		}
		return "", errors.New("%public% is not defined")
	}
	v, err := os.UserHomeDir()
	if err != nil {
		return "", err
	}
	return v + "/Public", nil
}
@ghost ghost added the Proposal label May 9, 2023
@seankhliao
Copy link
Member

is there sufficient usage of this to justify adding it to the standard library?

@seankhliao seankhliao changed the title os: UserPublicDir proposal: os: UserPublicDir May 9, 2023
@gopherbot gopherbot added this to the Proposal milestone May 9, 2023
@seankhliao
Copy link
Member

we need more than just a "yes" to consider this

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 9, 2023
@ianlancetaylor
Copy link
Contributor

@4cq2 It would help to see some examples of code that would benefit from putting this into the standard library.

In particular, please see https://go.dev/doc/faq#x_in_std .

Thanks.

@ghost
Copy link
Author

ghost commented May 10, 2023

@ianlancetaylor thanks for the link, and for all you've done over the years. Go is what convinced me to finally stop using shell scripts for everything and use a proper programming language.

@seankhliao not sure how to say this nice, so I will just say it. I have interacted with you a few times under different characters, and every single time you have been curt and unhelpful. If running the issue tracker is your paid job, you might reconsider if its a good fit for you.

@ghost ghost closed this as completed May 10, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Proposal WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants