[go-nuts] Why Go has only slice and map

2022-04-12 Thread 'Jack Li' via golang-nuts
Hi group,


Why Go provides only 2 built-in data structures, slice and map. It has just 
more than C, but less than all other programming languages I've heard of, C++, 
Python, Swift, Rust.


I think this simplicity attracts me very much. Sometimes I can use only one 
data structures for a task.Because there is no more similar data 
structures for choice. It's really "one way to do one thing". This also makes 
code like familiar and consistent.


I want to know more about the mind behind this design of built-in data 
structures.



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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/tencent_7D168C1B263BF2B862B18796F28F82753009%40qq.com.


Re: [go-nuts] float exactness

2022-04-09 Thread 'Jack Li' via golang-nuts
Thanks Robert,


It is great!


a, _ := decimal.NewFromString("0.1")
b, _ := decimal.NewFromString("0.2")
c := a.Add(b)
fmt.Println("decimal:", c)


a = decimal.NewFromFloat(0.1)
b = decimal.NewFromFloat(0.2)
c = a.Add(b)
fmt.Println("decimal:", c)


a, _ = decimal.NewFromString("0.1")
b, _ = decimal.NewFromString("0.35")
c = a.Add(b)
fmt.Println("decimal:", c)


a = decimal.NewFromFloat(0.1)
b = decimal.NewFromFloat(0.35)
c = a.Add(b)
fmt.Println("decimal:", c)



/*
$ go build  ./main
decimal: 0.3
decimal: 0.3
decimal: 0.45
decimal: 0.45
$

*/




--Original--
From: "Robert Engels"https://groups.google.com/d/msgid/golang-nuts/tencent_327903B1334351F91FC17D18F2C6E1937508%40qq.com.
 
 

 -- 
 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.
 To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/A7E20597-1DED-4666-BAFA-7F5F79F43A0E%40ix.netcom.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/tencent_B33EB1034311F99BC168183BC67393717908%40qq.com.


[go-nuts] float exactness

2022-04-09 Thread 'Jack Li' via golang-nuts
Hi group,


1.
Is there a package can do exact float operations, like Decimal in Python? For 
example:


x := 0.1; y := 0.2; z := x + y;


z will be exact 0.3


2.
Why literal operation is exact, variable is not?


fmt.Println(0.1 + 0.2) // 0.3 exactly


fmt.Println(x + y) // 0.30004




Thanks




func main() {
x := 0.1
y := 0.2
fmt.Println("x + y :", x  + y)
fmt.Println("literal:", 0.1 + 0.2)


x = 0.1
y = 0.35
fmt.Println("x + y :", x  + y)
fmt.Println("literal:", 0.1 + 0.35)
}


/*
$ go build  ./main
x + y : 0.30004
literal: 0.3
x + y : 0.44996
literal: 0.45
$
*/




// Python:


//  0.1 + 0.2
// 0.30004


//  float(Decimal('0.1') + Decimal('0.2'))
// 0.3
// 


//  0.35 + 0.1
// 0.44996


//  float(Decimal('0.35') + Decimal('0.1'))
// 0.45
// 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/tencent_327903B1334351F91FC17D18F2C6E1937508%40qq.com.


Re:[go-nuts] Re: MaxDiskSize MaxLogCount for glog?

2022-04-09 Thread 'Jack Li' via golang-nuts
Is it still maintained? The last commit is Aug 20, 2021 which is more than half 
year ago. The last commit of glog in C++ is just 5 days ago.






--Original--
From: "peterGo"https://github.com/golang/glog#glog  



"The code in this repo is for export only and is not itself under development. 
Feature requests will be ignored."



Peter


 

 -- 
 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.
 To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/93de7324-da98-4193-9d04-cae02b740db2n%40googlegroups.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/tencent_45B1F44343F9E5C14F18B5C66E93BB796708%40qq.com.


Re: [go-nuts] Missing /usr/lib/go/pkg/include/ for native binaries

2022-04-08 Thread 'Jack Li' via golang-nuts
Yes, I download the latest go 1.18 installer for macOS from golang.google.cn. 
There's no problem with the installer from the official site.




--Original--
From: "Ian Lance Taylor"http://deb.debian.org/debian bullseye-backports/main amd64 Packages
 *** 1.17.6-1~bpo11+1 100
 100 /var/lib/dpkg/status

That's odd. File a bug report against Debian? I don't know why they
are missing.

You can of course get the header files you need by installing Go
yourself (https://go.dev/doc/install).

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUG%3DbHnYq4qGCC6ZTqhQX0WknDwvqZBTnEhm8tJ3Sbh9w%40mail.gmail.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/tencent_4192200F2E967CA8269F31780D23C4D87D05%40qq.com.


[go-nuts] MaxDiskSize MaxLogCount for glog?

2022-04-07 Thread 'Jack Li' via golang-nuts
Hi group,


I only find MaxSize in glog which sets the size of each log file.


Can glog support the options like how many disk size (ie. 10%, 1.8G, etc.) all 
the log files may use in total, and the count (ie. 10) of log files it can 
save. For example, logfile1.txt, logfile2.txt, ..., logfile10.txt. These 10 
files is 18G in total. And there is no logfile11.txt, its content will 
overwrite logfile1.txt.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/tencent_6149C23CC8588B219B7C94E0188C24E3E007%40qq.com.


Re:[go-nuts] Re: How go.work knows which module refers to which folder

2022-04-06 Thread 'Jack Li' via golang-nuts
Thanks.


I think I may get it.


If there's go.work, the `import example.com/module` will try those local 
directories in go.work first. If not found, it will try online repositories. 
And module names like this `example.com/module`, `github.com/golang/glog`, etc. 
are unique, so there will be no ambiguous. Am I thinking right?





--Original--
From:   
 "thepud...@gmail.com"  
  
From the Go workspaces reference (https://go.dev/ref/mod#workspaces) :

 A 'use' adds a module on disk to the set of main modules in a workspace. 
Its argument is a relative path to the directory containing the module’s go.mod 
file. A 'use' directive does not add modules contained in subdirectories of its 
argument directory. Those modules may be added by the directory containing 
their go.mod file in separate 'use' directives.

Hope that helps, and sorry if that does not address your question.

Regards,
thepudds


On Wednesday, April 6, 2022 at 9:43:12 AM UTC-4 Jack Li wrote:

Hi group,


In the go.mod replace way, there’s a one-to-one mapping relationship, for 
example, the module example.com/hello is mapped to folder …/hello


```
$ go mod edit -replace example.com/hello=../hello
$ view go.mod
replace example.com/hello = ../hello
$
```


Now with the go.work way. If I've got three repos or modules like this:


```
module main
go 1.18
require example1.com/hello v1.0.0
require example2.com/hello v1.0.0
require example3.com/hello v1.0.0
```


How can go.work know which module above, refers to ./hello ?


```
go.work:
use ./hello
```


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.
 To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/7c90c2a4-7a81-4e16-b1fe-8ddd19b72f12n%40googlegroups.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/tencent_92E509C4160EBDE79705E7628818074DAA0A%40qq.com.


[go-nuts] How go.work knows which module refers to which folder

2022-04-06 Thread 'Jack Li' via golang-nuts
Hi group,


In the go.mod replace way, there’s a one-to-one mapping relationship, for 
example, the module example.com/hello is mapped to folder …/hello


```
$ go mod edit -replace example.com/hello=../hello
$ view go.mod
replace example.com/hello = ../hello
$
```


Now with the go.work way. If I've got three repos or modules like this:


```
module main
go 1.18
require example1.com/hello v1.0.0
require example2.com/hello v1.0.0
require example3.com/hello v1.0.0
```


How can go.work know which module above, refers to ./hello ?


```
go.work:
use ./hello
```


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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/tencent_FFE3265FF272623D8732F23F839930C48D09%40qq.com.


[go-nuts] Handle 1 million concurrent connections with 50 lines Go code

2022-04-06 Thread 'Jack Li' via golang-nuts
Hi group,


I am going through this page: https://studygolang.com/articles/22820 , It 
claims that the 50 lines of Go code handles 1 million concurrent connections 
from network clients, on 1 single server machine with a 4-Core CPU and 16G 
memory.


Does the package net already utilize IO Multiplexing internally, like epoll 
(epoll_create, epoll_ctl, epoll_wait)? So I can just use package net and gain 
the epoll ability automatically without calling epoll apis manually in Go?


Thanks


Server:
```
package main


import (
  "fmt"
  "net"
  "os"
  "time"
)


var array []byte = make([]byte, 10)


func checkError(err error, info string) (res bool) {


  if err != nil {
fmt.Println(info + " " + err.Error())
return false
  }
  return true
}


func Handler(conn net.Conn) {
  for {
_, err := conn.Write(array)
if err != nil {
  return
}
time.Sleep(10 * time.Second)
  }
}


func main() {


  for i := 0; i < 10; i += 1 {
array[i] = 'a'
  }


  service := ":"
  tcpAddr, _ := net.ResolveTCPAddr("tcp4", service)
  l, _ := net.ListenTCP("tcp", tcpAddr)


  for {
conn, err := l.Accept()
if err != nil {
  fmt.Printf("accept error, err=%s\n", 
err.Error())
  os.Exit(1)
}
go Handler(conn)
  }


}
```


Client:


```
package main


import (
  "flag"
  "fmt"
  "net"
  "os"
  "time"
)


var RemoteAddr *string
var ConcurNum *int
var LocalAddr *string


func init() {
  RemoteAddr = flag.String("remote-ip", "127.0.0.1", "ip addr of 
remote server")
  ConcurNum = flag.Int("concurrent-num", 100, "concurrent number of 
client")
  LocalAddr = flag.String("local-ip", "0.0.0.0", "ip addr of remote 
server")
}


func consume() {


  laddr := net.TCPAddr{IP: net.ParseIP(*LocalAddr)}


  var dialer net.Dialer
  dialer.LocalAddr = laddr


  conn, err := dialer.Dial("tcp", *RemoteAddr+":")
  if err != nil {
fmt.Println("dial failed:", err)
os.Exit(1)
  }
  defer conn.Close()


  buffer := make([]byte, 512)


  for {
_, err2 := conn.Read(buffer)
if err2 != nil {
  fmt.Println("Read failed:", err2)
  return
}


// fmt.Println("count:", n, "msg:", 
string(buffer))


  }


}


func main() {
  flag.Parse()
  for i := 0; i < *ConcurNum; i++ {
go consume()
  }
  time.Sleep(3600 * time.Second)
}
```

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/tencent_BEE3D2499F3C9358D7A1CD7C88E0228C6D07%40qq.com.


Re: [go-nuts] About build Go Archive

2019-09-06 Thread Jack Wang
But I can use -buildmod=plugin to generate a "ELF 64-bit LSB shared object, 
x86-64, version 1 (SYSV), dynamically linked", and it can be used. I want 
to konw if it's the only way to generate a binary package and the 
builmode=archive/shared not work anymore.

在 2019年8月28日星期三 UTC+8下午10:36:31,Ian Lance Taylor写道:
>
> On Wed, Aug 28, 2019 at 5:53 AM > wrote: 
> > 
> > As we know, Go 1.13 will drop support for binary-only packages. it seems 
> we have to use buildmode=plugin/archive if we want to build go archive to 
> provide to others. 
> > 
> > when I try go buildmode=archive or buildmode=shared(go 1.12, go module 
> project), it throw error like cannot use packages ... from different roots, 
> i want to ask if i do something wrong, or it can't support well with 1.12? 
>
> Using -buildmode=archive or -buildmode=shared isn't a way to step 
> around the restrictions on binary packages.  Now that support for 
> binary packages has been removed, the "go build" process inherently 
> expects to be able to see the source code of a package. 
>
> 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2527561f-96ea-41f0-bf4c-18b409250cec%40googlegroups.com.


[go-nuts] Re: Is go1.10beta1 a debug or unoptimized build? (possible regression)

2017-12-23 Thread Jack
I ran the same benchmarks on my local linux NUC and the code actually had 
small performance improvements between 1.9 and 1.10 (some better some not).

It appears to be isolated to running the benchmarks on my mac.

On Saturday, December 23, 2017 at 5:38:31 PM UTC-6, Krzysztof Kowalczyk 
wrote:
>
> Most likely it's 
> https://github.com/golang/go/commit/d8ff3d592088ef175222dbf69991887f0dd458d6#diff-b884a414ef2918cd3d75c6799cb62581
>  
> which seems to add fair amount of code to time.Now()
>
> You can see history of commits to that file with 
> https://github.com/golang/go/commits/master/src/runtime/sys_darwin_amd64.s
>
> On Saturday, December 23, 2017 at 9:32:38 AM UTC-8, Daniel Theophanes 
> wrote:
>>
>> It did change. See https://golang.org/cl/76990 and 
>> https://github.com/golang/go/issues/20427
>> .
>>
>> The numbers you posted look larger then anticipated if it is the same one.
>>
>

-- 
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] Is go1.10beta1 a debug or unoptimized build? (possible regression)

2017-12-22 Thread Jack
Hi,

I'm benchmarking my circuitbreaker implementation 
 
against others and decided to run my benchmarks against 
https://golang.org/dl/#unstable (using my mac).

I installed it following go get golang.org/x/build/version/go1.10beta1

The code makes heavy use of locks, goroutines, and atomics (it's a circuit 
pattern after all)!  Before I get too deep
trying to debug it, I was wondering if anything changed in go10 around how 
benchmarks are measured (maybe it's more accurate, not slower),
or if the build we're using isn't optimized like the official releases 
are.  The difference between "/1" and "/75" is how many goroutines
are concurrently executing.

> benchcmp go9_bench_results go10_bench_results 
benchmark old ns/op new 
ns/op delta
BenchmarkCiruits/Mine/passing/DefaultConfig/1-8   867  
 1962  +126.30%
BenchmarkCiruits/Mine/passing/DefaultConfig/75-8  461  
 823   +78.52%
BenchmarkCiruits/Mine/passing/NoTimeout/1-8   329  
 1223  +271.73%
BenchmarkCiruits/Mine/passing/NoTimeout/75-8  306  
 660   +115.69%
BenchmarkCiruits/Mine/failing/DefaultConfig/1-8   190  
 625   +228.95%
BenchmarkCiruits/Mine/failing/DefaultConfig/75-8  127  
 327   +157.48%
BenchmarkCiruits/Mine/failing/NoTimeout/1-8   200  
 605   +202.50%
BenchmarkCiruits/Mine/failing/NoTimeout/75-8  124  
 327   +163.71%
BenchmarkCiruits/GoHystrix/passing/DefaultConfig/1-8  6752  
9263  +37.19%
BenchmarkCiruits/GoHystrix/passing/DefaultConfig/75-8 2656  
2750  +3.54%
BenchmarkCiruits/GoHystrix/failing/DefaultConfig/1-8  5819  
6485  +11.45%
BenchmarkCiruits/GoHystrix/failing/DefaultConfig/75-8 1820  
1736  -4.62%
BenchmarkCiruits/rubyist/passing/Threshold-10/1-8 1453  
1876  +29.11%
BenchmarkCiruits/rubyist/passing/Threshold-10/75-8757  
 1454  +92.07%
BenchmarkCiruits/rubyist/failing/Threshold-10/1-8 114  
 321   +181.58%
BenchmarkCiruits/rubyist/failing/Threshold-10/75-8245  
 2245  +816.33%
BenchmarkCiruits/gobreaker/passing/Default/1-8197  
 594   +201.52%
BenchmarkCiruits/gobreaker/passing/Default/75-8   625  
 723   +15.68%
BenchmarkCiruits/gobreaker/failing/Default/1-895.3  
284   +198.01%
BenchmarkCiruits/gobreaker/failing/Default/75-8   281  
 350   +24.56%
BenchmarkCiruits/handy/passing/Default/1-81063  
1364  +28.32%
BenchmarkCiruits/handy/passing/Default/75-8   1350  
1875  +38.89%
BenchmarkCiruits/handy/failing/Default/1-81423  
1316  -7.52%
BenchmarkCiruits/handy/failing/Default/75-8   1688  
1621  -3.97%

-- 
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: How to know if interface{} data is nil w/o reflecting?

2017-11-01 Thread Jack Christensen



On 11/01/2017 09:31 AM, Ian Lance Taylor wrote:

On Wed, Nov 1, 2017 at 4:18 AM,  <oju...@gmail.com> wrote:

Ayan, imagine I am part of a development team. In our program I have a
pointer r:

r *myType

My variable r can be nil, because that is a valid situation. It is used in
dozens of places, like this:

if r != nil {
 r.doSomething()
}

That is a very usual idiom, no only in Go, but in many languages. Every
programmer is acquainted to that.

Then, years later, other programmer in my team decides to create an
interface to better capture a new understanding of the problem at hand,
changing the type of r to:

r myInterface

Subtly, the meaning of

if r != nil {
 r.doSomething()
}

changes. Under the right circumstances our software starts to behave
strangely. What?

This problem is dangerous because it is so subtle. We will read our old code
time and again to no avail, because everything seems fine and no one has
changed that "if r != nil r.doSomething" in ages.

As Dave Cheney said in
https://github.com/golang/go/issues/21538#issuecomment-323561094 that could
be solved:

"by making an nil interface and an interface which contains a type who's
value is nil also equal to nil."

A different way to state your argument is that nil is overloaded in
Go.  Your argument is essentially identical to saying suppose you have
an integer r:

type MyIntegerType int
var r MyIntegerType

and a bunch of code that tests whether r is 0 or not

if r != 0 {
 r.doSomething()
}

Then you change r to an interface type, and now the meaning of r != 0
has subtly changed.  The code still compiles, but now it means
something different.  r != 0 will be true even if the value of r
actually is 0, because in `r != 0` the `0` will be given type `int`,
but `r` is type `MyIntegerType`, so the values are not equal.

That is definitely potentially confusing, but I would like to believe
that you would not argue that we should treat r != 0 specially for
integer types.  Or, at least, we shouldn't treat it any differently
than r != 1.  And, obviously, `r == nil` should not be true if r
happens to be `0`.

I think the reason it feels different for pointer types is that we,
probably incorrectly, chose to use the same identifier, `nil`, to
represent the zero value both for pointers and for interfaces.
Suppose we had given the zero value of interface types the name
`nilinterface`.  Then the situation for pointers would be the similar
to that for integers.  Writing `r != nilinterface` would be equivalent
to `r != nil` today: it would test whether the interface itself is
nil.  `r != nil` would be a compilation error, because, unlike `0`,
there is no default type for `nil`.

If we do change something in this area for Go 2, which we probably
won't, my preference would definitely be to introduce `nilinterface`
rather than to further confuse the meaning of `r != nil`.

Ian

Perhaps a small package and linter could solve this without requiring a 
language change. The package would expose either a NilInterface value or 
a IsNilInterface method. Users of the package would either compare to 
the pkg.NilInterface or call the pkg.IsNilInterface method. Then the 
linter could warn on all direct interface comparisons to nil.


Jack

--
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] repeatable builds

2017-10-18 Thread Jack Christensen



On 10/18/2017 03:08 AM, Conrad Wood wrote:

I did (admittedly found it only after I send the email). I give that a
try and see how it goes - thank you!

And advice on point #2 by any chance?
When I have a mixed language repo I tend to include an entire GOPATH in 
the the repo. Something like direnv (https://direnv.net/) can be used to 
automatically set the GOPATH environment variable as needed.




On Tue, 2017-10-17 at 19:46 +0100, roger peppe wrote:

Have you looked at the dep tool (github.com/golang/dep) ?

On 17 Oct 2017 13:42, "Conrad Wood"  wrote:

Hi,

We're considering Go for new services in our software architecture.
Generally it seems like a good fit. There are a few things I'm not
sure about though, so I wonder what others do:

1. How does one ensure repeatable builds? (go get obviously pulls
from the internet by default.to get repeatable and versioned
builds, does one keep the packages itself in a git repository?)

2. Our repositories have a lot of files (documentation, tools,
tests, and whatnot, a java client), and only a fairly small part of
actual Go code. However, the go code needs to remain within the
GOPATH. The java classes on the other hand need to reside in the
CLASSPATH. To make matters worse, go doesn't like symlinks in the
gopath. (https://github.com/golang/go/issues/14054). What I really
want, is a self contained repository to has all the bits and bobs
that we need to this particular service and is compilable and
executable from it's own directory.

I am thinking of the workflow for developers, and I'm trying to
achieve (and did with C and Java) a simple "git clone [repo]" ; cd
repo ; ./build.sh" to get started quickly and easily. Ideally the
server would execute the same steps and produce the binaries
required and use the same dependencies as the compiler on the
developer workstation.

How do others set this up with Go?

Thanks,

Conrad




--
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: pgx v3 - PostgreSQL Driver and Toolkit

2017-07-24 Thread Jack Christensen
pgx is a pure Go driver and toolkit for PostgreSQL. pgx is different 
from other drivers such as [pq](http://godoc.org/github.com/lib/pq) 
because, while it can operate as a database/sql compatible driver, pgx 
is also usable directly. It offers a native interface similar to 
database/sql that offers better performance and more features.


https://github.com/jackc/pgx

## Features

pgx supports many additional features beyond what is available through 
database/sql.


* Support for approximately 60 different PostgreSQL types
* Batch queries
* Single-round trip query mode
* Full TLS connection control
* Binary format support for custom types (can be much faster)
* Copy protocol support for faster bulk data loads
* Extendable logging support including built-in support for log15 and logrus
* Connection pool with after connect hook to do arbitrary connection setup
* Listen / notify
* PostgreSQL array to Go slice mapping for integers, floats, and strings
* Hstore support
* JSON and JSONB support
* Maps inet and cidr PostgreSQL types to net.IPNet and net.IP
* Large object support
* NULL mapping to Null* struct or pointer to pointer.
* Supports database/sql.Scanner and database/sql/driver.Valuer 
interfaces for custom types
* Logical replication connections, including receiving WAL and sending 
standby status updates

* Notice response handling (this is different than listen / notify)

## Performance

pgx performs roughly equivalent to [go-pg](https://github.com/go-pg/pg) 
and is almost always faster than 
[pq](http://godoc.org/github.com/lib/pq). When parsing large result sets 
the percentage difference can be significant (16483 queries/sec for pgx 
vs. 10106 queries/sec for pq -- 63% faster).


In many use cases a significant cause of latency is network round trips 
between the application and the server. pgx supports query batching to 
bundle multiple queries into a single round trip. Even in the case of a 
connection with the lowest possible latency, a local Unix domain socket, 
batching as few as three queries together can yield an improvement of 
57%. With a typical network connection the results can be even more 
substantial.


See this 
[gist](https://gist.github.com/jackc/4996e8648a0c59839bff644f49d6e434) 
for the underlying benchmark results or checkout 
[go_db_bench](https://github.com/jackc/go_db_bench) to run tests for 
yourself.


In addition to the native driver, pgx also includes a number of packages 
that provide additional functionality.


## github.com/jackc/pgx/stdlib

database/sql compatibility layer for pgx. pgx can be used as a normal 
database/sql driver, but at any time the native interface may be 
acquired for more performance or PostgreSQL specific functionality.


## github.com/jackc/pgx/pgtype

Approximately 60 PostgreSQL types are supported including uuid, hstore, 
json, bytea, numeric, interval, inet, and arrays. These types support 
database/sql interfaces and are usable even outside of pgx. They are 
fully tested in pgx and pq. They also support a higher performance 
interface when used with the pgx driver.


## github.com/jackc/pgx/pgproto3

pgproto3 provides standalone encoding and decoding of the PostgreSQL v3 
wire protocol. This is useful for implementing very low level PostgreSQL 
tooling.


## github.com/jackc/pgx/pgmock

pgmock offers the ability to create a server that mocks the PostgreSQL 
wire protocol. This is used internally to test pgx by purposely inducing 
unusual errors. pgproto3 and pgmock together provide most of the 
foundational tooling required to implement a PostgreSQL proxy or MitM 
(such as for a custom connection pooler).


https://github.com/jackc/pgx

Jack


--
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: Recommended design pattern for real-time monitoring and control of an observatory

2017-04-06 Thread jack
James,

Let me suggest the TICK Stack <https://influxdata.com> (Written in Go) and 
Grafana <https://grafana.net>. Its pretty get setup and has much of what 
you want out of the box. Here is a blog post 
<http://engineer.john-whittington.co.uk/2016/11/raspberry-pi-data-logger-influxdb-grafana/>
 
describing the setup. I'm also working on a webinar describing how to do 
this.

Jack

On Wednesday, April 5, 2017 at 5:22:15 PM UTC-7, James McHugh wrote:
>
> I'm writing some software to monitor and control my observatory. It will 
> have many many inputs (clouds, rain, temp, time, roof position, telescope 
> status, focuser status, camera status, filter status etc etc ) and will 
> control the whole setup including opening closing the roof based on weather 
> / alt of the Sun, taking images, focusing based on temp changes, auto 
> guiding, selecting the best target, shutting the system down if there is 
> rain or clouds,  etc etc etc 
> It could get quite complex.
>
> I have all the individual pieces working, now I'm looking for a nice 
> design pattern to tie it all together.
>
> Any suggestions or ideas to get me started? I'm worried if I start off 
> with just a bunch of if statements and for loops it will quickly become a 
> huge mess.
>
> Regards
>
> James
>

-- 
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] Does there exist a curated list of all Go Gopher images?

2016-12-01 Thread Jack
Is there a list/page/album/etc somewhere of every reusable Go Gopher image 
and it's associated license/author?

-- 
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.