Giter Site home page Giter Site logo

Pull in typewriter package about gen HOT 6 CLOSED

clipperhouse avatar clipperhouse commented on May 22, 2024
Pull in typewriter package

from gen.

Comments (6)

freeeve avatar freeeve commented on May 22, 2024

Seems reasonable. I was thinking it seemed like there was an extra package somewhere in the new layout.

from gen.

clipperhouse avatar clipperhouse commented on May 22, 2024

It appears this is a no-go – a gen package with a main() (that is, a package intended to be installed as a binary) cannot also be used as an import.

At least, not in my experiments. Is the above true?

from gen.

maddyblue avatar maddyblue commented on May 22, 2024

You can import a package named main with a main() func, but you must name the import:

$GOPATH/src/a/main.go:

package main

import b "b" // just `import "b"` won't work here - try it

func main() {
    println("a")
    b.Hi()
}

$GOPATH/src/b/main.go:

package main

func main() {
    println("b")
}

func Hi() {
    println("hi")
}

$ go run $GOPATH/src/a/main.go
a
hi

from gen.

freeeve avatar freeeve commented on May 22, 2024

You could also do something like go get github.com/clipperhouse/gen/gen for the binary w/ main--you'd have to put it in a subfolder though. This is also necessary for the gopkg.in router--had to do it for https://github.com/wfreeman/pj

from gen.

clipperhouse avatar clipperhouse commented on May 22, 2024

@mjibson @wfreeman Thanks, I suspected the workarounds would look like that. I think both are a bit error-prone for clients of the package, though the subfolder offends me slightly less.

I think a subfolder for the binary is def a no-go from a design perspective. A simpler URL for installers wins, since they are the majority of users.

So then the library is the thing. Do we ask people to import clipperhouse/typewriter or clipperhouse/gen/gen?

from gen.

clipperhouse avatar clipperhouse commented on May 22, 2024

The typewriter package is still separate, but part of the main gen repo. Good enough for now.

from gen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.