Skip to content

Commit

Permalink
refactoring linter
Browse files Browse the repository at this point in the history
  • Loading branch information
aladine committed Feb 5, 2019
1 parent 329e33a commit 3d3222c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 64 deletions.
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

32 changes: 0 additions & 32 deletions .goreleaser.yml

This file was deleted.

6 changes: 1 addition & 5 deletions Readme.org
@@ -1,7 +1,3 @@
#+TITLE: README
#+STARTUP: showall


* EverOrg

[[./docs/images/Unicorn.png]]
Expand Down Expand Up @@ -57,7 +53,7 @@
#!/bin/bash
FILES=$HOME/evernote/*.enex

for f in $FILES ; do
for f in $FILES ; do
./EverOrg --input=$f --merge=false
done
#+END_SRC
Expand Down
16 changes: 3 additions & 13 deletions evernote.go
Expand Up @@ -53,9 +53,9 @@ type Note struct {
Author string `xml:"author"`
Latitude float64 `xml:"latitude"`
Longitude float64 `xml:"longitude"`
Altitude float64 `xml:"altitude"`
Source string `xml:"source"`
SourceUrl string `xml:"source-url"`
// Altitude float64 `xml:"altitude"`
Source string `xml:"source"`
SourceUrl string `xml:"source-url"`
} `xml:"note-attributes"`

Resources []Resource `xml:"resource"`
Expand All @@ -69,13 +69,3 @@ type Resource struct {
Encoding string `xml:"encoding,attr"`
} `xml:"data"`
}

// Content ...
type Content struct {
Spans []struct {
Media []struct {
Hash string `xml:"hash,attr"`
Type string `xml:"type,attr"`
} `xml:"en-media"`
} `xml:"span"`
}
19 changes: 9 additions & 10 deletions everorg.go
Expand Up @@ -187,7 +187,6 @@ func (nodes Nodes) orgFormat() string {

default:
fmt.Println("skip token: " + node.Token.Data)
break
}

case html.EndTagToken:
Expand Down Expand Up @@ -296,21 +295,21 @@ func main() {
newWrittenDir := filepath.Join(currentDir, baseName)
// strings.TrimSuffix(readFile, ext)
if _, err = os.Stat(newWrittenDir); os.IsNotExist(err) {
os.Mkdir(newWrittenDir, 0711)
_ = os.Mkdir(newWrittenDir, 0711)
}

// Create Attachments Directory if not existent
currentFilePathName := filepath.Join(newWrittenDir, baseName)

attachmentPath = currentFilePathName + attFolderExt
if _, err = os.Stat(attachmentPath); os.IsNotExist(err) {
os.Mkdir(attachmentPath, 0711)
_ = os.Mkdir(attachmentPath, 0711)
}

b, _ := ioutil.ReadAll(xmlFile)

var q Query
xml.Unmarshal(b, &q)
_ = xml.Unmarshal(b, &q)

var f *os.File
// Parse the contained xml
Expand All @@ -334,17 +333,17 @@ func main() {
nodes := parseHTML(reader)

if isMerged {
f.WriteString(note.orgProperties())
f.WriteString(nodes.orgFormat())
f.Sync()
_, _ = f.WriteString(note.orgProperties())
_, _ = f.WriteString(nodes.orgFormat())
_ = f.Sync()
} else {
noteFileName := sanitize(note.Title) + "-" + note.Updated + ".org"
newFile, err := os.Create(filepath.Join(newWrittenDir, noteFileName))
if err != nil {
continue
}
newFile.WriteString(note.orgProperties())
newFile.WriteString(nodes.orgFormat())
_, _ = newFile.WriteString(note.orgProperties())
_, _ = newFile.WriteString(nodes.orgFormat())
_ = newFile.Close()
}

Expand Down Expand Up @@ -387,7 +386,7 @@ func sanitize(title string) string {
func createAttachment(attachment Resource, attachmentPath string) error {
h := md5.New()
sDec, _ := b64.StdEncoding.DecodeString(attachment.Data.Content)
h.Write(sDec)
_, _ = h.Write(sDec)
filename := hex.EncodeToString(h.Sum(nil))
ext, err := mime.ExtensionsByType(attachment.Mime)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
@@ -1,3 +1,3 @@
module github.com/aladine/EverOrg

require golang.org/x/net v0.0.0-20190110200230-915654e7eabc
require golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3
4 changes: 2 additions & 2 deletions go.sum
@@ -1,2 +1,2 @@
golang.org/x/net v0.0.0-20190110200230-915654e7eabc h1:Yx9JGxI1SBhVLFjpAkWMaO1TF+xyqtHLjZpvQboJGiM=
golang.org/x/net v0.0.0-20190110200230-915654e7eabc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3 h1:ulvT7fqt0yHWzpJwI57MezWnYDVpCAYBVuYst/L+fAY=
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=

0 comments on commit 3d3222c

Please sign in to comment.