[go-nuts] warning: "std" matched no packages (hello world works)

2017-11-10 Thread rorschach . rev
Platform is x86_64 kernel 4.4.0 Ubuntu flavored Linux Mint. I had the 
golang package installed but it was too old to run newer code. Removed 
package and proceeded with install.
Downloaded static version of go 1.9.2 (104247844 bytes) from website, moved 
folder into /usr/local/go. gopath is set. and I followed the hello world 
example in the docs/install.html.  

go list std
warning: "std" matched no packages

go get github.com/dvyukov/go-fuzz/go-fuzz
gocode/src/github.com/dvyukov/go-fuzz/go-fuzz/hub.go:35:5: error: reference 
to undefined identifier ‘atomic.Value’
(plus many more errors)

go get github.com/dvyukov/go-fuzz/go-fuzz-build
package go/constant: unrecognized import path "go/constant"
package go/types: unrecognized import path "go/types"

go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/me/gocode"
GORACE=""
GOROOT="/usr"
GOTOOLDIR="/usr/lib/gccgo/tool"
TERM="dumb"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CXX="g++"
CGO_ENABLED="1"

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Zip file created by archive/zip can't be opened on Windows machine

2017-11-10 Thread Donovan
its not totally clear the exact issue you're dealing with - a minimal 
example would go a long way.

If I had to guess, I would say your zip entries are using characters not 
supported by windows file systems. windows has more reserved characters 
than you might expect, and even reserved filenames you have to avoid like 
nul, ptr, etc. 
See 
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions


On Friday, November 10, 2017 at 4:40:40 PM UTC-5, Jimmy 99 wrote:
>
> Is anyone familiar with the archive/zip package? 
> I am experiencing the following problem:
> When I create the Zip file on Ubuntu the file can be extracted no problem.
> When I try and extract the zip file on a windows machine I get an error 
> saying the file cannot be created.
>
> I have tried compiling the go app on the windows machine, and same problem 
> - Windows file explorer cannot extract the zipped file.
>
> Interestingly enough, 7zip on the windows machine can extract the zip 
> file, but obviously I cannot ask the user community to install 7zip just to 
> extract a zip file:(
>
> Any help or pointers will be appreciated
>
>
>
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: NaN as key in map

2017-11-10 Thread 'Bryan Mills' via golang-nuts
On Friday, November 10, 2017 at 5:24:25 PM UTC-5, Stefan Nilsson wrote:
>
> NaN is not equal to NaN. This means that if you use NaN as a key in a 
> map[float64]string you will not be able to retrieve it again: 
> https://play.golang.org/p/A7KGgoM3o6
> I guess this is the way it should be, but it's still a little bit 
> disconcerting. What's your thoughts on this?
>

See https://golang.org/issue/20660. 

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] NaN as key in map

2017-11-10 Thread Dave Cheney
You could iterate over the map with range and retrieve the key and values

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] NaN as key in map

2017-11-10 Thread Jan Mercl
On Fri, Nov 10, 2017 at 11:24 PM Stefan Nilsson <
trolleriprofess...@gmail.com> wrote:

> What's your thoughts on this?

Not mine, but recommended reading: https://research.swtch.com/randhash

-- 

-j

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] NaN as key in map

2017-11-10 Thread Stefan Nilsson
NaN is not equal to NaN. This means that if you use NaN as a key in a 
map[float64]string you will not be able to retrieve it again: 
https://play.golang.org/p/A7KGgoM3o6
I guess this is the way it should be, but it's still a little bit 
disconcerting. What's your thoughts on this?

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Zip file created by archive/zip can't be opened on Windows machine

2017-11-10 Thread Jimmy 99
Is anyone familiar with the archive/zip package? 
I am experiencing the following problem:
When I create the Zip file on Ubuntu the file can be extracted no problem.
When I try and extract the zip file on a windows machine I get an error 
saying the file cannot be created.

I have tried compiling the go app on the windows machine, and same problem 
- Windows file explorer cannot extract the zipped file.

Interestingly enough, 7zip on the windows machine can extract the zip file, 
but obviously I cannot ask the user community to install 7zip just to 
extract a zip file:(

Any help or pointers will be appreciated



-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: import paths - slash vs backslash

2017-11-10 Thread Dave Cheney
That's a good question.

The contents of the import declaration are defined to be implementation 
dependent by the spec

> The interpretation of the ImportPath is implementation-dependent but it 
is typically a substring of the full file name of the compiled package and 
may be relative to a repository of installed packages.

It also goes on to say

> Implementation restriction: A compiler may restrict ImportPaths to 
non-empty strings using only characters belonging to Unicode's 
 L, M, N, P, and S general 
categories (the Graphic characters without spaces) and may also exclude the 
characters !"#$%&'()*,:;<=>?[\]^`{|} and the Unicode replacement character 
U+FFFD.

Suggesting that some implementations may exclude backslash.

In practice gc and gccgo treat the import path as a directory path, and 
while windows can cope with forward slashes, non windows operating systems 
cannot cope with backslash. So for simplicities sake, i'd say you should 
treat the import path like a path in a url--forward slashes only.

On Saturday, 11 November 2017 05:31:37 UTC+11, Tim Hockin wrote:
>
> Is it valid to say `import "github.com\foo\bar" (windows path 
> separators) or must it be "github.com/foo/bar"?  I couldn't find a 
> canonical answer to this. 
>
> Thanks 
>
> Tim 
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: try to avoid additional memory allocations

2017-11-10 Thread krolaw
You could avoid allocations altogether by reusing the same byte array and 
passing it to the function.

To retain readability, use a buffer and fmt.Fprintf

On Saturday, 11 November 2017 04:00:48 UTC+13, Vasiliy Tolstov wrote:
>
> Thanks, i know that optimization can lead obscurity, but for critical 
> paths i think that it useful =) 
>
> 2017-11-10 8:41 GMT+03:00 peterGo : 
> > Vasiliy, 
> > 
> > For portability, when you initialize cfg.WorkDir, clean it: cfg.WorkDir 
> = 
> > filepath.Clean(cfg.WorkDir) 
> > 
> > You can reduce the allocations from 5 to 1. However, optimization can 
> lead 
> > to obscurity. For example, 
> > 
> > $ go test oid_test.go -bench=. 
> > BenchmarkVasiliy-4 200700 ns/op88 B/op5 allocs/op 
> > BenchmarkKrolaw-4  300550 ns/op80 B/op4 allocs/op 
> > BenchmarkPeter-4  1000201 ns/op48 B/op1 allocs/op 
> > 
> > Playground: https://play.golang.org/p/DnGoM8PYd6 
> > 
> > Peter 
> > 
> > 
> > On Thursday, November 9, 2017 at 3:58:03 PM UTC-5, Vasiliy Tolstov 
> wrote: 
> >> 
> >> Hi. I have server that read/write data to many files (each is about 
> >> 4-32Mb). To determine on which file i need to read/write i'm use this 
> >> function to os.OpenFile 
> >> 
> >> func oid2filepath(cfg *Config, oID uint64) string { 
> >> file_path := filepath.Join(cfg.WorkDir, fmt.Sprintf("%x", 
> >> oid2vid(oID)), fmt.Sprintf("%016x", oID)) 
> >> return file_path 
> >> } 
> >> 
> >> oid2vid function get uint32 and return uint32 with shift some bits 
> >> path looks like (for one of 4Mb chunk) 
> store/obj/7c2b25/007c2b250180 
> >> 
> >> When i'm write 4Gb data i need to call this function 1024 times for 
> >> single big chunk of data. 
> >> Does it possible to write function that does not have additional 
> >> allocations? 
> >> And does it possible to write it in portable way (i mean path 
> separator). 
> >> 
> >> 
> >> -- 
> >> Vasiliy Tolstov, 
> >> e-mail: v.to...@selfip.ru 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
> Vasiliy Tolstov, 
> e-mail: v.to...@selfip.ru  
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Golang performance benchmarks on arm64 (Qualcomm Centriq 2400)

2017-11-10 Thread Jonathan Yu
On Thu, Nov 9, 2017 at 6:37 AM, Gerald Henriksen  wrote:

> On Wed, 8 Nov 2017 13:57:03 -0800 (PST), you wrote:
>
> >"Go support for aarch64 is quite disappointing.
>
> >Qualcomm and other ARMv8
> >vendors intends to put significant engineering resources to amend this
> >situation, but really any one can contribute to Go. So if you want to live
> >your mark, now is the time."
>
> I would turn this around and say hardware support for aarch64 is quite
> disappointing, and as a result nobody is interested in developing for
> it (outside of certain companies who can either afford the hardware
> costs or are given the hardware).
>
> If the aarch64 hardware makers want the open source community to
> develop and test for aarch64, then they need to make appropriate
> hardware available to the community at a cost your average open source
> developer can afford.  Yes, it nice the blogger in question was given
> some (likely very expensive) hardware, but that doesn't apply to the
> community in general.
>

Presumably most of the development will be done by companies (such as
CloudFlare) that have a vested interest in a second vendor succeeding,
perhaps because of better performance for specific applications (more
cores, less energy, better price/performance ratio). Large open source
projects (e.g. Debian) will probably get sponsored machines. Smaller
projects would presumably be able to "rent" these processors on one of the
clouds and might receive some sponsorship as well.

>
> [and this is restriced to ARM, POWER has the same issue]
>

I assume you mean "not restricted" to ARM. POWER doesn't seem to have
really taken off (neither ARM at present, but certainly Centriq is
fascinating) despite being opened up (OpenPOWER). I'm not close enough to
either of these communities to speculate as to why this is so.

-- 
Jonathan Yu / *@jawnsy* on LinkedIn ,
Twitter , GitHub ,
Facebook 
*“Ever tried. Ever failed. No matter. Try again. Fail again. Fail better.”* —
Samuel Beckett, Worstward Ho (1983)

“In an adaptive environment, winning comes from adapting to change by
continuously experimenting and identifying new options more quickly and
economically than others. The classical strategist's mantra of sustainable
competitive advantage becomes one of serial temporary advantage.” — Navigating
the Dozens of Different Strategy Options

 (HBR)

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] import paths - slash vs backslash

2017-11-10 Thread 'Tim Hockin' via golang-nuts
Is it valid to say `import "github.com\foo\bar" (windows path
separators) or must it be "github.com/foo/bar"?  I couldn't find a
canonical answer to this.

Thanks

Tim

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] [ann] fsq 1.7.1 released

2017-11-10 Thread robert . upcraft
I'm happy to announce a new release of fsq.



*What is fsq?*
fsq is a BSD-licensed command line tool for querying the file system with a 
SQL-like language.  It attempts to optimize for efficient I/O when 
possible, but most of all, strives to to make it easy to write readable 
file system search queries.  For example:

 fsq "path,size in 'src' where name endswith '.go' and content contains 
'main('"



*What's new in 1.7.1?*
   
   - Searching with regular expressions is now supported with the "matches" 
   operator.
   - Prebuilt binaries use Go 1.9.

The source code, documentation, and links to pre-built binaries can be 
found on the GitHub repository: https://github.com/upcrob/fsq



-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: try to avoid additional memory allocations

2017-11-10 Thread Vasiliy Tolstov
Thanks, i know that optimization can lead obscurity, but for critical
paths i think that it useful =)

2017-11-10 8:41 GMT+03:00 peterGo :
> Vasiliy,
>
> For portability, when you initialize cfg.WorkDir, clean it: cfg.WorkDir =
> filepath.Clean(cfg.WorkDir)
>
> You can reduce the allocations from 5 to 1. However, optimization can lead
> to obscurity. For example,
>
> $ go test oid_test.go -bench=.
> BenchmarkVasiliy-4 200700 ns/op88 B/op5 allocs/op
> BenchmarkKrolaw-4  300550 ns/op80 B/op4 allocs/op
> BenchmarkPeter-4  1000201 ns/op48 B/op1 allocs/op
>
> Playground: https://play.golang.org/p/DnGoM8PYd6
>
> Peter
>
>
> On Thursday, November 9, 2017 at 3:58:03 PM UTC-5, Vasiliy Tolstov wrote:
>>
>> Hi. I have server that read/write data to many files (each is about
>> 4-32Mb). To determine on which file i need to read/write i'm use this
>> function to os.OpenFile
>>
>> func oid2filepath(cfg *Config, oID uint64) string {
>> file_path := filepath.Join(cfg.WorkDir, fmt.Sprintf("%x",
>> oid2vid(oID)), fmt.Sprintf("%016x", oID))
>> return file_path
>> }
>>
>> oid2vid function get uint32 and return uint32 with shift some bits
>> path looks like (for one of 4Mb chunk) store/obj/7c2b25/007c2b250180
>>
>> When i'm write 4Gb data i need to call this function 1024 times for
>> single big chunk of data.
>> Does it possible to write function that does not have additional
>> allocations?
>> And does it possible to write it in portable way (i mean path separator).
>>
>>
>> --
>> Vasiliy Tolstov,
>> e-mail: v.to...@selfip.ru
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
Vasiliy Tolstov,
e-mail: v.tols...@selfip.ru

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: try to avoid additional memory allocations

2017-11-10 Thread Vasiliy Tolstov
Thanks!

2017-11-10 3:52 GMT+03:00 krolaw :
> func oid2filepath(cfg *Config, oID uint64) string {
>return fmt.Sprintf("%s%c%x%c%016x", cfg.WorkDir, filepath.Seperator,
> oid2vid(oID), filepath.Seperator, oID)
> }
>
> On Friday, 10 November 2017 09:58:03 UTC+13, Vasiliy Tolstov wrote:
>>
>> Hi. I have server that read/write data to many files (each is about
>> 4-32Mb). To determine on which file i need to read/write i'm use this
>> function to os.OpenFile
>>
>> func oid2filepath(cfg *Config, oID uint64) string {
>> file_path := filepath.Join(cfg.WorkDir, fmt.Sprintf("%x",
>> oid2vid(oID)), fmt.Sprintf("%016x", oID))
>> return file_path
>> }
>>
>> oid2vid function get uint32 and return uint32 with shift some bits
>> path looks like (for one of 4Mb chunk) store/obj/7c2b25/007c2b250180
>>
>> When i'm write 4Gb data i need to call this function 1024 times for
>> single big chunk of data.
>> Does it possible to write function that does not have additional
>> allocations?
>> And does it possible to write it in portable way (i mean path separator).
>>
>>
>> --
>> Vasiliy Tolstov,
>> e-mail: v.to...@selfip.ru
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
Vasiliy Tolstov,
e-mail: v.tols...@selfip.ru

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] What are Parse Html token methods for email templates in golang?

2017-11-10 Thread Marvin Renich
* Josh Kamau  [171110 03:47]:
> You can use 'with'  to achieve what you want.
> Take a look at this example
> 
> https://play.golang.org/p/incDGEmUJK
> 
> On Wed, Nov 8, 2017 at 12:03 PM,  wrote:
> > I could not found such token system in golang or any library supporting
> > such format. Can anyone please tell how can I achieve to create such
> > tokens. There should be no dot before the attribue. either it should be
^^
> > only the attribute like {{Name}} or like {{ test.name }}.

This is not how the template package works.  You must use the dot to
signify that the name comes from the data supplied to the Execute method
(e.g. a field, key, or method of the data).  An identifier without a
preceding dot is either a keyword used to specify an action (e.g. if,
range, or with), or a function name.

You can use {{.test.name}}, or you can use {{with .test}} and then
{{.name}} as Josh shows above.

It is unclear if you have found the correct documentation, where this is
described.  In the documentation at [1], which describes things specific
to html/template, the second paragraph in the Overview directs you to
[2], which describes the text/template package, which is the basis for
the html/template package.

In the text/template documentation, see Actions[3] and Arguments[4] for
more details about what items require a preceding dot.

If you want a much simpler templating system, which only allows simple
substitutions and does not require the dot, it would be a fairly easy
package to write.

...Marvin

[1] https://golang.org/pkg/html/template/
[2] https://golang.org/pkg/text/template/
[3] https://golang.org/pkg/text/template/#hdr-Actions
[4] https://golang.org/pkg/text/template/#hdr-Arguments

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] network programming about go

2017-11-10 Thread 2891132love
I try to change the IP address and close the software related,but it 
sometimes still can't run sucessfully.Sometimes it can run parts of the 
result I hope to see.It shows that the client can connect with the server 
but the server can't connect the client and get the message.

在 2017年11月7日星期二 UTC+8下午3:22:44,Karan Chaudhary写道:
>
> Is the port 5000 on 192.168.153.239 open?  If it is open,  is your server 
> running on that port?
>
>
> https://stackoverflow.com/questions/2972600/no-connection-could-be-made-because-the-target-machine-actively-refused-it
>
> On Monday, 6 November 2017 19:30:22 UTC+5:30, 28911...@gmail.com wrote:
>>
>> I try to modify the program,but the result is: host:portfatal error: dial 
>> tcp 192.168.153.239:5000: connectex: No connection could be made because 
>> the target machine actively refused it.exit status 1.How to solve it??
>>
>> 在 2017年11月6日星期一 UTC+8下午5:08:26,rog写道:
>>
>>> On 30 October 2017 at 06:55,  <28911...@gmail.com> wrote: 
>>> > I write this code in the follwings: 
>>> > package main 
>>> > 
>>> > import ( 
>>> > "fmt" 
>>> > "net" 
>>> > "os" 
>>> > ) 
>>> > 
>>> > func main() { 
>>> > service := ":5000" 
>>> > tcpAddr, err := net.ResolveTCPAddr("tcp", service) 
>>> > checkError(err) 
>>> > listener, err := net.ListenTCP("tcp", tcpAddr) 
>>> > checkError(err) 
>>> > for i := 0; i < 10; i++ { 
>>> > conn, err := listener.Accept() 
>>> > if err != nil { 
>>> > continue 
>>> > } 
>>> > handleClient(conn) 
>>> > conn.Close() 
>>> > } 
>>> > } 
>>> > func handleClient(conn net.Conn) { 
>>> > var buf [512]byte 
>>> > for { 
>>> > n, err := conn.Read(buf[0:]) 
>>> > if err != nil { 
>>> > return 
>>> > } 
>>> > rAddr := conn.RemoteAddr() 
>>> > fmt.Println("receive from client", rAddr.String(), string(buf[0:n])) 
>>> > _, err2 := conn.Write([]byte("welcome client!")) 
>>> > if err2 != nil { 
>>> > return 
>>> > } 
>>> > } 
>>> > } 
>>> > func checkError(err error) { 
>>> > if err != nil { 
>>> > fmt.Fprintf(os.Stderr, "fatal error: %s", err.Error()) 
>>> > os.Exit(1) 
>>> > } 
>>> > } 
>>> > 
>>> > 
>>> > I try to run it in Sublime Text3 but it has no reaction and I try to 
>>> run it 
>>> > in running windows, it shows: 
>>> > fatal error: lsiten tcp:5000:bind:Only one usage of each socket 
>>> > address(protocol/network address/port) is normally permitted.exit 
>>> status 1 
>>>
>>> From that error message, I suspect that you already have a running 
>>> instance 
>>> of your program - as the message says, you are only allowed to listen 
>>> on a port once. 
>>>
>>> To avoid that, you could listen on port zero, which will choose an 
>>> arbitrary 
>>> port (but then you'll need to print out the port number so that you can 
>>> know which port to use on the client). 
>>>
>>> By the way, your code is a little bit more complex than 
>>> it needs to be. Instead of this: 
>>>
>>> > service := ":5000" 
>>> > tcpAddr, err := net.ResolveTCPAddr("tcp", service) 
>>> > checkError(err) 
>>> > listener, err := net.ListenTCP("tcp", tcpAddr) 
>>>
>>> You could do: 
>>>
>>> service := ":5000" 
>>> listener, err := net.Listen("tcp", tcpAddr) 
>>>
>>> Similarly when dialing - there's no need to call ResolveTCPAddr 
>>> explicitly (and it's actually not as good if you do that, 
>>> because Dial will automatically use multiple IP addresses 
>>> if it needs to, but if you use ResolveTCPAddr, it can only use one). 
>>>
>>> Hope this helps, 
>>>
>>>   rog. 
>>>
>>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Scaleway

2017-11-10 Thread tactician
Hi Rene,

Many thanks for your response.
First part works, i.e. looks like I downloaded Go.

Second part am struggling with is to engage in Go .

not sure how to set the parameters, path etc.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Scaleway

2017-11-10 Thread Rene Kaufmann
If you need the newest go release:  https://golang.org/doc/install

# download the archive
wget https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-amd64.tar.gz

# extract it to /usr/local
sudo tar -C /usr/local -xzf go1.9.2.linux-amd64.tar.gz

# add /usr/local/go/bin to your path
echo 'export PATH=$PATH:/usr/local/go/bin' >> $HOME/.profile

You can also install go with your package manager (version 1.6 if you are 
on ubuntu 16.04):
- sudo apt-get install golang-go

On Friday, November 10, 2017 at 12:28:42 PM UTC+1, tactician wrote:
>
> Thank you Mauricio.
>>
>Two points - 
>I do NOT wish to use docker - this would be counter performant 
>I do not understand your reply. I have bash, and cannot download 
> http.
> It seems setting up relies on prior knowledge of linux code, which I do 
> not possess.
> I need a set up Go on scaleway for dummies approach
>
>  
>>
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Scaleway

2017-11-10 Thread tactician

>
> Thank you Mauricio.
>
   Two points - 
   I do NOT wish to use docker - this would be counter performant 
   I do not understand your reply. I have bash, and cannot download 
http.
It seems setting up relies on prior knowledge of linux code, which I do not 
possess.
I need a set up Go on scaleway for dummies approach

 
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Update Mongodb fields with omitempty flag in Golang structure

2017-11-10 Thread Amandeep Kaur
Thanks @Diego Medina  It worked for me.

On Thursday, November 9, 2017 at 12:19:14 AM UTC+5:30, Diego Medina wrote:
>
> replied on the mgo list 
>
> https://groups.google.com/d/topic/mgo-users/F3LbWdyPGDc/discussion
>
> (pasted here to save a click)
>
> Hi,
>
> > the checkbox is unchecked and form is submitted to save. Now as I have 
> applied "omitempty" 
>
> if the checkbox is unchecked, your client side code should send "false" to 
> the go server, so omitempty is not applied because it is not empty, it is 
> false, so saving it to mongo will actually update the field.
>
> for truly optional fields, what I do is, declare the fields as pointers to 
> the type, so, you would have
>
> type Coupon struct {
> Id   *int`json:"id,omitempty" bson:"_id,omitempty"`
> Name *string `json:"name,omitempty" bson:"name,omitempty"`
> Code *string `json:"code,omitempty" bson:"code,omitempty"`
> Description  *string `json:"description,omitempty" 
> bson:"description,omitempty"`
> Status   *bool   `json:"status" bson:"status"`// I assume this 
> is also optional
> MaxUsageLimit*int`json:"max_usage_limit,omitempty" 
> bson:"max_usage_limit,omitempty"`
> SingleUsePerUser *bool   `json:"single_use_per_user,omitempty" 
> bson:"single_use_per_user,omitempty"`
> }
>
>
> the bson/json Un/marshaller will then omit the values that are nil 
> pointers, so now yo ucan tell the difference between a false checkbox, and 
> a REST POST that did not include the field at all
>
> Hope this helps.
>
> Diego
>
> On Wednesday, November 8, 2017 at 12:46:39 AM UTC-5, Amandeep Kaur wrote:
>>
>>
>> Hi
>>
>> I am working on a Coupon form in which I have some optional fields. 
>>
>> *Introduction:*
>>
>> All the form field values are received as JSON and mapped into a Golang 
>> structure. In the structure, I have added an "omitempty" flag with every 
>> field. So only those form values are mapped which have some appropriate 
>> value, rest of the values like 0, " ", false are ignored by the structure.
>>
>> Here is the Golang structure
>>
>> type Coupon struct {
>> Id   int`json:"id,omitempty" bson:"_id,omitempty"`
>> Name string `json:"name,omitempty" bson:"name,omitempty"`
>> Code string `json:"code,omitempty" bson:"code,omitempty"`
>> Description  string `json:"description,omitempty" 
>> bson:"description,omitempty"`
>> Status   bool   `json:"status" bson:"status"`
>> MaxUsageLimitint`json:"max_usage_limit,omitempty" 
>> bson:"max_usage_limit,omitempty"`
>> SingleUsePerUser bool   `json:"single_use_per_user,omitempty" 
>> bson:"single_use_per_user,omitempty"`}
>>
>> *Problem:*
>>
>>1. 
>>
>>When I save this form for the very first time, the form values that 
>>are appropriate are saved into the Mongodb.
>>2. 
>>
>>Now I want to update that form and suppose there is a check box, 
>>which was checked at the time of saving data. While updating form, the 
>>checkbox is unchecked and form is submitted to save. Now as I have 
>> applied 
>>"omitempty" flag in the structure, so its not mapping the empty value to 
>>the checkbox field. Since the value is not mapped into the structure, its 
>>not getting saved into the Database. 
>>3. 
>>
>>When a user edits the form for the second time, it sees the same 
>>check box as checked. (But practically, the value should be updated to 
>> the 
>>DB and the check box should be displayed as unchecked.)
>>4. 
>>
>>I am using the same form data (in JSON format) in a REST API. In API, 
>>while updating form data, if I mention only those values which are 
>> required 
>>and don't pass the values which I don't want to update, then MongoDB is 
>>overriding the whole document with the provided required values(Even 
>> those 
>>values are also being overridden which I don't want to update as well as 
>>don't pass in the API).
>>
>> *Requirement:*
>>
>> In future, I want to expose the REST API, So I don't want this thing to 
>> be happened there. That is why I don't want to remove "omitempty" flag from 
>> the structure fields. 
>>
>> Is there any way to save the empty form values or API data fields to the 
>> DB while using omitempty flag in the structure?
>>
>> Thanks!
>>
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] What are Parse Html token methods for email templates in golang?

2017-11-10 Thread Josh Kamau
You can use 'with'  to achieve what you want.

Take a look at this example

https://play.golang.org/p/incDGEmUJK

I have to say your question is not clear and i just guessed what you want.

Thanks.
Josh

On Wed, Nov 8, 2017 at 12:03 PM,  wrote:

> Hi everyone,
>
> I am trying to create email templates having html tokens in golang. I have
> searched all over the web and found
>
> "html/template"
>
> library. It supports token format like below
>
> Hello {{.Name}}
>Confirm email address
>
> But the requirement for html token is something like
> Name: {{ test.name }}
> Phone: {{ test.phone }}
> Address: {{ test.address }}, {{ test.city }}, {{ test.state }} {{ test.zip
> }}
>
> I could not found such token system in golang or any library supporting
> such format. Can anyone please tell how can I achieve to create such
> tokens. There should be no dot before the attribue. either it should be
> only the attribute like {{Name}} or like {{ test.name }}.
>
> Thank you!
>
> --
> 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+unsubscr...@googlegroups.com.
> 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Go predicts the end of the universe

2017-11-10 Thread Hal
Go predicts the end of the time, i.e. the end of the universe 

https://play.golang.org/p/THHvbdo_IS

package main


import (
 "fmt"
 "math"
 "time"
)


func main() {
 endOfTheTime := time.Unix(math.MaxInt64,81394542089).UTC()
 fmt.Println(endOfTheTime.String())
}

Hal

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.