From fc2c45d73ea63a64441206b2c358c1018a134182 Mon Sep 17 00:00:00 2001 From: Ambor Date: Sat, 27 Jun 2020 22:03:35 +0800 Subject: [PATCH] Fix unexcept error for the config (#16) * fix: not except error echo for the config not exist * docs: update the md styles --- CODE_OF_CONDUCT.md => CODEOFCONDUCT.md | 3 +-- CONTRIBUTING.md | 3 +-- README.md | 14 ++++++-------- config/config.go | 4 ++-- 4 files changed, 10 insertions(+), 14 deletions(-) rename CODE_OF_CONDUCT.md => CODEOFCONDUCT.md (99%) diff --git a/CODE_OF_CONDUCT.md b/CODEOFCONDUCT.md similarity index 99% rename from CODE_OF_CONDUCT.md rename to CODEOFCONDUCT.md index eba53b6..050c6f1 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODEOFCONDUCT.md @@ -1,4 +1,3 @@ - # Contributor Covenant Code of Conduct ## Our Pledge @@ -61,7 +60,7 @@ representative at an online or offline event. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at -[INSERT CONTACT METHOD]. +[saltbo@foxmail.com]. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7447885..2982611 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing -By participating to this project, you agree to abide our [code of conduct](/CODE_OF_CONDUCT.md). +By participating to this project, you agree to abide our [code of conduct](/CODEOFCONDUCT.md). ## Setup your machine @@ -71,4 +71,3 @@ Thank you to all our backers! [[Become a backer](https://opencollective.com/salt ### Sponsors Thank you to all our sponsors! (please ask your company to also support this open source project by [becoming a sponsor](https://opencollective.com/saltbo#sponsor)) - diff --git a/README.md b/README.md index 26ff841..b2d0602 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,14 @@ English | [πŸ‡¨πŸ‡³δΈ­ζ–‡](https://saltbo.cn/uptoc) **homebrew tap**: -```console -$ brew install saltbo/bin/uptoc +```bash +brew install saltbo/bin/uptoc ``` **homebrew** (may not be the latest version): -```console -$ brew install uptoc +```bash +brew install uptoc ``` **deb/rpm**: @@ -41,8 +41,8 @@ install with `dpkg -i` and `rpm -i` respectively. **Shell script**: -```console -$ curl -sSf https://static.saltbo.cn/github.com/uptoc/install.sh | sh +```bash +curl -sSf https://static.saltbo.cn/github.com/uptoc/install.sh | sh ``` **manually**: @@ -50,8 +50,6 @@ $ curl -sSf https://static.saltbo.cn/github.com/uptoc/install.sh | sh Download the pre-compiled binaries from the [releases page](https://github.com/saltbo/uptoc/releases) and copy to the desired location. - - ## Usage ### Basic diff --git a/config/config.go b/config/config.go index 2ba065a..14ddd40 100644 --- a/config/config.go +++ b/config/config.go @@ -59,7 +59,7 @@ func ParseFromRC() (*Config, error) { } rcPath := filepath.Join(homeDir, ".uptocrc") - f, err := os.OpenFile(rcPath, os.O_CREATE|os.O_RDWR, 0644) + f, err := os.OpenFile(rcPath, os.O_RDWR, 0644) if os.IsNotExist(err) { return nil, fmt.Errorf("please setup your config by run `uptoc config`") } else if err != nil { @@ -69,7 +69,7 @@ func ParseFromRC() (*Config, error) { c := &Config{f: f} yd := yaml.NewDecoder(f) if err := yd.Decode(c); err != nil { - return nil, err + return nil, fmt.Errorf("decode config failed: %s", err) } if strings.HasPrefix(c.Core.SaveRoot, "/") {