Dave Cheney | 28 Feb 03:17 2015
Picon

Re: go build - multiple cmd



On Saturday, 28 February 2015 10:13:36 UTC+11, Carlos wrote:
Hi,


Probably I am wrong - but I don't if I am wrong because I am doing something wrong or because the concept is wrong.

I have a project which will generate few binaries, therefore, I have few packages under cmd, like:

----> cmd/magic1
----> cmd/magic2


When I have only magic1 or magic2 under cmd, when I call:
$ go build ./cmd/... 

It generates the magic1 binary correctly. But when I have both, the same command generates no binary at all.

You didn't include an example of trying this, and the results. That said, most of the go commands take multiple arguments, consider

% go build ./cmd/magic1 ./cmd/magic2

To echo what Ian also said, please prefer go install over go build, pretty much always.
 
 
What is it wrong that I am doing/thinking?


Thanks,
        - CC

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Ian Davis | 28 Feb 03:10 2015

Re: go build - multiple cmd

 
On Fri, Feb 27, 2015, at 11:12 PM, Carlos U. Cirello Filho wrote:
Hi,
 
 
Probably I am wrong - but I don't if I am wrong because I am doing something wrong or because the concept is wrong.
 
I have a project which will generate few binaries, therefore, I have few packages under cmd, like:
 
----> cmd/magic1
----> cmd/magic2
 
 
When I have only magic1 or magic2 under cmd, when I call:
$ go build ./cmd/... 
 
It generates the magic1 binary correctly. But when I have both, the same command generates no binary at all.
 
What is it wrong that I am doing/thinking?
 
 
Use go install instead
 
Ian

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Ivan Daniluk | 28 Feb 01:43 2015
Picon

Weird timezone (+139 TMT). Is it Go-specific issue?

Hi all,

I'm in Tallinn (Estonia) right now (EET) and the next code produces strange result for me, both on Linux GAE-instance, and on local MacOS X:
package main

import (
"fmt"
"time"
)

func main() {
tzName, tzOffset := time.Now().In(time.Local).Zone()
fmt.Printf("time.Local is: %s (GMT+%d)\n", tzName, tzOffset/3600)

t, _ := time.Parse("15:04", "14:35")
fmt.Println("T:", t)
fmt.Println("T:", t.In(time.Local))

fmt.Println("Now:", time.Now().In(time.Local))
}


Output:
time.Local is: EET (GMT+2)
T: 0000-01-01 14:35:00 +0000 UTC
T: 0000-01-01 16:14:00 +0139 TMT
Now: 2015-02-28 02:41:02.452292128 +0200 EET

Notice that "+0139 TMT" zone. It appears only with time obtained by time.Parse(). With time.Now() it seems to be ok.

I can't find any information on that weird timezone. Can someone clarify this?
Looks like bug for me.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Mike Ossareh | 28 Feb 01:12 2015
Picon

Re: go build - multiple cmd

This is by design and is documented here: http://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies

When the command line specifies a single main package, build writes the resulting executable to output. Otherwise build compiles the packages but discards the results, serving only as a check that the packages can be built.

To build both you can issue:

go build github.com/yatayatayta/cmd/magic1
go build github.com/yatayatayta/cmd/magic2

given the commands are under cmd/ you can readily script this so that you don't have to build each one by hand.


On Fri, Feb 27, 2015 at 5:12 PM, Carlos U. Cirello Filho <uldericofilho-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Hi,


Probably I am wrong - but I don't if I am wrong because I am doing something wrong or because the concept is wrong.

I have a project which will generate few binaries, therefore, I have few packages under cmd, like:

----> cmd/magic1
----> cmd/magic2


When I have only magic1 or magic2 under cmd, when I call:
$ go build ./cmd/... 

It generates the magic1 binary correctly. But when I have both, the same command generates no binary at all.

What is it wrong that I am doing/thinking?


Thanks,
        - CC

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
tholowka | 27 Feb 22:51 2015
Picon

DI engine for Go

Hello All, 

I have created a small library for providing Dependency Injection in Go. 
Contrary to the other one I saw (https://github.com/facebookgo/inject) the library I've created does not rely on 'annotations' (reminiscent of the encoding/json package). 
It has its own convention and best-practices, which I tried highlighting in the Github README. 

The link to the library is https://github.com/tholowka/octopus.

My personal belief is that to make a product good, the good way is to open source it and have other people, review, test and hammer out bugs. 
If you are interested in this, please drop me a line. I will help you set this up for you if you bump into problems. 

I would appreciate suggestions whether there are bugs, and how to improve the documentation. 
Regards, 
tholowka


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Carlos U. Cirello Filho | 28 Feb 00:12 2015
Picon

go build - multiple cmd

Hi,


Probably I am wrong - but I don't if I am wrong because I am doing something wrong or because the concept is wrong.

I have a project which will generate few binaries, therefore, I have few packages under cmd, like:

----> cmd/magic1
----> cmd/magic2


When I have only magic1 or magic2 under cmd, when I call:
$ go build ./cmd/... 

It generates the magic1 binary correctly. But when I have both, the same command generates no binary at all.

What is it wrong that I am doing/thinking?


Thanks,
        - CC

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Rüdiger Sonderfeld | 27 Feb 21:08 2015
Picon

Proposal: Add StringBase method to big.Int

Hello,

the SetString method of big.Int supports setting Int from a string with any 
base between 2 and MaxBase.  However there is no corresponding function to 
extract the string in such a base.  String() only supports base 10 and Format 
is limited to base 2, 8, 10, or 16.  While those are certainly the most 
popular choices, other choices, such as 12, 32, or 36 are not unlikely and in 
fact I came upon the issue because I need base 36.  Therefore I propose adding 
a StringBase method, which accepts any base between 2 and MaxBase and returns 
a string of the Int in the base.

Changing String to accept a base would sadly break backwards compatibility and 
be incompatible to the fmt.Stringer interface.

The only issue I see is whether to use lowercase or uppercase letters for 
bases above 10.  I see the following options:

1. Simply decide it.  If the user needs an upper/lowercase version then she 
can strings.ToUpper/Lower.  This however could become problematic if MaxBase 
is ever changed beyond 36.

2. Add an additional flag to allow switching.  Since the issue only applies 
for 10 < base <= 36 the flag would make no sense for many cases and just 
complicate the call.  (Crazy suggestion:  Use "negative" bases for a certain 
case and positive bases for another case.  This however wouldn't be very 
intuitive, require changing SetString, and might mislead users into thinking 
Go had real support for negative bases)

3. Let the user provide the character set.  This is actually how the 
underlying function big.nat.string deals with it.  This would like option 2 
complicate the call.

Here is a simple implementation of StringBase (using lowercase):

----
// StringBase returns x as a string in the given base.
// The base argument must be a value from 2 through MaxBase.
func (x *Int) StringBase(base int) string {
	if base < 2 || base > MaxBase {
		panic(fmt.Sprintf("illegal number base %d", base))
	}
	charset := lowercaseDigits[0:base]
	switch {
	case x == nil:
		return "<nil>"
	case x.neg:
		return "-" + x.abs.string(charset)
	}
	return x.abs.string(charset)
}
----

I have a patch including test cases ready.  I just wanted some feedback, 
especially on the lowercase/uppercase issue before submitting it for review.

Regards,
Rüdiger

--

-- 
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@...
For more options, visit https://groups.google.com/d/optout.

Cenk Altı | 27 Feb 21:04 2015
Picon

[ANN] dominantcolor: Find dominant color in images

I have ported the KMean clustering algorithm for finding dominant color in an image from Chromium source code.

https://github.com/cenkalti/dominantcolor

The documentation explains how the algorithm works in detail:
http://godoc.org/github.com/cenkalti/dominantcolor

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Manlio Perillo | 27 Feb 19:45 2015
Picon

using html/template for SVG documents

Hi.

I'm trying to use html/template for the generation of SVG documents.
However SVG is an XML application, and it seems hmtl/template does not support XML.

The following template:

var svg = `
<?xml version="1.0" standalone="no"?>
<svg width="auto" height="auto" version="1.1"
     xmlns="http://www.w3.org/2000/svg">
</svg>
`

generates
&lt;?xml version="1.0" standalone="no"?>
<svg width="auto" height="auto" version="1.1"
     xmlns="http://www.w3.org/2000/svg">
</svg>


How hard is to modify html/template to support XML and friends?


Thanks  Manlio Perillo 

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Ken MacDonald | 27 Feb 17:05 2015
Picon

Flag package unexpected behaviour....

I've been using the "flag" package to parse a command line argument, "-cfg file.conf" to get the name of a config file.

I used:

flag.StringVar(&cfgFile, "cfg", "file.conf", "-cfg file.conf")

followed by:

gcfg.ReadFileInto(&Cfg, cfgFile)   // Cfg is a struct...

which reads the file named in the variable cfgFile just peachy. As long as that file name is "file.conf".

Note that I had forgotten to call flag.Parse().... but the value of the variable "cfgFile" is set to my default value anyway. The doc for the flag package says that
the flag variables are not usable until after flag.Parse() is called, which - to me - indicates that "cfgFile" should have been empty. This seems like a bug in the flag package. The flag variables defined should really not have values until flag.Parse() runs - assigning the defaults at the time the flags are first defined made it difficult to notice that I had an error in my logic until the program moved to another platform and we tried to run:

./myprogram -cfg someotherfile.conf

which immediately croaked with "can't open file.conf".

Since the doc says that flag.Parse() is needed to set the flag values, it would be great if it actually worked that way.
Ken

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
zylthinking | 27 Feb 09:10 2015
Picon

why write channel in select block will never failed to default branch.

Hi, groups

I have a question here:

package main
import "fmt"

func main() {
    ch := make(chan int, 1)
    if (1 < 2) {
        fmt.Println("--------");
    }   

    for j := 0; j < 100; j += 1  {
        select {
            case ch <- 0:
                fmt.Println("write 0");
            case ch <- 1:
                fmt.Println("write 1");
            default:
                fmt.Println("fuck0000000000000000000000000000");
        }   
        i := <- ch
        fmt.Println("i = ", i); 
    }   
}

I can get write 0, write 1, while never fuck0000000000000000000000000000
why?

then I add another line:
            case ch <- 2:
                fmt.Println("write 2");
this time I got all write 0, write 1,  write 2;
so it is not a timing problem.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Gmane