[go-nuts] Couldn't able to establish Web Socket connection when server and client running as containers in different hosts

2021-02-21 Thread thatipelli santhosh
Hi Everyone,

Server and client both are developed in go. I am using
*github.com/gorilla/websocket
 *library to establish a web socket
connection.
My server is running on port 8080 as docker container and my client (cli
tool) is running as docker container in another host. When the client
requests the server with "WS://domain_name:8080/api/connect" to establish
ws connection, nothing is happening even an error also not occurred at both
ends. It is working good in localhost but when the server and client are
running as containers, it is not working as expected.

If anyone has any idea to solve this issue,please let me know.

Any help is appreciated. Thank you!!

Sample server code:
var upgrader = websocket.Upgrader{} // use default options
func echo(w http.ResponseWriter, r *http.Request) {
c, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Print("upgrade:", err)
return
}
defer c.Close()
for {
mt, message, err := c.ReadMessage()
if err != nil {
log.Println("read:", err)
break
}
log.Printf("recv: %s", message)
err = c.WriteMessage(mt, message)
if err != nil {
log.Println("write:", err)
break
}
}
}





Sample client code:

var addr = flag.String("addr", "localhost:8080", "http service address")
func main() {
flag.Parse()
log.SetFlags(0)
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, os.Interrupt)
u := url.URL{Scheme: "ws", Host: *addr, Path: "/echo"}
log.Printf("connecting to %s", u.String())
c, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
if err != nil {
log.Fatal("dial:", err)
}
defer c.Close()

-- 
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/CAN1Sb7wnQHgotLADWdeKn7QT9hUP0frqML4zL4uT-H%3DMGkiLCQ%40mail.gmail.com.


Re: [go-nuts] Re: best way to know executable version without running it

2020-08-19 Thread thatipelli santhosh
Hi Guys

Thank you for your response.

Consul is go executable. I can get version using /bin/consul version
command but I need to find the version using string search in executable
file data.


I noticed some pattern in executables

1.8.312345156252160h3100043191500ms781258760h94105:***@ => 1.8.3

1.8.212345156252160h3100043191500ms781258760h94105:***@ => 1.8.2

1.8.112345156252160h3100043191500ms781258760h94105:***@ => 1.8.1

1.8.012345156252160h3100043191500ms781258760h94105:***@

1.7.712345156252160h3100043191500ms781258760h94105:***@

1.7.612345156252160h3100043191500ms781258760h94105:***@

1.7.412345156252160h3100043191500ms781258760h94105:***@

1.7.312345156252160h3100043191500ms781258760h94105:***@

1.7.212345156252160h3100043191500ms781258760h94105:***@

1.6.812345156252160h3100043191500ms781258760h94105:***@


the first 3 digits are version number in above strings which we found them
executable but I don't find this string in all versions of consul


So does go use any specific delimiter before or after adding version
numbers in executable file (compiled file)?

do you have any idea to get version number from go executable without
executing it which is common for all?

Note: Attached screenshot method is not working for all versions



On Thu, Aug 13, 2020 at 6:35 PM Sathish VJ  wrote:

> Maybe you are asking how to get build version information into the
> executable.  If yes, then use -ldflags.
> https://pmcgrath.net/include-version-information-in-golang-app
>
> On Thursday, 13 August 2020 at 15:12:36 UTC+5:30 seank...@gmail.com wrote:
>
>> go version -m 
>>
>> On Thursday, August 13, 2020 at 10:30:56 AM UTC+2 santhoshth...@gmail.com
>> wrote:
>>
>>> Hi All,
>>>
>>> What is best way to know a executable version without executing it
>>> through golang?
>>>
>>> I tried with reading the executable file through a scanner and matching
>>> every line with regex (like ngnix regx) but this is not working for all
>>> executables.
>>>
>>> Do you have any idea?
>>>
>> --
> 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/eac6fad2-edcf-47c2-8b0e-e1f2d2dd6d56n%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/CAN1Sb7wuBOxEFxO3KJnrDo9B6WuZcwCvnjsSHgZzKOMZ5OWO%3DQ%40mail.gmail.com.


[go-nuts] best way to know executable version without running it

2020-08-13 Thread thatipelli santhosh
Hi All,

What is best way to know a executable version without executing it through
golang?

I tried with reading the executable file through a scanner and matching
every line with regex (like ngnix regx) but this is not working for all
executables.

Do you have any idea?

-- 
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/CAN1Sb7wpzMNh8y7f65vQrZk96SyL%2BcaFxOmCSWUE_4uoOvO%3DKw%40mail.gmail.com.


[go-nuts] Pipe multiple commands in golang

2020-08-12 Thread thatipelli santhosh
Hi all,

I have requirement to execute a command like cmd : *strings
dynamic_file_path | grep regex*

I don't know what is the best way to do this like any well known library or
standard way.

Can you please help here?

-- 
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/CAN1Sb7y2DdZJP30cfxRKr%3DFKgFsc1Kp%2Bdzqe0pd3qAt4JDg6LQ%40mail.gmail.com.


Re: [go-nuts] How to determine system requirements for an application?

2020-07-03 Thread thatipelli santhosh
My thought would be write another program or client to send requests to
your k8's deployed app/program to test its limits and determine your
optimal solution.

I think it is kind of doing a stress testing and go has tools for it.

On Sat, Jul 4, 2020, 00:25 smart aquarius  wrote:

> But as per my understanding the threading mechanism of Golang is far more
> better and lightweight than any technology like C# or Java. My use case is
> I wanted to deploy golang api on kuernetes which will be called by 150
> clients every 20 seconds. I don't know how much ram and cpu will be be good
> in such case. Before this, I have never deployed anything on K8. I always
> used azure shared instance for my other technologies where resource
> management is automatic.
>
> On Friday, 3 July 2020 18:04:00 UTC+5:30, Gergely Födémesi wrote:
>>
>> If you can do that in any other language, similar strategy would work in
>> similar go programs as well.
>> (I assume you know you can't do that in the general case. For details see
>> the halting problem.)
>>
>> On Fri, Jul 3, 2020, 11:58  wrote:
>>
>>> Hello,
>>>
>>> If we make an application in golang then how to determine the system
>>> requirements required for its flawless execution.
>>>
>>> What are the parameters to justify the estimated values ​​of CPU and
>>> RAM, especially for the application.exe built in Golang
>>>
>>> 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 golan...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/golang-nuts/15d06b49-a467-4f5c-bd5c-c29c93b576d7o%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/abd6296e-c9f4-47b8-8871-ab946136f51bo%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/CAN1Sb7w4F2U4nT6sSmdM_21BE1pRKkNpgiGh_%3DKigQxvO__xVA%40mail.gmail.com.


Re: [go-nuts] Re: Extending an array 'The right way'. Guidence needed!

2019-10-15 Thread thatipelli santhosh
Hi Marvin,

I am curious to know if we approx 10 ( we don't know exact amount of
slice entries)  add to slice.  Slice will grow based on our size of data
and underlying array size but doing this create multiple underlying arrays
(more memory resource utilization, processing). In such case,  what is the
optimum solution?

On Tue, Oct 15, 2019, 17:22 Marvin Renich  wrote:

> [When you are replying to someone else's message, reply to that message,
> not your original message.  Your reply lost the context of the message
> to which you were replying (Jan Mercl's).]
>
> * Stuart Davies  [191015 07:24]:
> > My goal is to contain a list of integers that may extend to possibly a
> > couple of thousand entries. Initial size is 100. Extensions add 50
> entries
> > at a time.
> >
> > I declared the array initially with:
> >
> > make([]int64, 100).
> >
> > I tried using the Append function but could not Append past the 100
> > entries. The 101 entry threw a panic so I detirmined to extend the array
> > myself.
> >
> > I would have thought Append should extend if required but it did not (or
> am
> > I using it incorrectly). I looked at some other code examples but could
> not
> > find a solution.
> >
> > In C there is an array copy function that is implemented by the
> processor
> > directly, it's been a long time since I used C and assembler but I
> rememer
> > there were non overlapping mem copy instructions that would make an
> array
> > copy very fast.
> >
> > Is there somthing similar in GO.
> >
> > This is a general question, it is not really specific to my application.
> I
> > just want to know the best practices for 'extending' an array of
> arbitrary
> > type.
>
> The append function should do exactly what you want, but you must use it
> properly.  There is a good explanation of slices on the Go blog at
> «https://blog.golang.org/go-slices-usage-and-internals».  The builtin
> append function will append to the existing backing array if there is
> enough capacity, but will allocate a new backing array if necessary.
> Because of this, it always returns the new slice, and you must use the
> returned slice, rather than the original.  Here is a playground link
> demonstrating the use of append:
> «https://play.golang.org/p/5Pl16hN-T5u».
>
> ...Marvin
>
> --
> 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/20191015115219.dca3mjcdj54qxslq%40basil.wdw
> .
>

-- 
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/CAN1Sb7w%2BXKLXmRrzS4biZTvZJ-eTbtWR8DOGfzdfp13S2%3Dx%3D3w%40mail.gmail.com.


Re: [go-nuts] Need explaination for code

2019-07-27 Thread thatipelli santhosh
Thank you for explaining that @brian Hatfield

On Sat, Jul 27, 2019, 00:02 Brian Hatfield  wrote:

> Welcome to Go!
>
> There's a couple things going on here, which you can break down into two
> overarching parts.
>
> Part 1, var/type definition:
>
> var testCases = []struct {
>  description string
>  planet  Planet
>  seconds float64
>  expectedfloat64
> }
>
> This says the following things:
>
>- Create a new variable, called testCases
>- testCases will contain a slice of (anonymous) structs ( []struct {.}
>)
>- and each of those structs will contain 4 fields: description,
>planet, seconds, expected
>
> Part 2, the instantiation/struct literal:
>
> {
>  {
>  description: "age on Earth",
>  planet:  "Earth",
>  seconds: 10,
>  expected:31.69,
>  },
>  {
>  description: "age on Mercury",
>  planet:  "Mercury",
>  seconds: 2134835688,
>  expected:280.88,
>  },
> [etc]
> }
>
> This says:
>
>- Instantiate this slice of structs right in-line (this is called a
>literal)
>- Repeated anonymous struct literals for each item in the slice
>
> The likely purpose of this code, overall, is so that later on down,
> something can iterate `testCases` and get a number of `testCase`, each with
> test expected values.
>
> You could also write this code like:
>
> type TestCase struct {
>  description string
>  planet  Planet
>  seconds float64
>  expectedfloat64
> }
>
> var testCases []TestCase
>
> testCases = append(testCases, TestCase{
>  description: "age on Uranus",
>  planet:  "Uranus",
>  seconds: 3210123456,
>  expected:1.21,
> })
>
> [.etc]
>
> with an append call for each case you want to add.
>
> The example you provided just streamlines the whole process, and takes
> advantage of slice literals, anonymous struct definitions, and implicit
> struct literals within a slice definition.
>
> Hope that helps!
> Brian
>
> On Fri, Jul 26, 2019 at 2:16 PM thatipelli santhosh <
> santhoshthatipelli...@gmail.com> wrote:
>
>> Hi ,
>>
>> I am learning Go step by step. I have go through with slices and structs
>> but this below code sample is using slices and structs both at a time.
>>
>> Can anyone please explain this piece of code? this would be more helpful
>> to me to understand this. Thank you!
>>
>> var testCases = []struct {
>>  description string
>>  planet  Planet
>>  seconds float64
>>  expectedfloat64
>> }{
>>  {
>>  description: "age on Earth",
>>  planet:  "Earth",
>>  seconds: 10,
>>  expected:31.69,
>>  },
>>  {
>>  description: "age on Mercury",
>>  planet:  "Mercury",
>>  seconds: 2134835688,
>>  expected:280.88,
>>  },
>>  {
>>  description: "age on Venus",
>>  planet:  "Venus",
>>  seconds: 189839836,
>>  expected:9.78,
>>  },
>>  {
>>  description: "age on Mars",
>>  planet:  "Mars",
>>  seconds: 2329871239,
>>  expected:39.25,
>>  },
>>  {
>>  description: "age on Jupiter",
>>  planet:  "Jupiter",
>>  seconds: 901876382,
>>  expected:2.41,
>>  },
>>  {
>>  description: "age on Saturn",
>>  planet:  "Saturn",
>>  seconds: 30,
>>  expected:3.23,
>>  },
>>  {
>>  description: "age on Uranus",
>>  planet:  "Uranus",
>>  seconds: 3210123456,
>>  expected:1.21,
>>  },
>>  {
>>  description: "age on Neptune",
>>  planet:  "Neptune",
>>  seconds: 8210123456,
>>  expected:1.58,
>>  },
>> }
>>
>>
>> --
>> 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/de5ac14e-0f10-4e84-ae07-10aecd9eb11d%40googlegroups.com
>> <https://groups.google.com/d/msgid/golang-nuts/de5ac14e-0f10-4e84-ae07-10aecd9eb11d%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/CAN1Sb7xn%2B6nUSKJLK5%2BcB%3D%3DKHuS6WbFVu%3DZo6_hkqPp6cLugwg%40mail.gmail.com.


[go-nuts] Need explaination for code

2019-07-26 Thread thatipelli santhosh
Hi ,

I am learning Go step by step. I have go through with slices and structs 
but this below code sample is using slices and structs both at a time.

Can anyone please explain this piece of code? this would be more helpful to 
me to understand this. Thank you!

var testCases = []struct {
 description string
 planet  Planet
 seconds float64
 expectedfloat64
}{
 {
 description: "age on Earth",
 planet:  "Earth",
 seconds: 10,
 expected:31.69,
 },
 {
 description: "age on Mercury",
 planet:  "Mercury",
 seconds: 2134835688,
 expected:280.88,
 },
 {
 description: "age on Venus",
 planet:  "Venus",
 seconds: 189839836,
 expected:9.78,
 },
 {
 description: "age on Mars",
 planet:  "Mars",
 seconds: 2329871239,
 expected:39.25,
 },
 {
 description: "age on Jupiter",
 planet:  "Jupiter",
 seconds: 901876382,
 expected:2.41,
 },
 {
 description: "age on Saturn",
 planet:  "Saturn",
 seconds: 30,
 expected:3.23,
 },
 {
 description: "age on Uranus",
 planet:  "Uranus",
 seconds: 3210123456,
 expected:1.21,
 },
 {
 description: "age on Neptune",
 planet:  "Neptune",
 seconds: 8210123456,
 expected:1.58,
 },
}


-- 
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/de5ac14e-0f10-4e84-ae07-10aecd9eb11d%40googlegroups.com.