1. 23

Hello! Sharing this project I made, I hope that somebody finds it useful: It’s a personal wiki notebook that you can use, backed a git repository of markdown files.

It uses the git2go library to interface to the git repo. It uses blackfriday to render the markdown documents into HTML. It is about 300 lines of code.

The nice thing about using a git backend is that it’s very transparent, you can just view the files in the filesystem as well as being able to store your notes on any of the git hosting sites. It also gives you a lot of power since if the web interface lacks a feature you can get by with the git command line tools.

  1.  

    1. 1

      There are packages that makes these sections more readable. For example: https://github.com/whitecypher/work

      1. 5

        Oh my! Looking at the example, that’s even worse. Now you need to wrap every computation in a closure! There are far more elegant solutions, even with Go’s limited type system. E.g., from the code:

        obj, err := repo.RevparseSingle("HEAD")
        if err != nil { log.Fatal(err) }
        

        Can be converted into:

        if obj, err := repo.RevparseSingle("HEAD"); err != nil {
            log.Fatal(err)
        }
        

        Or just write a small function:

        func exitIfError(err error) {
            if err != nil {
                log.Fatal(err)
            }
        }
        
        // ...
        
        obj, err := repo.RevparseSingle("HEAD")
        exitIfError(err)
        

        Or switch to a language with sum types and monads/macros :). Though, I still have difficulty understanding why the Go team just doesn’t add some syntactic sugar to let errors bubble up, since error is an interface.

        1. 3

          It’s things like this that make Go feel like a spectacular waste of an opportunity to have improved on C. That API could have been more like:

          git_repo_t *gr = NULL;
          git_obj_t *go = NULL;
          git_commit_t *gc = NULL;
          
          if (git_open_repository(repo_path, &gr) != 0 ||
              git_revparse_single(gr, "HEAD", &go) != 0 ||
              git_obj_to_commit(go, &gc) != 0) {
                  warnx(get_errstr());
                  git_commit_free(gc);
                  git_object_free(gc);
                  git_repo_close(gr);
                  return (-1);
          }
          
          return (0);
          
      2. 1

        There is no way that this could be avoid break the DRY principle ?

      3. 4

        I am new to Go and I am trying to get this to work. When I ran go get I am getting following:

        $go get
        
        # pkg-config --cflags libgit2
        Package libgit2 was not found in the pkg-config search path.
        Perhaps you should add the directory containing `libgit2.pc'
        to the PKG_CONFIG_PATH environment variable
        No package 'libgit2' found
        pkg-config: exit status 1
        

        EDIT: Fixed it after doing brew install libgit2

        1. 4

          I’ve been using a project called tiddlywiki (http://tiddlywiki.com/), which I sync via dropbox, for a while now. I like it a lot, primarily because I can use markdown to format everything. This project looks similar, though a little less matured (which is not necessarily a bad thing - last I checked there was not a whole lot of development being done on tiddlywiki, and I’ll take active development over age any day). Tiddlywiki’s faults are mainly in documentation - it took me quite a while to get everything how I wanted, and now I often don’t mess with my configuration, and layout, just in case I mess something up.

          I like using git for sync. I think that’s a good idea, and it was actually something I felt was missing from tiddlywiki. To me, the revision history of my notes is every bit as important as the notes themselves, which is part of the reason that I still use paper for many things. This project seems more flexible than tiddlywiki - it would be easy, for instance, to turn this into a blogging platform. I hope you keep up work on it, it’ll be good for there to be options in the personal wiki product domain.

          1. 3

            very handy, thanks! I’ve been waning to create a personalized Wiki of sorts where I can centralize lots of random information.

            1. 3

              I’m curious how people use personal wikis? Is it for note taking and todos?

              I keep a $HOME/notes folders where I keep a bunch of .md files with my notes and .tasks files (using vim-tasks [1]) for todos. Then I created a tiny ZSH script bin ‘note’ to either open a note if it exists already or create a new one from anywhere in terminal.

                $ note my-project
              

              Will automatically execute:

                 nvim my-project.md 
                 OR
                 echo "# My Project\n\n" >> $HOME/notes/my-project.md && nvim $HOME/notes/my-project.md
              

              I like the simplest approaches. But I’m curious if these Wiki’s help keep things organized better.

              [1] vim-tasks plugin: https://github.com/irrationalistic/vim-tasks

              1. 2

                You’re basically accomplishing the same thing as this project, except he includes git.

                1. 2

                  I keep a personal wiki with gollum, which works over git as well and can use all sorts of text formats, though I tend to stick to markdown. I figured I would always use plain text editing, but on some occasions I do use the in-browser, markdown preview editor.