From 8ef813e55dc2fa610f40f795c9852a7ca336fd98 Mon Sep 17 00:00:00 2001 From: stephen mcquay Date: Sun, 7 Feb 2016 23:54:55 -0800 Subject: [PATCH] init --- cmd/ysvd/main.go | 4 ++++ doc.go | 2 ++ licence.txt | 27 +++++++++++++++++++++++++++ readme.md | 11 +++++++++++ ysv.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ ysv_test.go | 37 +++++++++++++++++++++++++++++++++++++ 6 files changed, 129 insertions(+) create mode 100644 cmd/ysvd/main.go create mode 100644 doc.go create mode 100644 licence.txt create mode 100644 readme.md create mode 100644 ysv.go create mode 100644 ysv_test.go diff --git a/cmd/ysvd/main.go b/cmd/ysvd/main.go new file mode 100644 index 0000000..da29a2c --- /dev/null +++ b/cmd/ysvd/main.go @@ -0,0 +1,4 @@ +package main + +func main() { +} diff --git a/doc.go b/doc.go new file mode 100644 index 0000000..5fc7b89 --- /dev/null +++ b/doc.go @@ -0,0 +1,2 @@ +// package ysv implements a vanity service for use by the the go tool +package ysv diff --git a/licence.txt b/licence.txt new file mode 100644 index 0000000..754c07d --- /dev/null +++ b/licence.txt @@ -0,0 +1,27 @@ +Copyright (c) 2016, stephen mcquay + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ysv nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..fc49c8e --- /dev/null +++ b/readme.md @@ -0,0 +1,11 @@ +# ysv + +`ysvd` is a vanity url server for use by the `go` tool. + +## installation + + $ go get mcquay.me/ysv/cmd/ysvd + +## running server + + $ ysvd diff --git a/ysv.go b/ysv.go new file mode 100644 index 0000000..034f4b9 --- /dev/null +++ b/ysv.go @@ -0,0 +1,48 @@ +/* + +From the documentation for the go tool, it searches for the following header +when searching for packages: + + + +ysv stands for You're so Vain, the song by Carly Simon. +*/ +package ysv + +import "fmt" + +type vcs int + +const ( + Git vcs = iota + Hg +) + +var vcss = [...]string{ + "git", + "mercurial", +} + +var labelToVcs = map[string]vcs{ + "git": Git, + "mercurial": Hg, + "hg": Hg, +} + +// String returns the name of the vcs ("git", "mercurial", ...). +func (v vcs) String() string { return vcss[v] } + +type pkg struct { + Vcs vcs `json":vcs"` + Path string `json:"path"` + Repo string `json:"repo"` +} + +func (p pkg) String() string { + return fmt.Sprintf( + "", + p.Path, + p.Vcs, + p.Repo, + ) +} diff --git a/ysv_test.go b/ysv_test.go new file mode 100644 index 0000000..4c0b527 --- /dev/null +++ b/ysv_test.go @@ -0,0 +1,37 @@ +package ysv + +import ( + "fmt" + "testing" +) + +func TestString(t *testing.T) { + p := pkg{ + Path: "mcquay.me/bps", + Repo: "https://s.mcquay.me/sm/bps", + } + got := fmt.Sprintf("%s", p) + want := `` + if got != want { + t.Errorf( + "incorrect converstion to meta; got %s, want %s", + got, + want, + ) + } +} + +func TestVcsStrings(t *testing.T) { + tests := []struct { + got string + want string + }{ + {fmt.Sprintf("%+v", Git), "git"}, + {fmt.Sprintf("%+v", Hg), "mercurial"}, + } + for _, test := range tests { + if test.got != test.want { + t.Errorf("incorrect conversion of ysv.Vcs -> string; got %q, want %q", test.got, test.want) + } + } +}