Re: [go-nuts] How to lower listen backlog for tcp socket
I think you can't. The listen backlog is set to whatever is kernel's maximum backlog value. See for example /usr/local/go/src/net/sock_linux.go to see how that is determined. There has been a bug report about it: https://github.com/golang/go/issues/6079 I think it has been incorrectly closed (or alternatively I am missing how to set it). Workarounds: * Create the socket yourself using syscall.Socket, syscall.Bind and syscall.Listen and then use net.FileListener. * Lower the kernel backlog value. Note that this will affect all processes on the system. Best regards, Janne Snabb sn...@epipe.com On 22/03/2019 18.48, Wangbo wrote: I know Control func and syscall.SetsockoptInt(fd, syscall.AF_INET, syscall.SO_REUSEADDR, 1) cat set reuseadd But how to adjust listen backlog since i never find socket options for it. Agniva De Sarker <mailto:agniva.quicksil...@gmail.com>> 于2019年3月22日周五 下午4:44写道: Using ListenConfig is the way to go. The Control func is passed the raw socket connection on which you can apply whatever socket options you choose. You have to go through 2 layers to get to the fd. ListenConfig{ Control: func(conn syscall.RawConn) error { return conn.Control(func(fd uintptr) error { return syscall.SetsockoptInt(fd, syscall.AF_INET, 0, 0) }) } } On Thursday, 21 March 2019 20:49:20 UTC+5:30, Peter Wang wrote: I try to use net.ListenConfig, but fail can someone give example ? -- 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 <mailto: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 <mailto: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] syscall.SendMsg/RecvMsg
Well, you are obviously stat()ing two completely different files. It is impossible to guess what you are doing wrong because you do not show your code. My crystall ball is not strong enough. Please see: https://github.com/golang/go/wiki/How-to-ask-for-help Have you considered using an existing solution instead of trying to reinvent the wheel? A simple google search returns this at the top: https://github.com/ftrvxmtrx/fd Janne Snabb sn...@epipe.com On 15/03/2019 20.12, sbezverk wrote: Hello, I am trying to pass a descriptor using syscall.SendMsg/RecvMsg and I noticed that inod for the second process is not the same as original, but according to Unix Networking API, inod should stay the same and only number of reference to inod should be incremented. Anybody successfully managed to send descriptors using syscall.SendMsg? Here is Stat of the file on sending side: File descriptor: 3 File Stat returnd: &{name:test-420291847 size:55 mode:420 modTime:{wall:782108249 ext:63688268119 loc:0xd50460} sys:{Dev:64768 >>>>>Ino:67217215<<<<< Nlink:1 Mode:33188 Uid:0 Gid:0 X__pad0:0 Rdev:0 Size:55 Blksize:4096 Blocks:8 Atim:{Sec:1552671319 Nsec:781108231} Mtim:{Sec:1552671319 Nsec:782108249} Ctim:{Sec:1552671319 Nsec:782108249} X__unused:[0 0 0]}} Encoded Socket Control Messages: [20 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 3 0 0 0 0 0 0 0] Here is Stat of the file on receiving side: Received buffer: [20 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 7 0 0 0 0 0 0 0] Received messages: [{Header:{Len:20 Level:1 Type:1} Data:[7 0 0 0]}] Parsed right: [7] Created file object with name: /tmp/service-2 File Stat returnd: &{name:service-2 size:0 mode:1627 modTime:{wall:0 ext:62135596800 loc:0xd50460} sys:{Dev:7 >>>>>Ino:35926817 <<<<< Nlink:1 Mode:49663 Uid:0 Gid:0 X__pad0:0 Rdev:0 Size:0 Blksize:4096 Blocks:0 Atim:{Sec:0 Nsec:0} Mtim:{Sec:0 Nsec:0} Ctim:{Sec:0 Nsec:0} X__unused:[0 0 0]}} Any suggestions are really welcome! Thank you Serguei -- 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 <mailto: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] how to build golang program with a lower kernel requirement?
You are somehow confused. The kernel version requirement of some particular glibc version is not relevant. There is no problem. It works. See https://github.com/golang/go/wiki/MinimumRequirements for kernel version requirements. Hope this helps, Janne Snabb sn...@epipe.com On 30/11/2018 07.36, hui zhang wrote: I build golang programe on ubuntu 18.04, try to run it on ubuntu 16.04 , it hint "kernal too old" ldd --version ldd (Ubuntu GLIBC 2.27-3ubuntu1) 2.27 #ubuntu 18.04 ldd (Ubuntu GLIBC 2.23-3ubuntu1) 2.23 #ubuntu 16.04 glibc 2.24 above requires kernel 3.2 minimum glibc 2.23 requires kernel 2.6.32. minimum #ubuntu 16.04 Q1: how to build golang program with a lower kernel requirement? Q2: on the other hand if I build golang program on ubuntu 16.04 , can it run on ubuntu 18.04 -- 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 <mailto: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] Determining latest released Go version
Thanks! I think programmers are more likely to stay consistent than web designers — thus this feels a bit better than scraping a web page. Janne Snabb sn...@epipe.com On 20/11/2018 22.06, Caleb Mingle wrote: Perhaps something built using these may work (sorting the go1* tags descending?): https://go.googlesource.com/go/+refs https://go.googlesource.com/go/+refs?format=JSON https://go.googlesource.com/go/+refs?format=TEXT Kinda brittle to tie this to tag names, but it may be less brittle than parsing HTML. Good luck! On Tue, Nov 20, 2018 at 11:30 AM Janne Snabb <mailto:sn...@epipe.com>> wrote: Parsing HTML is exactly what I wanted to avoid doing :) but I haven't found any alternatives so far. For some reason https://api.github.com/repos/golang/go/releases does not return anything. It does work for other projects on Github. Janne Snabb sn...@epipe.com <mailto:sn...@epipe.com> On 20/11/2018 03.51, Tamás Gulácsi wrote: See whatgithub.com/niemeyer/godeb <http://github.com/niemeyer/godeb> does. -- 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 <mailto:golang-nuts+unsubscr...@googlegroups.com>. For more options, visit https://groups.google.com/d/optout. -- mingle.cm <http://mingle.cm/> | @caleb_io <http://twitter.com/caleb_io> -- 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 <mailto: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] Determining latest released Go version
Parsing HTML is exactly what I wanted to avoid doing :) but I haven't found any alternatives so far. For some reason https://api.github.com/repos/golang/go/releases does not return anything. It does work for other projects on Github. Janne Snabb sn...@epipe.com On 20/11/2018 03.51, Tamás Gulácsi wrote: See what github.com/niemeyer/godeb does. -- 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] Determining latest released Go version
Dear Gophers, How to determine the latest released Go version programmatically? I am working on a system which needs to use the latest published Go version (whatever it is at the time it is run). I would rather not update it manually every time a new version comes out as this is error prone and slow. Also scraping and parsing golang.org web site contents seems silly. I would like an URL which returns the latest released version number as text or as a redirect to the latest tarball or something similar. Does such thing exist? Any other ideas? -- Janne Snabb sn...@epipe.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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Go could really use a while statement
On 2018-05-13 11:34, Hugh Fisher wrote: > I still think a while { ... } loop would be a worthwhile > addition, for the reasons I've already given. Your reason from the original post was: "I know it's possible to use a for, but it doesn't feel right to me." It is not reasonable to demand everyone else in the world to change to behave according to your feelings. It is much less waste of resources that you just learn to align your own feelings to match the world around you. I am sure there are also people in the world who feel that "let" would be better than "var" and "mitähäh?" would be better than "if". Should the language also be changed to accommodate those feelings? Obviously not. Janne Snabb sn...@epipe.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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] net.Conn not returning error upon Write after being closed from far side.
Your TCP FIN is still in transit or not yet processed by the other TCP stack when you issue the first write. TCP is not synchronous even if running on same host. Janne Snabb sn...@epipe.com On 2018-04-10 17:58, pierspowlesl...@gmail.com wrote: > Hi > > I'm trying to understand what is going on under the hood here. > > I would expect a net.Conn after being closed from the far side, to issue > an error if the near side then tries to write to it. On my local machine > an error is returned on the second write, on the go playground all > writes succeed. > > The test is shown below and is also here > - https://play.golang.org/p/EFYX_ZehMKs > > Thanks for any insight, > > Piers > > | > func TestDetectClosedConnectionWhenWriting(t *testing.T) { > listener, err := net.Listen("tcp", ":0") > if err != nil { > t.Fatal(err) > } > > wait := make(chan struct{}) > go func() { > conn, err := listener.Accept() > if err != nil { > t.Fatal(err) > } > err = conn.Close() > if err != nil { > t.Fatal(err) > } > wait <- struct{}{} > }() > > conn, err := net.Dial("tcp", listener.Addr().String()) > if err != nil { > t.Fatal(err) > } > <-wait > for i := 0; i < 100; i++ { > println(i) > _, err = conn.Write([]byte("b")) > if err != nil { > break > } > } > if err == nil { > t.Fatal("expecting error to be returned when writing") > } > t.Fatal("expecting error to be a permanent net.OpError") > } > > | > > > > -- > 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 > <mailto: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] Set a SAN otherName using `x509.CertificateRequest`
Yes, but not as easily as using DNSName. You need to add the extension "manually". Put it in ExtraExtensions of the template. See /usr/local/go/src/crypto/x509/x509.go functions buildExtensions and marshalSANs to see how to put it there. Janne Snabb sn...@epipe.com On 2017-04-24 18:28, Adam Medziński wrote: > Is it possible to set a SAN otherName in x509.CertificateRequest > <https://golang.org/pkg/crypto/x509/#CertificateRequest> structure, so > it will be present in the DER encoded output > of x509.CreateCertificateRequest > <https://golang.org/pkg/crypto/x509/#CreateCertificateRequest>? > > -- > 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 > <mailto: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] Re: golang tour - floating point numbers
It does not do this. It would be nice in most cases if it did. But some times extra parenthesis are useful for making some formula easier to read. Janne Snabb sn...@epipe.com On 2017-04-15 01:36, Jesper Louis Andersen wrote: > If I remember correctly, you can just go wild and put in all the > parenthesis you want and "go fmt" will clean it up for you wrt > precedence rules > > > On Fri, Apr 14, 2017, 14:38 Elias Naur <elias.n...@gmail.com > <mailto:elias.n...@gmail.com>> wrote: > > Your expression is (effectively) ((z*z-x)/2)*z. Use parentheses to > group the 2*z term: (z*z-x)/(2*z). > > - elias > > > On Friday, April 14, 2017 at 2:30:33 PM UTC+2, ksam...@redhat.com > <mailto:ksam...@redhat.com> wrote: > > Hello, > > Am a newbie to golang, and was trying myself with golang tour. > > > I was trying https://tour.golang.org/flowcontrol/8 and below is > my code snippet for the same > > | > package main > > import ( > "fmt" > "math" > ) > > func Sqrt(x float64) float64 { > z := float64(1) > > for i := 0; i < 10; i++ { > //z = z - (z*z-x)/2*z -- this does not work why ??? > z = z - (float64(z*z)-float64(x))/float64(2*z) > } > return float64(z) > } > > func main() { > fmt.Printf("Ans: %0.2f \n", Sqrt(4)) > fmt.Printf("math.Sqrt: %0.2f", math.Sqrt(4)) > } > > | > > I assume that all data is handled as float64 only, if you see > the commented codes not seem to work especially for simple > Sqrt(4) i get an answer of 1.76 instead of 2 ;) .. but after i > did the casting to float64(..) it seem to work right.. > > I am not able to understand why .. > > any thoughts ? > > -- > 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 > <mailto: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 > <mailto: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] godoc: example wont show up
It seems it is because it is "package main". See $GOPATH/src/golang.org/x/tools/godoc/static/package.html template. "IsMain" is set if the package is called "main". Looks like there is no way to output examples in that case. Janne Snabb sn...@epipe.com On 2017-03-06 19:25, mhhc...@gmail.com wrote: > > thanks for your reply. > > yeah, that s right, ok, but what about TOC#5 ? > > That should work too, > > To achieve this we can use a "whole file example." > A whole file example is a file that ends in |_test.go|✓ > contains exactly one example > function, ✓ > no test or benchmark > functions, ✓ > and at least one other package-level declaration. ✓ > When displaying such examples godoc will show the entire file. > > : x > > https://github.com/mh-cbon/emd/blob/master/main_test.go > > > On Monday, March 6, 2017 at 5:42:32 PM UTC+1, Janne Snabb wrote: > > Your example function is named ExampleMain(). This means that it is > supposed to document function Main() or type Main. > > However, there is no function Main() or type Main in the package. Thus > the example is not visible in the documentation because there is > nothing > for it to attach to. > > See for example the following about the naming rules: > > https://blog.golang.org/examples#TOC_4 > <https://blog.golang.org/examples#TOC_4>. > > > Janne Snabb > sn...@epipe.com > > On 2017-03-06 17:35, mhh...@gmail.com wrote: > > Hi, > > > > in my package here, what did i do wrong so the ExampleMain won t > show up ? > > > > https://github.com/mh-cbon/emd > > > > https://godoc.org/github.com/mh-cbon/emd > <https://godoc.org/github.com/mh-cbon/emd> > > > > Im expecting to see > > https://github.com/mh-cbon/emd/blob/master/main_test.go#L13 > <https://github.com/mh-cbon/emd/blob/master/main_test.go#L13> > > > > Note, go test works fine. > > > > 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...@googlegroups.com > > <mailto:golang-nuts+unsubscr...@googlegroups.com >. > > For more options, visit https://groups.google.com/d/optout > <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 > <mailto: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] Load public key from DER encoded certificate
You are trying to read a certificate with a function intended for reading a public key. Use x509.ParseCertificates instead. Janne Snabb sn...@epipe.com On 2017-03-06 16:39, 0x7bc77a wrote: > Hi, > > I would like to load the public key from a DER encoded certificate > > Here is my code > > func ExampleParsePKIXPublicKey() { > raw, err := ioutil.ReadFile("/Path/To/DER/Encoded/Certificate") > > if err != nil { > panic("failed to read certificate" + err.Error()) > } > > pub, err := x509.ParsePKIXPublicKey(raw) > > if err != nil { > panic("failed to parse DER encoded public key: " + err.Error()) > } > > switch pub := pub.(type) { > case *rsa.PublicKey: > fmt.Println("Pub is of type RSA:", pub) > case *dsa.PublicKey: > fmt.Println("Pub is of type DSA:", pub) > case *ecdsa.PublicKey: > fmt.Println("Pub is of type ECDSA:", pub) > default: > panic("unknown type fo public key") > } > } > > then I get errors like below: > > panic: failed to parse DER encoded public key: asn1: structure error: > tags don't match (6 vs {class:2 tag:0 length:3 isCompound:true}) > {optional:false explicit:false application:f > alse defaultValue: tag: stringType:0 timeType:0 set:false > omitEmpty:false} ObjectIdentifier @2 > > any ideas to solve this problem? > > thanks in advance! > > -- > 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 > <mailto: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] godoc: example wont show up
Your example function is named ExampleMain(). This means that it is supposed to document function Main() or type Main. However, there is no function Main() or type Main in the package. Thus the example is not visible in the documentation because there is nothing for it to attach to. See for example the following about the naming rules: https://blog.golang.org/examples#TOC_4. Janne Snabb sn...@epipe.com On 2017-03-06 17:35, mhhc...@gmail.com wrote: > Hi, > > in my package here, what did i do wrong so the ExampleMain won t show up ? > > https://github.com/mh-cbon/emd > > https://godoc.org/github.com/mh-cbon/emd > > Im expecting to see > https://github.com/mh-cbon/emd/blob/master/main_test.go#L13 > > Note, go test works fine. > > 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 > <mailto: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] sqlEZ: the easiest way to use a SQL database
Looks similar to https://github.com/jmoiron/sqlx which is well established. Might be a good idea to add a short summary of differences/additional benefits compared to sqlx in README. Janne Snabb sn...@epipe.com On 2017-03-05 01:36, jmacwhyte wrote: > Hello all, > > After seeing a need for simplifying SQL databases in Go, I have written > a new package that makes it very easy to do basic SELECT, INSERT, and > UPDATE database operations. Essentially you define a struct that > corresponds with the data in your database, and then you can simply pass > that struct to my package to insert and retrieve data. I'm now using it > in one of my projects, and it has reduced database-related code by 60%, > making things much more readable! > > Here's how easy it is to retrieve some info, make some changes, and > return it to the database: > > | > type SumoWreslterstruct{ > Namestring`db:"name"` > Ageint`db:"age"` > Rankstring`db:"level"` > } > > func main(){ > db,err :=sqlez.Open("databaseDriver","dataSource") > > tooOld :=30 > > results,err :=db.SelectFrom("wrestlers",SumoWreslter{},sqlez.Params{ >Where:`age < ? AND level = "master"`, >OrderBy:`age DESC`, >Limit:1, > },tooOld) > > theOne :=results[0].(SumoWreslter) > theOne.Rank="grand master" > // Manipulate data further > > _,err :=db.Update("wrestlers",theOne,sqlez.Params{ >Where:`name = ?`, >},theOne.Name) > } > > // Done! > | > > I think it's a very handy tool, especially for getting started quickly. > It can handle embedded structs, it can store and retrieve Go datatypes > like structs and maps using JSON, and uses sql.NullString under the hood > to avoid errors when trying to pull TEXT columns that are NILL. > > I would love any feedback or suggestions, both on the code and the > documentation I've written (which is geared more for people who are > new-ish to Go). > > Thanks! > 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 > <mailto: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] API call fails
Your client is working correctly but the server at port 11215 is offering a wrong certificate. Configure the server to offer a certificate for myDomain.com instead of offering a certificate for anotherDomain.com. Alternatively you can work around the issue by setting InsecureSkipVerify in your client. Janne Snabb sn...@epipe.com On 2017-02-17 16:38, Sovon Nath wrote: > Hi - I am trying to call a restful API using a certificate. The pem file > I have is of the format: > > -BEGIN RSA PRIVATE KEY- > > data is here > > -END RSA PRIVATE KEY- > > -BEGIN CERTIFICATE- > > data is here > > -END CERTIFICATE- > > -BEGIN CERTIFICATE- > data is here > -END CERTIFICATE- > > > The code that i am using is > > > //creating the certificate for call > caCert, err := ioutil.ReadFile("certFil.pem") > if err != nil { >log.Fatal(err) > } > > > caCertPool := x509.NewCertPool() > caCertPool.AppendCertsFromPEM(caCert) > > client := { >Transport: { > TLSClientConfig: { > RootCAs: caCertPool, > }, >}, > } > > //end of creating the certificate for call > > //creating the body for call > url := "https://mydomain.com:11215/myuri/path1/path2; > fmt.Println("URL:>", url) > > var jsonStr = []byte(`{ > "My JSON" > } `) > > req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr)) > req.Header.Set("Accept", "application/json;v=3") > req.Header.Set("Cache-Control", "no-cache, no-store") > req.Header.Set("Connection", "Keep-Alive") > req.Header.Set("User-Agent", "HttpClient") > req.Header.Set("Content-Type", "application/json;v=3") > > //client := {} > resp, err := client.Do(req) > if err != nil { >panic(err) > } > defer resp.Body.Close() > > > > > > > When I run this code I get an exception: > > > x509: certificate is valid for anotherDomain.com, not myDomain.com > > > > Can you please help me solve this issue? > > -- > 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 > <mailto: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] TLS server to save client certificates after a request is received
The certificate byte stream is available in the Raw field of the Certificate struct. You can for example output received certificates PEM encoded like this: for _, c := range r.TLS.PeerCertificates { pem.Encode(os.Stdout, {Type: "CERTIFICATE", Bytes: c.Raw}) } Or you can just save c.Raw in a file if you prefer binary format. See https://gist.github.com/snabb/01c71af8cc9815e2fed68767bbb445af for complete example. Janne Snabb sn...@epipe.com On 2017-02-15 03:54, Naveen Shivegowda wrote: > Hi, > > I need to store the client certificates in a file for further > authentication purpose but I am not able to re-form the client certificates. > TLS.PeerCertificates has information related to client certificates but > it is separated by struct fields and is not present as byte stream which > could be written into a file, Is there any package which could take > 'TLS.PeerCertificates' and convert it into a certificate again? > > -- > 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 > <mailto: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] Turning off nagle's algorithm for http.Client
In the http.Client that you use, specify your own Transport where you specify your own DialContext function which Dials first and then calls SetNoDelay on the connection before returning. Janne Snabb sn...@epipe.com On 2016-10-08 11:25, hay wrote: > Hi, > > I'm using http.Client to make restful calls, turning off nagle's > algorithm will help as messages are very short and response time needs > to be fast. Is there a way to check or/and set to turn off > 'NoDelay'/Nagle's algorithm for http.Client ( > https://golang.org/pkg/net/http/#Client ) ? > > Regards and thanks in advance, > > > -- > 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 > <mailto: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] why is my program retaining memory when len([]byte)>16384 ?
On 2016-07-03 20:35, mhhcbon wrote: > r :=buf.Bytes()// read from encoder > buf.Truncate(0) I did not understand your explanation of the problem, but surely there is a bug in the code quoted above. Read bytes.Buffer Bytes() function documentation: func (b *Buffer) Bytes() []byte Bytes returns a slice of length b.Len() holding the unread portion of the buffer. The slice is valid for use only until the next buffer modification (that is, only until the next call to a method like Read, Write, Reset, or Truncate). The slice aliases the buffer content at least until the next buffer modification, so immediate changes to the slice will affect the result of future reads. Janne Snabb sn...@epipe.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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] golang poll/epoll/select
On 2016-06-25 22:59, Michael Soulier wrote: > I'm curious as to what I'm doing wrong with select here, and if it's > possible to do this with a goroutine like you describe. You should not be using select in the first place. You are making things complicated for no reason whatsoever. (If I understand your intention correctly.) You should just read from os.Stdin. It will block until there is something to read (unless you did something special to set it in non-blocking mode). Check for EOF to know when to quit reading. Use a goroutine if you need to do something else while the read is blocked. If you do not need to do something else, you do not need a goroutine. Just a plain and simple read loop. Janne Snabb sn...@epipe.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. For more options, visit https://groups.google.com/d/optout.