[go-nuts] Re: Debugging in Go seems to be a very difficult task to accomplish

2016-11-14 Thread Nyah Check
Hi Gophers,

I know this post is old and there's a lot online with different sometimes 
contrasting opinions on how to debug go programs. My question given the 
complexities involved in multi-threading in Go does the go team have any 
plans on creating a standard debugger. I'm currently looking at delve and 
gdb(although inadequate). What's the best way of debugging go programs so 
far. I know some may say use intelligently placed fmt.Printf() statements. 
Just looking for more ideas.

Thanks,
Nyah

-- 
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: [ANN] lint - Run linters as part of go test

2016-11-14 Thread Dobrosław Żybort
Neat idea.
Just some random thought: instead of adding all linters by hand maybe you 
could use what gometalinter already provide?
https://github.com/alecthomas/gometalinter

W dniu poniedziałek, 14 listopada 2016 14:27:26 UTC+1 użytkownik 
sri...@laddoo.net napisał:
>
> Hi,
>
> I'd like to announce a library I just released called lint [1]. It allows 
> you to run a variety of linters as part of go test. It also supports 
> whitelisting false positives. It reduces the need for build scripts, makes 
> CI integration easy and lets projects enforce linter usage without extra 
> scripts. I built it while working on our mobile app (which is written in 
> Go) and have found it useful so far.
>
> The below example test will check for gofmt usage, run go tool vet 
> --shadow, golint, errcheck, gosimple and gostaticcheck
>
> import (
> "testing"
> "github.com/surullabs/lint"
> ) 
>
>
> func TestLint(t *testing.T) {
> if err := lint.Default.Check("./..."); err != nil {
> t.Fatal("lint failures: %v", err)
> }
> }
>
> Please let me know if you find this useful and if you'd like any features 
> added/removed/modified.
>
> Thanks!
> Sridhar
>
> [1] https://www.timeferret.com/lint
>
>

-- 
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: htmltest – tests generated HTML for problems, new project

2016-11-14 Thread Egor Smolyakov
Recommend to see this project -- http://www.validity.org.uk/

понедельник, 14 ноября 2016 г., 22:51:25 UTC+2 пользователь Will Pimblett 
написал:
>
> Hi,
>
> This is a bit of a general post, not really a precise question. I've built 
> a go application to test the validity of generated HTML markup (the sort 
> you'd make with a static site generator, like Hugo or Jekyll) based loosely 
> on an existing ruby gem html-proofer. It runs files through a series of 
> checks to ensure all links, images, and scripts references work, alt tags 
> are filled in,  Rather useful in a static site CD pipeline. I've toyed 
> around with Go previously but never built anything with it, this is my 
> first 'real' project.
>
> I'm posting here to advertise it to those who may find it useful, and if 
> anyone is willing: to garner feedback over the codebase. I've tried to pick 
> up as many Go idioms as possible but will surely have made many mistakes.
>
> https://github.com/wjdp/htmltest
>
> Cheers,
> Will
>

-- 
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 assembly support shifted operands?

2016-11-14 Thread william . wei . xiao
Do you have plan to restore them back for reducing code size?

On Tuesday, November 15, 2016 at 5:19:56 AM UTC+8, Aram Hăvărneanu wrote:
>
> They used to be supported but I think I dropped them with the old C 
> assembler. 
>
> -- 
> Aram Hăvărneanu 
>

-- 
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: Using EasyJSON with Golang

2016-11-14 Thread Tyler Compton
It looks like someone on Stack Overflow has answered your question[1].

You know your needs better than I do, but code generation seems like an 
unnecessarily complex way to unmarshal JSON code. I'd recommend taking a 
look at encoding/json[2] if you haven't already .

1. http://stackoverflow.com/a/40588324
2. http://golang.org/pkg/encoding/json

On Monday, November 14, 2016 at 4:41:50 AM UTC-7, DM wrote:
>
> Crossposting this from stackoverflow 
> :-
>
> Let's say I have a struct like below:-
>
> //easyjson:json
> type JSONData struct {
> Data []string}
>
> I want to un-marshal the below json to JSONData struct
>
> {"Data" : ["One", "Two", "Three"]} 
>
> Can someone let me know how can I use easyjson 
>  to un-marshal a json in Golang? I 
> could not find any example in their README
>

-- 
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: [ANN] Go geospatial libraries: geometries, GeoJSON, WKB, KML, PostGIS, GPX, polyline

2016-11-14 Thread Daniel Whitenack
Thanks Tom! I think it would be great to add a few of these here:

https://github.com/gopherds/resources/tree/master/tooling

where you think it is appropriate.  Would you consider submitting a PR with 
some additions?

Daniel

On Sunday, November 13, 2016 at 1:33:27 PM UTC-5, Tom Payne wrote:
>
> A quick announce of a few libraries for geospatial applications that are 
> now mature and battle-tested:
>
> https://github.com/twpayne/go-geom : efficient geometry library, using a 
> high-performance cache-friendly data representation (more info 
> ), with 
> import and export from multiple formats 
>  (e.g. GeoJSON, 
> WKB, KML) and many 2D geometry functions 
> . Really easy PostGIS 
> integration with database/sql 
> 
> .
>
> 
> https://github.com/twpayne/go-kml : generate KML files quickly and 
> flexibly.
>
> 
> https://github.com/twpayne/go-gpx : read and write GPX files.
>
> 
> https://github.com/twpayne/go-polyline : encode and decode data to/from 
> Google Maps Polyline format.
>
> I think that go-geom's internal data representation 
>  is a nice 
> example of high performance Go code and a reasonable attempt at practical 
> code while the language does not support generics.
>
> All feedback welcome!
>

-- 
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 assembly support shifted operands?

2016-11-14 Thread Michael Hudson-Doyle
It doesn't look like they're supported on arm64 though. File a bug?

Cheers,
mwh


> On 15 November 2016 at 06:26, Rob Pike  wrote:

> They are supported. Please read the ARM section of golang.org/doc/asm.html
> to see the syntax.
>
>
> On Sunday, November 13, 2016, wei.x...@arm.com 
> wrote:
>
>> I'm trying to rewrite following two ARM64 assembly instructions into
>> GoLang assembly instructions
>> add x0, x3, x6, lsr #1
>> neg x4, x4, lsl #1
>>
>> But it seems that GoLang ARM64 assembly don't support shifted operands.
>> So i need to write following 4 GoLang assembly instructions?
>> LSL $1, R4, R4
>> NEG R4, R4
>> LSR $1, R6, R6
>> ADD R6, R3, R0
>>
>>
>> My question is: GoLang assembly support shifted operands?
>>
>>
>> --
>> 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.
>

-- 
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] StackImpact - pprof-based production profiler and monitor

2016-11-14 Thread dmitri
 

Hi Everyone,


This is a quick announcement of StackImpact, which is a production profiler 
and monitor partially based on pprof API. It automates profiling and 
tracing, and displays regular and anomaly-triggered profiles in a 
historically comparable form. A tracing introduced in 1.5 is used for HTTP 
handler and HTTP call bottleneck detection. StackImpact also includes 
health monitoring, anomaly alerting, and more. 


Here the package link: https://github.com/stackimpact/stackimpact-go


The main motivation behind creating StackImpact can be summarized in these 
few points:


   - To have the historical view of application hot spots and bottlenecks, 
   which is necessary for performance issue troubleshooting and optimization, 
   a regular pprof execution, interactive result analysis and comparison is 
   needed.
   - Locating and accessing the application node’s host to run the go tool 
   pprof against may be tricky in container environments such as Kubernetes.
   - Pprof’s HTTP handler, which accepts profiling requests, needs to 
   attach itself to application’s HTTP server (or have one running), which 
   means extra security measures should be taken to protect the listening port.
   - If application has crashed or is unable to respond to pprof requests, 
   no profiling is possible. However, historical profiles could be extremely 
   useful in post-mortem root cause analysis.

Here is how it works. After adding the following two lines to the 
application, the agent will start reporting profiles, traces as well as 
runtime metrics and other performance related information to the Dashboard, 
where it will be available for analysis. See screenshots here 
https://stackimpact.com/features/.


agent := stackimpact.NewAgent();
agent.Configure("agent key here", “SomeGoApp”)


This starts the agent, which runs with the app from start till the end. 
Performance information will be reported to and available in the Dashboard 
at https://stackimpact.com (or on-premise respectively)



Your feedback is welcome!


Thanks,

Dmitri

-- 
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] htmltest – tests generated HTML for problems, new project

2016-11-14 Thread Will Pimblett
Hi,

This is a bit of a general post, not really a precise question. I've built 
a go application to test the validity of generated HTML markup (the sort 
you'd make with a static site generator, like Hugo or Jekyll) based loosely 
on an existing ruby gem html-proofer. It runs files through a series of 
checks to ensure all links, images, and scripts references work, alt tags 
are filled in,  Rather useful in a static site CD pipeline. I've toyed 
around with Go previously but never built anything with it, this is my 
first 'real' project.

I'm posting here to advertise it to those who may find it useful, and if 
anyone is willing: to garner feedback over the codebase. I've tried to pick 
up as many Go idioms as possible but will surely have made many mistakes.

https://github.com/wjdp/htmltest

Cheers,
Will

-- 
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: Sub-Benchmark strange results.

2016-11-14 Thread Dave Cheney
Cool. Thanks for figuring it out and posting your answer.

On Tuesday, 15 November 2016 07:28:16 UTC+11, Evan Digby wrote:
>
> Confirmed bug on my part. 
>
> When using the "..." suffix to pass a slice into a func with variadic args 
> it passes through the the original slice, rather than constructing a new 
> one. An obvious optimization, but caused my function to act differently in 
> my tests vs. a real use case.
>
> The tests pass in "[][]int64..." whereas the code using the function 
> passes several individual slices. 
>
> The function clobbers the individual slices inside.
>
> I've now added an explicit test to validate behaviour is the same passing 
> individual args vs. breaking out a slice.
>
>
> On Saturday, 12 November 2016 12:57:07 UTC-8, Evan Digby wrote:
>>
>> I think I've eyeballed a bug in my code that *might* cause this but I 
>> won't be at a computer for a day or two to verify. I'll keep here posted!
>
>

-- 
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: Sub-Benchmark strange results.

2016-11-14 Thread Evan Digby
Confirmed bug on my part. 

When using the "..." suffix to pass a slice into a func with variadic args 
it passes through the the original slice, rather than constructing a new 
one. An obvious optimization, but caused my function to act differently in 
my tests vs. a real use case.

The tests pass in "[][]int64..." whereas the code using the function passes 
several individual slices. 

The function clobbers the individual slices inside.

I've now added an explicit test to validate behaviour is the same passing 
individual args vs. breaking out a slice.


On Saturday, 12 November 2016 12:57:07 UTC-8, Evan Digby wrote:
>
> I think I've eyeballed a bug in my code that *might* cause this but I 
> won't be at a computer for a day or two to verify. I'll keep here posted!

-- 
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 assembly support shifted operands?

2016-11-14 Thread Rob Pike
They are supported. Please read the ARM section of golang.org/doc/asm.html
to see the syntax.

On Sunday, November 13, 2016, wei.x...@arm.com 
wrote:

> I'm trying to rewrite following two ARM64 assembly instructions into
> GoLang assembly instructions
> add x0, x3, x6, lsr #1
> neg x4, x4, lsl #1
>
> But it seems that GoLang ARM64 assembly don't support shifted operands.
> So i need to write following 4 GoLang assembly instructions?
> LSL $1, R4, R4
> NEG R4, R4
> LSR $1, R6, R6
> ADD R6, R3, R0
>
>
> My question is: GoLang assembly support shifted operands?
>
>
> --
> 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.


Re: [go-nuts] Stressing the system using

2016-11-14 Thread Michael Jones
Benchmark a call to math.Sqrt(). It is easy. Here is all it takes:

https://play.golang.org/p/1XZJsjhpIq

 

In the assembly output of “go test -v -run=Q -bench=. -gcflags=-S” you can see 
the SQRT instruction:

 

babar:sqrt mtj$ go test -v -run=Q -bench=. -gcflags=-S

# sqrt

"".BenchmarkSqrt t=1 size=59 args=0x8 locals=0x0

    0x 0 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:10)   
  TEXT    "".BenchmarkSqrt(SB), $0-8

    0x 0 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:10)   
  FUNCDATA  $0, gclocals·a36216b97439c93dafebe03e7f0808b5(SB)

    0x 0 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:10)   
  FUNCDATA  $1, gclocals·33cdeebe80329f1fdbee7f5874cb(SB)

    0x 0 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:11)   
  MOVQ "".b+8(FP), AX

    0x0005 5 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:11)   
  MOVQ $0, CX

    0x0007 7 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:11)   
  MOVQ 216(AX), DX

    0x000e 00014 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:11)   
  CMPQ  CX, DX

    0x0011 00017 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:11)   
  JGE  $0, 58

    0x0013 00019 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:12)   
  MOVSD   "".A(SB), X0

    0x001b 00027 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:12)   
  SQRTSD  X0, X1

    0x001f 00031 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:12)   
   ADDSD X1, X0

    0x0023 00035 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:12)   
  MOVSD   X0, "".A(SB)

    0x002b 00043 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:11)   
  INCQ    CX

    0x002e 00046 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:11)   
  MOVQ 216(AX), DX

    0x0035 00053 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:11)   
  CMPQ  CX, DX

    0x0038 00056 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:11)   
  JLT   $0, 19

    0x003a 00058 (/Users/mtj/gocode/src/sqrt/sqrt_test.go:14)   
  RET

 

And the output shows you the time per iteration:

 

babar:sqrt mtj$ go test -v -run=Q -bench=.

BenchmarkSqrt-8    1      10.9 ns/op

PASS

ok    sqrt  1.113s

 

An empty loop is about 0.75 ns/iteration, so that means:

 

One square root requires about 10.2 nanoseconds to execute. (on my laptop 
computer)

 

In your hogcpu() function, you have a loop containing a select and a sqrt(). So 
that means:

 

If select can be implemented in 10.2 nsec, then you’ll be 50% select and 50% 
sqrt.

If 100 nsec, then you’ll be 90.7% select

if 1000 nsec, then it will be 98.99% select

:

 

there are many ways to implement a non-blocking channel, but not many that are 
faster than 10.2 nanoseconds.

 

 

From:  on behalf of 
Date: Monday, November 14, 2016 at 6:23 AM
To: golang-nuts 
Cc: 
Subject: Re: [go-nuts] Stressing the system using

 

Why would a select statement take up most of the execution time? 

 

Is there another way to implement a non blocking channel?


On Monday, November 14, 2016 at 6:01:24 PM UTC+5:30, Michael Jones wrote:

This is funny in the sense that my programs are great at stressing the CPU even 
though I don’t want to! :-) 

 

I looked at your hogcpu() function and saw an issue: you busy loop repeats a 
select statement and a square root. Almost any simple implementation of this 
will spend all of its time in the select. Put a loop around that math.Sqrt() so 
that the “hog” routine is doing mostly sqrt() and not mostly select. DO 
something similar for the hogio and other hog functions.

 

From:  on behalf of 
Date: Monday, November 14, 2016 at 4:06 AM
To: golang-nuts 
Subject: [go-nuts] Stressing the system using

 

I have been working on this applications to stress the cpu, io and the hard 
drive.

 

https://github.com/vyasgiridhar/gstress

 

Kind of like stress. But i am unable to achieve high load. This might be due to 
the scheduling of goroutines.

Is there a work around for 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...@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] Re: Rendering absolute URLs for a hypermedia API

2016-11-14 Thread paraiso . marc
With gorilla/mux you can use named routes :

r := mux.NewRouter() r.HandleFunc("/articles/{category}/{id:[0-9]+}", 
ArticleHandler). Name("article")
url, err := r.Get("article").URL("category", "technology", "id", "42")



Le lundi 14 novembre 2016 17:34:26 UTC+1, to...@hypr.nz a écrit :
>
> I believe I have done enough research (and attempts) that this should be 
> an easy answer: either it doesn't work that way or I've missed something 
> simple! Fingers crossed and thanks in advance.
>
> My goal is to render absolute URLs for my API—I can't get route libraries 
> (eg gorilla/mux) to do this even though they look to be able to do so.
>
> The first question, to render absolute URLs by reversing a route name, 
> which library should I really be using? I'm assuming one that hooks into 
> the http.Request, such as, gorilla/mux.
>
> Given I use gorilla/mux, how? I see in the source that it requires a Host 
> to be setting in the route registration but upon registration of a Host, it 
> never matches a route again. (I can't find a solution to this either which 
> suggests that I have something wrong in my thinking).
>
> I hope this is descriptive enough to know whether I am way off the mark or 
> need to provide more, detailed information.
>
> Thanks. Todd.
>

-- 
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] Rendering absolute URLs for a hypermedia API

2016-11-14 Thread todd
I believe I have done enough research (and attempts) that this should be an 
easy answer: either it doesn't work that way or I've missed something 
simple! Fingers crossed and thanks in advance.

My goal is to render absolute URLs for my API—I can't get route libraries 
(eg gorilla/mux) to do this even though they look to be able to do so.

The first question, to render absolute URLs by reversing a route name, 
which library should I really be using? I'm assuming one that hooks into 
the http.Request, such as, gorilla/mux.

Given I use gorilla/mux, how? I see in the source that it requires a Host 
to be setting in the route registration but upon registration of a Host, it 
never matches a route again. (I can't find a solution to this either which 
suggests that I have something wrong in my thinking).

I hope this is descriptive enough to know whether I am way off the mark or 
need to provide more, detailed information.

Thanks. Todd.

-- 
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] GoLang assembly support shifted operands?

2016-11-14 Thread wei.x...@arm.com
I'm trying to rewrite following two ARM64 assembly instructions into GoLang 
assembly instructions
add x0, x3, x6, lsr #1
neg x4, x4, lsl #1

But it seems that GoLang ARM64 assembly don't support shifted operands.
So i need to write following 4 GoLang assembly instructions?
LSL $1, R4, R4
NEG R4, R4
LSR $1, R6, R6
ADD R6, R3, R0


My question is: GoLang assembly support shifted operands?


-- 
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] Stressing the system using

2016-11-14 Thread vyasgiridhar27
Why would a select statement take up most of the execution time? 

Is there another way to implement a non blocking channel?

On Monday, November 14, 2016 at 6:01:24 PM UTC+5:30, Michael Jones wrote:
>
> This is funny in the sense that my programs are great at stressing the CPU 
> even though I don’t want to! :-) 
>
>  
>
> I looked at your hogcpu() function and saw an issue: you busy loop repeats 
> a select statement and a square root. Almost any simple implementation of 
> this will spend all of its time in the select. Put a loop around that 
> math.Sqrt() so that the “hog” routine is doing mostly sqrt() and not mostly 
> select. DO something similar for the hogio and other hog functions.
>
>  
>
> *From: * on behalf of <
> vyasgir...@gmail.com >
> *Date: *Monday, November 14, 2016 at 4:06 AM
> *To: *golang-nuts 
> *Subject: *[go-nuts] Stressing the system using
>
>  
>
> I have been working on this applications to stress the cpu, io and the 
> hard drive.
>
>  
>
> https://github.com/vyasgiridhar/gstress
>
>  
>
> Kind of like stress . But i 
> am unable to achieve high load. This might be due to the scheduling of 
> goroutines.
>
> Is there a work around for 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...@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.


Re: [go-nuts] Stressing the system using

2016-11-14 Thread vyasgiridhar27
Why would a select statement take up most of the execution time? 

Is there another way to implement a non blocking channel?

On Monday, November 14, 2016 at 6:01:24 PM UTC+5:30, Michael Jones wrote:
>
> This is funny in the sense that my programs are great at stressing the CPU 
> even though I don’t want to! :-) 
>
>  
>
> I looked at your hogcpu() function and saw an issue: you busy loop repeats 
> a select statement and a square root. Almost any simple implementation of 
> this will spend all of its time in the select. Put a loop around that 
> math.Sqrt() so that the “hog” routine is doing mostly sqrt() and not mostly 
> select. DO something similar for the hogio and other hog functions.
>
>  
>
> *From: * on behalf of <
> vyasgir...@gmail.com >
> *Date: *Monday, November 14, 2016 at 4:06 AM
> *To: *golang-nuts 
> *Subject: *[go-nuts] Stressing the system using
>
>  
>
> I have been working on this applications to stress the cpu, io and the 
> hard drive.
>
>  
>
> https://github.com/vyasgiridhar/gstress
>
>  
>
> Kind of like stress . But i 
> am unable to achieve high load. This might be due to the scheduling of 
> goroutines.
>
> Is there a work around for 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...@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.


Re: [go-nuts] Stressing the system using

2016-11-14 Thread Michael Jones
This is funny in the sense that my programs are great at stressing the CPU even 
though I don’t want to! :-) 

 

I looked at your hogcpu() function and saw an issue: you busy loop repeats a 
select statement and a square root. Almost any simple implementation of this 
will spend all of its time in the select. Put a loop around that math.Sqrt() so 
that the “hog” routine is doing mostly sqrt() and not mostly select. DO 
something similar for the hogio and other hog functions.

 

From:  on behalf of 
Date: Monday, November 14, 2016 at 4:06 AM
To: golang-nuts 
Subject: [go-nuts] Stressing the system using

 

I have been working on this applications to stress the cpu, io and the hard 
drive.

 

https://github.com/vyasgiridhar/gstress

 

Kind of like stress. But i am unable to achieve high load. This might be due to 
the scheduling of goroutines.

Is there a work around for 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.


-- 
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] Stressing the system using

2016-11-14 Thread vyasgiridhar27


I have been working on this applications to stress the cpu, io and the hard 
drive.


https://github.com/vyasgiridhar/gstress


Kind of like stress . But i am 
unable to achieve high load. This might be due to the scheduling of 
goroutines.

Is there a work around for 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] Using EasyJSON with Golang

2016-11-14 Thread Debraj Manna
Crossposting this from stackoverflow
:-

Let's say I have a struct like below:-

//easyjson:json
type JSONData struct {
Data []string}

I want to un-marshal the below json to JSONData struct

{"Data" : ["One", "Two", "Three"]}

Can someone let me know how can I use easyjson
 to un-marshal a json in Golang? I
could not find any example in their README

-- 
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: Exported singleton in vendor is initialized on every call

2016-11-14 Thread Rayland
Thank you!

On Monday, November 14, 2016 at 11:00:36 AM UTC+2, pierre...@gmail.com 
wrote:
>
> Hello,
>
> You shadow your DB global variable in the DB, err := gorm.Open() call.
> Do something like this instead:
> var err error
> DB, err = gorm.Open()
>
>
>
> Le lundi 14 novembre 2016 09:54:40 UTC+1, Rayland a écrit :
>>
>> Greetings fellow gophers,
>>
>> I have a library in my vendor folder that looks like this:
>>
>> package gorm
>>
>> import (
>>"fmt"
>>"github.com/jinzhu/gorm"
>>_ "github.com/jinzhu/gorm/dialects/mysql"
>>conf "github.com/spf13/viper"
>>"math/rand"
>>"time"
>> )
>>
>> var DB *gorm.DB
>>
>> func GetDB() (*gorm.DB, error) {
>>if DB != nil {
>>   return DB, nil
>>}
>>
>>DB_NAME := conf.GetString("db.sql.mysql.dbname")
>>DB_USERNAME := conf.GetString("db.sql.mysql.username")
>>DB_PASSWORD := conf.GetString("db.sql.mysql.password")
>>DB_IPS := conf.GetStringSlice("db.sql.mysql.ips")
>>ipsNr := len(DB_IPS)
>>
>>rand.Seed(int64(time.Now().Nanosecond()))
>>
>>connString := 
>> fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=latin1=True",
>>   DB_USERNAME,
>>   DB_PASSWORD,
>>   DB_IPS[rand.Intn(ipsNr)],
>>   DB_NAME,
>>)
>>
>>DB, err := gorm.Open("mysql", connString)
>>if err != nil {
>>   return nil, err
>>}
>>
>>return DB, nil
>> }
>>
>>
>> And every time I use GetDB() I get a new database connection instead of 
>> getting the one already initialized. 
>>
>> When I do the same thing outside the vendor folder it works as intended.
>>
>> What's the catch here?
>>
>>
>> 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.


[go-nuts] Re: Exported singleton in vendor is initialized on every call

2016-11-14 Thread pierre . curto
Hello,

You shadow your DB global variable in the DB, err := gorm.Open() call.
Do something like this instead:
var err error
DB, err = gorm.Open()



Le lundi 14 novembre 2016 09:54:40 UTC+1, Rayland a écrit :
>
> Greetings fellow gophers,
>
> I have a library in my vendor folder that looks like this:
>
> package gorm
>
> import (
>"fmt"
>"github.com/jinzhu/gorm"
>_ "github.com/jinzhu/gorm/dialects/mysql"
>conf "github.com/spf13/viper"
>"math/rand"
>"time"
> )
>
> var DB *gorm.DB
>
> func GetDB() (*gorm.DB, error) {
>if DB != nil {
>   return DB, nil
>}
>
>DB_NAME := conf.GetString("db.sql.mysql.dbname")
>DB_USERNAME := conf.GetString("db.sql.mysql.username")
>DB_PASSWORD := conf.GetString("db.sql.mysql.password")
>DB_IPS := conf.GetStringSlice("db.sql.mysql.ips")
>ipsNr := len(DB_IPS)
>
>rand.Seed(int64(time.Now().Nanosecond()))
>
>connString := 
> fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=latin1=True",
>   DB_USERNAME,
>   DB_PASSWORD,
>   DB_IPS[rand.Intn(ipsNr)],
>   DB_NAME,
>)
>
>DB, err := gorm.Open("mysql", connString)
>if err != nil {
>   return nil, err
>}
>
>return DB, nil
> }
>
>
> And every time I use GetDB() I get a new database connection instead of 
> getting the one already initialized. 
>
> When I do the same thing outside the vendor folder it works as intended.
>
> What's the catch here?
>
>
> 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.


[go-nuts] Exported singleton in vendor is initialized on every call

2016-11-14 Thread Rayland
Greetings fellow gophers,

I have a library in my vendor folder that looks like this:

package gorm

import (
   "fmt"
   "github.com/jinzhu/gorm"
   _ "github.com/jinzhu/gorm/dialects/mysql"
   conf "github.com/spf13/viper"
   "math/rand"
   "time"
)

var DB *gorm.DB

func GetDB() (*gorm.DB, error) {
   if DB != nil {
  return DB, nil
   }

   DB_NAME := conf.GetString("db.sql.mysql.dbname")
   DB_USERNAME := conf.GetString("db.sql.mysql.username")
   DB_PASSWORD := conf.GetString("db.sql.mysql.password")
   DB_IPS := conf.GetStringSlice("db.sql.mysql.ips")
   ipsNr := len(DB_IPS)

   rand.Seed(int64(time.Now().Nanosecond()))

   connString := 
fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=latin1=True",
  DB_USERNAME,
  DB_PASSWORD,
  DB_IPS[rand.Intn(ipsNr)],
  DB_NAME,
   )

   DB, err := gorm.Open("mysql", connString)
   if err != nil {
  return nil, err
   }

   return DB, nil
}


And every time I use GetDB() I get a new database connection instead of 
getting the one already initialized. 

When I do the same thing outside the vendor folder it works as intended.

What's the catch here?


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.