Skip to content

Commit

Permalink
clean up extraneous stuff in main
Browse files Browse the repository at this point in the history
  • Loading branch information
philhofer committed Apr 7, 2015
1 parent f8e5650 commit 75ee40d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
24 changes: 0 additions & 24 deletions doc.go

This file was deleted.

32 changes: 28 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
// msgp is a code generation tool for
// creating methods to serialize and de-serialize
// Go data structures to and from MessagePack.
//
// This package is targeted at the `go generate` tool.
// To use it, include the following directive in a
// go source file with types requiring source generation:
//
// //go:generate msgp
//
// The go generate tool should set the proper environment variables for
// the generator to execute without any command-line flags. However, the
// following options are supported, if you need them:
//
// -o = output file name (default is {input}_gen.go)
// -file = input file name (or directory; default is $GOFILE, which is set by the `go generate` command)
// -io = satisfy the `msgp.Decodable` and `msgp.Encodable` interfaces (default is true)
// -marshal = satisfy the `msgp.Marshaler` and `msgp.Unmarshaler` interfaces (default is true)
// -tests = generate tests and benchmarks (default is true)
//
// For more information, please read README.md, and the wiki at github.com/tinylib/msgp
//
package main

import (
Expand All @@ -24,8 +46,7 @@ var (
func main() {
flag.Parse()

// GOFILE and GOPACKAGE are
// set by `go generate`
// GOFILE is set by go generate
if *file == "" {
*file = os.Getenv("GOFILE")
if *file == "" {
Expand Down Expand Up @@ -56,8 +77,10 @@ func main() {
}
}

// Run writes all methods using the associated file/path and package.
// (The package is only relevant for writing the new file's package declaration.)
// Run writes all methods using the associated file or path, e.g.
//
// err := msgp.Run("path/to/myfile.go", gen.Size|gen.Marshal|gen.Unmarshal|gen.Test)
//
func Run(gofile string, mode gen.Method) error {
if mode&^gen.Test == 0 {
return nil
Expand All @@ -77,6 +100,7 @@ func Run(gofile string, mode gen.Method) error {
return printer.PrintFile(newFilename(gofile, fs.Package), fs, mode)
}

// picks a new file name based on input flags and input filename(s).
func newFilename(old string, pkg string) string {
if *out != "" {
if pre := strings.TrimPrefix(*out, old); len(pre) > 0 &&
Expand Down

0 comments on commit 75ee40d

Please sign in to comment.