npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

goose

v0.0.3

Published

Goose is a command which adds brackets for golang

Downloads

106

Readme

Goose is a command which adds brackets for golang!

Golang is great! But its syntax doesn't fit me..
I have no idea about changing it. Only to change the way I code it.
Please help me if you are familiar with Golang.
Indentation-sensitive syntax is more concise. Some people like it, some hate it.
But there should always be an alternative solution for the minority.
Hope you like it.

Installation

By now it's a simple and fragile script adding brackets by counting.
Installing it with npm, some of you may need to add sudo:

npm install -g goose

Use command to watch files in the background. It will write .go in the same path.
There shouldn't be any output after running it. Note that I only tested on Linux.

goose files.gos file2.gos more-file.gos &
pkill -f goose

Usage

-o option to specify output directory.

Considered:

It'll be much more complicated to make it compatible with the whole go syntax.
Below is the parts covered in this script:

  • var const import use parentheses
  • force case default to use curly brackets
  • // comments for comments, /* cross line */ is also available
  • backquote represents cross line strings
  • golang use "\t" to indent

Examples:

This is only a demo in fake code:


package main

import "fmt"

func main()
  fmt.Println("Hello, 世界")


var
  Stdin  = newFile (0, "/dev/stdin")
  Stdout = newFile (1, "/dev/stdout")
  Stderr = newFile (2, "/dev/stderr")

import
  "./file"
  "flag"
  "fmt"
  "os"

const
  red = iota   // red == 0
  blue         // blue == 1
  green        // green == 2

 
func cat(f *file.File)
  const NBUF = 512
  var buf [NBUF]byte
  for
    switch nr, er := f.Read(buf[:]); true
    case nr < 0:
      fmt.Fprintf(os.Stderr, "cat: error reading from %s: %s\n", f.String(), er.String())
      os.Exit(1)
    case nr == 0:  // EOF
      return
    case nr > 0:
      if nw, ew := file.Stdout.Write(buf[0:nr]); nw != nr
        fmt.Fprintf(os.Stderr, "cat: error writing from %s: %s\n", f.String(), ew.String())

Otto.Set("def", 11)
Otto.Run(`
  console.log("The value of def is " + def)
    // The value of def is 1

`)

/* comment
comment
    comment
  comment
*/

Converts to:


package main

import "fmt"

func main() {
  fmt.Println("Hello, 世界")
}


var (
  Stdin  = newFile (0, "/dev/stdin")
  Stdout = newFile (1, "/dev/stdout")
  Stderr = newFile (2, "/dev/stderr")
)

import (
  "./file"
  "flag"
  "fmt"
  "os"
)

const (
  red = iota   // red == 0
  blue         // blue == 1
  green        // green == 2
)


func cat(f *file.File) {
  const NBUF = 512
  var buf [NBUF]byte
  for {
    switch nr, er := f.Read(buf[:]); true
    case nr < 0: {
      fmt.Fprintf(os.Stderr, "cat: error reading from %s: %s\n", f.String(), er.String())
      os.Exit(1)
    }
    case nr == 0:  // EOF {
      return
    }
    case nr > 0: {
      if nw, ew := file.Stdout.Write(buf[0:nr]); nw != nr {
        fmt.Fprintf(os.Stderr, "cat: error writing from %s: %s\n", f.String(), ew.String())
      }
    }
  }
}

Otto.Set("def", 11)
Otto.Run(`
  console.log("The value of def is " + def)
    // The value of def is 1

`)

/* comment
comment {
    comment
  }
  comment
}
*/

Syntax highlight

You can use the Sublime package to highlight:
https://github.com/jiyinyiyong/Goose.sublime

License

MIT