[go-nuts] Re: printing a struct fields that implements an error interface

2018-02-18 Thread Diego Medina
using %#v

as in

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



log.Printf("Hello, playground %#v\n", ret)



On Saturday, February 17, 2018 at 7:05:42 PM UTC-5, Joseph Lorenzini wrote:
>
> Hi all:
>
> Per documentation:
>
> "If an operand implements the error interface, the Error method will be 
> invoked to convert the object to a string, which will then be formatted as 
> required by the verb (if any)"
>
> And this is so even if the struct implements the stringer interface. So if 
> I print the struct, I get the error value. Is there anyway to force 
> fmt.Print to output the struct fields, even when it implements the error 
> interface? 
>
> Thanks,
> Joe 
>

-- 
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: Participate in the Go 2018 Company Questionnaire

2018-10-07 Thread Diego Medina
Thanks for gathering this info, and the work you all put into Go, but I 
just went to answer it and I wonder how many people are going to answer 
this one wrong:

What are the preferred languages at your company? (top 4)
(Please list up to 4, 1 = most preferred)

scale is 1 to 4, in most surveys, the highest number would mean the "most" 
for the question, even though there is a fine print/hint saying 1 = most 
preferred, I can see some people miss that detail.

Regards,

Diego


On Thursday, October 4, 2018 at 3:13:05 PM UTC-4, c...@golang.org wrote:
>
> The Go project wants to hear from you!
>
>
> We need your help to create the best programming language for developing 
> simple, reliable, and scalable software. To do this, we need to better 
> understand how companies are using Go. Please help by participating in a 
> 7-minute company questionnaire.
>
>
> *Who:* If you are in a position to share details like “company name,” “if 
> your company is hiring Go developers,” and “reasons your team or company 
> adopted Go” then please help us by taking this company questionnaire. We 
> only need one response per company (or per department for larger 
> companies). If you aren’t the right person, please forward this onto the 
> right person at your company.
>
> *Please note: this is different from our annual anonymous Go user survey, 
> which* *will be announced in November.*
>
>
> *Where:* Please take this 7-minute questionnaire by October 30th: Go 
> Company Questionnaire 2018 .
>
> The questionnaire is confidential, but not anonymous. For more 
> information, please refer to Google’s privacy policy here 
> .
>
>
> The Go project leadership will use your responses to better understand how 
> companies use Go and in what ways we can improve their experience.
>
>
> Spread the word!
>
> We would like as many companies as possible to participate to help us 
> better understand our global user base. Please help us spread the word by 
> sharing this post on your social network feeds, at meetups, and in other 
> communities.
>
>
> 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] help with openpgp error: tag byte does not have MSB set

2018-11-22 Thread Diego Medina
Hi,

At work we get pgp encrypted files from different vendors, when our app 
tries to decrypt the file from one of them, I get:

openpgp: invalid data: tag byte does not have MSB set

But if I use the gpg command line, I'm able to decrypt it.


Part of the verbose output from gpg when it decrypts it is:

gpg --decrypt-files -vvv xyz.zip.pgp 
gpg: using character set `utf-8'
gpg: armor: BEGIN PGP MESSAGE
gpg: armor header: Version: EldoS PGPBlackbox (.NET edition)
:pubkey enc packet: version 3, algo 1, keyid AFF537579B90F252
data: [4095 bits]

gpg: public key encrypted data: good DEK
:pubkey enc packet: version 3, algo 1, keyid 
data: [4095 bits]
gpg: public key is 
:encrypted data packet:
length: unknown
mdc_method: 2


:literal data packet:
mode b (62), created 1542720445, name="xyz.zip",
raw data: unknown length
gpg: original file name='xyz.zip'
gpg: decryption okay


==

Any help solving this, or even better understand it would be great.

Thanks

Diego








-- 
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: Simple Go http daemon under systemd

2018-11-22 Thread Diego Medina
Check this repository

https://github.com/fmpwizard/mrwilson

* It runs a very simple https service
* Gets certificates using Let's Encrypt
* Has ansible playbook to run the app under systemd

feel free to ask any questions.

Diego




On Thursday, November 22, 2018 at 10:14:52 PM UTC-5, Tong Sun wrote:
>
> Hi, 
>
> I want to write a simple Go http daemon that return a static string 
> regardless what the request is, 
> like this one: 
> https://github.com/suntong/dbab/blob/master/src/bin/dbab-svr#L20
>
> and it needs to be working under systemd. 
>
> *What is the best example that I can start with?* (They both, Go http 
> daemon and systemd, and new to me)
>
> I found 
>
> enricofoltran /main.go 
> 
>
> A simple golang web server with basic logging, tracing, health check, 
> graceful shutdown and zero dependencies
>
>
> but it seems not supporting https requests,
>
> I also found 
>
> tabalt /gracehttp 
> 
>
> a simple and graceful HTTP server for Golang
>
>
> which seems quite complete, it has nice single-handling and https support. 
> but there is no mentioning of how it can work under systemd, which could 
> be troublesome, 
> like the question I found at why systemd cannot start golang web app 
> 
>
> Any help appreciated. Thx. 
>
>

-- 
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] Simple Go http daemon under systemd

2018-11-23 Thread Diego Medina
> I'm not looking for an service/socket example, 

if the service part is in reference to the repo I posted, where I said 
service, you can just assume I said an http endpoint you can visit with 
your browser, and it will return a status code, like

curl -v  https://mrwilson.one/status
*   Trying 45.55.162.45...
* Connected to mrwilson.one (45.55.162.45) port 443 (#0)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 592 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
*  server certificate verification OK
*  server certificate status verification SKIPPED
*  common name: mrwilson.one (matched)
*  server certificate expiration date OK
*  server certificate activation date OK
*  certificate public key: RSA
*  certificate version: #3
*  subject: CN=mrwilson.one
*  start date: Fri, 19 Oct 2018 18:15:16 GMT
*  expire date: Thu, 17 Jan 2019 18:15:16 GMT
*  issuer: C=US,O=Let's Encrypt,CN=Let's Encrypt Authority X3
*  compression: NULL
* ALPN, server accepted to use http/1.1
> GET /status HTTP/1.1
> Host: mrwilson.one
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Fri, 23 Nov 2018 20:00:33 GMT
< Content-Length: 0
< 
* Connection #0 to host mrwilson.one left intact

that endpoint returns no html just because I don't need it, but the status 
200 is there to tell me the app is running


a go deamon is just a go binary, nothing special

systemd works fine with any go binary that serves http









On Friday, November 23, 2018 at 2:18:28 PM UTC-5, Tong Sun wrote:
>
> [resending, sorry sam]
>
> On Fri, Nov 23, 2018 at 10:50 AM Sam Whited wrote:
>
>> On Thu, Nov 22, 2018, at 21:14, Tong Sun wrote:
>> > and it needs to be working under systemd. 
>> > …
>> > but there is no mentioning of how it can work under systemd, which 
>> could 
>> > be 
>> > troublesome, 
>> > like the question I found at why systemd cannot start golang web app 
>> > <
>> https://stackoverflow.com/questions/37297714/why-systemd-cannot-start-golang-web-app
>> >
>>
>> I'm not really sure what you're asking, Go binaries aren't doing anything 
>> special and systemd can start them just like any other program. Are you 
>> looking for an example service/socket file that lets you bind to port 443, 
>> or wondering what type of service to use? Or are you getting some other 
>> kind of error?
>>
>
> Both Go http daemon and systemd, and new to me, and I was looking for an 
> example that they work well together, and I found above. 
>
> No, I'm not looking for an service/socket example, just normal Go http 
> server started from systemd, and the only thing I found them both mentioned 
> is in above stackoverflow question 
> 
> . 
>
> Hence I'm asking for a simplest Go http daemon that works under systemd.
>
>  
>

-- 
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: golang on ec2; terraform, salt, etc.

2017-07-25 Thread Diego Medina
Hi,

For what you described, I wouldn't even use Docker (not trying to get into 
flame wars, just my opinion that not using it will keep your setup even 
simpler)

Some time ago I wrote this

https://github.com/fmpwizard/mrwilson/tree/master/ansible

it's a complete ansible set of playbooks, roles, etc that take a new fresh 
server running Fedora (so bare that it doesn't even have python) to a fully 
running server that has systemd setup for the service I'm deploying, sets 
some SELinux things, opens/closes ports using a firewall, etc.

It assumes a few things:

1. you compile your go program locally (or from a ci server where you run 
the ansible playbook)
2. your user can already ssh into the server

At work we use something similar, where our ci server running jenkins has a 
job that once triggered, it calls ansible, copies our files to the servers 
and then restarts the services

Hope it helps.

Diego




On Tuesday, July 25, 2017 at 1:45:00 PM UTC-4, Sankar wrote:
>
> Hi
>
> I have a golang REST api server. I cross-compile the monolithic golang 
> binary with GOOS=linux GOARCH=amd64 from my macbook (developer machine) and 
> then scp the binary to a ec2 vm. I have written a systemd service file to 
> manually bring down the service before the scp and bring up after the scp.
>
> I use RDS for database and run any migrations that are needed, after the 
> scp and before the service restart.
>
> Now I have reached a stage where I want the deployments to be continuous 
> and preferably from my CI system.  I have already written a Dockerfile 
> which is used in the CI system for testing. I do not want to use kubernetes 
> or anything complex at the moment because I am going to have only one 
> instance of my monolithic binary and also a free tier vm is sufficient for 
> my current needs.
>
> I am looking for tools / processes / best practices that people are 
> following to automate deploy of golang binaries on EC2. I prefer to use a 
> cloud-vendor-neutral-tool (such as terraform or saltstack) instead of 
> cloudformation. Can you share your golang production deploy experience ?
>
> Thanks a lot.
>
>
>

-- 
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: Code Review - Applying functions on custom types

2017-07-26 Thread Diego Medina
I think we have a similar setup to what you are trying to do, we also 
started with Scala and about 3 years ago we moved it to Go (still use Scala 
for other parts of our app).

While working in Scala and other languages you are encourage to abstract 
things as much as you can, in Go it is often better to just address the 
issues/requirements at hand and be clear on what you are doing.
In our case we define a struct that has the expected fields and types for 
each column, and as we walk each row, we check that we get the expected 
type, then it's a matter of cleaning/adjusting values as we need to, assign 
the result of this cell to a variable and continue with the rest of the 
cells on this row, once done, we initialize our struct and save it to the 
database, move to the next row and repeat.

Hope it helps.


On Wednesday, July 26, 2017 at 10:09:07 AM UTC-4, Sofiane Cherchalli wrote:
>
> The schema is statically specified. The values always arrive in a defined 
> order. Each value has a defined type.
>
> On Tuesday, July 25, 2017 at 3:01:14 AM UTC+2, rog wrote:
>>
>> On 24 July 2017 at 23:21, Sofiane Cherchalli  wrote:
>>
>>> Yes, I'm trying to stream CSV values encoded in strings. A schema 
>>> defines a type of each value, so I have to parse values to verify they 
>>> match the type. Once validation is done, I apply functions on each value.
>>>
>>
>> Is the schema dynamically or statically specified? That is, do you know
>> in advance what the schema is, or do are you required to write
>> general code that deals with many possible schemas?
>>
>>
>>

-- 
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: Code Review - Applying functions on custom types

2017-08-10 Thread Diego Medina
Hope you had a goo time on vacation.

No need for custom types, specially with csv files, all you get are
"string" type, but you know that some columns are actually float values, or
ints or plain text. So we have several functions that "clean, format, etc"
different kinds of data, and just call them with the value we get. For
example, we have:


func parseDateTimeOrZero(in string) time.Time {

rtd := strings.TrimSpace(in)
loc, _ := time.LoadLocation("America/New_York")

var t = time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)
for _, format := range dateLayouts {
stamp, er := time.ParseInLocation(format, rtd, loc)
if er == nil {
t = stamp
break
}
}
return t
}

dateLayouts is a slice of all the date time formats we support, we loop
over them until we get one that works, if not, we return the default value
(for our app this makes sense, in other cases we could return an error)


and while walking the csv, we just do:


if headers.versusDate != optionalErrorValue {
  versusDate = parseDateTimeOrZero(record[headers.versusDate])
}

// optionalErrorValue defaults to a high enough number that if our column
matcher hasn't updated the key index, it means we skip it, (we then have a
diff rule for mandatory fields)

so, instead of creating a new interface DateTimeColumn with a parse
function, it's just a stand alone function that is easy to understand, easy
to test.

We have been evolving this part of the tool for years, we have had
different developers work on it, adding new parsing rules, editing
existing, making some of them more flexible, and it hasn't been an issue.
The thought process is, I have a value and I need to clean it, you check
the list of functions to see if there is anything that looks like it does
what you want, if not, add a new one vs, let's find an interface or type
that
may have the things we need, then let's initialize that struct and call the
method on it.

BTW, when I first starting using Go, after working on scala for about 5
years, it felt really wrong to have so many top level functions, but after
a while you see how there is nothing wrong with top level functions.

Hope this helps.

Thanks

Diego



On Thu, Aug 10, 2017 at 12:17 PM, Sofiane Cherchalli 
wrote:

> Hi Medina,
>
> Sorry I was on vacations.
>
> So do you mean the way to do it is to hardcode most of functionality. No
> need to use custom types, interfaces. Just plain text parsing?
>
> In that case, how easy is it to evolve or refactor the code?
>
> Thanks
>
> On Wednesday, July 26, 2017 at 8:36:15 PM UTC+2, Diego Medina wrote:
>>
>> I think we have a similar setup to what you are trying to do, we also
>> started with Scala and about 3 years ago we moved it to Go (still use Scala
>> for other parts of our app).
>>
>> While working in Scala and other languages you are encourage to abstract
>> things as much as you can, in Go it is often better to just address the
>> issues/requirements at hand and be clear on what you are doing.
>> In our case we define a struct that has the expected fields and types for
>> each column, and as we walk each row, we check that we get the expected
>> type, then it's a matter of cleaning/adjusting values as we need to, assign
>> the result of this cell to a variable and continue with the rest of the
>> cells on this row, once done, we initialize our struct and save it to the
>> database, move to the next row and repeat.
>>
>> Hope it helps.
>>
>>
>> On Wednesday, July 26, 2017 at 10:09:07 AM UTC-4, Sofiane Cherchalli
>> wrote:
>>>
>>> The schema is statically specified. The values always arrive in a
>>> defined order. Each value has a defined type.
>>>
>>> On Tuesday, July 25, 2017 at 3:01:14 AM UTC+2, rog wrote:
>>>>
>>>> On 24 July 2017 at 23:21, Sofiane Cherchalli  wrote:
>>>>
>>>>> Yes, I'm trying to stream CSV values encoded in strings. A schema
>>>>> defines a type of each value, so I have to parse values to verify they
>>>>> match the type. Once validation is done, I apply functions on each value.
>>>>>
>>>>
>>>> Is the schema dynamically or statically specified? That is, do you know
>>>> in advance what the schema is, or do are you required to write
>>>> general code that deals with many possible schemas?
>>>>
>>>>
>>>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/golang-nuts/b0UQrfolaiY/unsubscribe.
> To unsubscribe from th

[go-nuts] Re: golang continuous deployment & gitlab

2017-08-20 Thread Diego Medina
Hi,

At work we have all of our deployment logic written in ansible and simply 
call an ansible playbook from jenkins (gitlab-ci in your case)

Here is a sample project using ansible 

https://github.com/fmpwizard/mrwilson/tree/master/ansible

it has all the roles, code, etc needed to start with a fresh fedora server 
provided by digital ocean (so bare that it starts by installing python 
using the raw command and then continues to use regular ansible code)

This file:

https://github.com/fmpwizard/mrwilson/blob/master/ansible/all_roles.sh

shows you the commands your ci would run, depending on what you need.

this deploys the binary:
ansible-playbook -i hosts/production playbooks/deploy.yml --ask-vault-pass 
-u root

and after it is deployed, 

ansible-playbook -i hosts/production playbooks/site-state.yml 
--ask-vault-pass --extra-vars "app_state=restart" -u root

restarts systemd

No docker in this setup, 

Hope it helps.

Diego




On Saturday, August 19, 2017 at 3:03:07 PM UTC-4, Sankar wrote:
>
> Hi
>
> I have a golang HTTP server that I am deploying on an AWS EC2 VM, as a 
> systemd service.
>
> Right now, I am manually deploying the service as follows:
>
> 1) vm$  sudo systemctl stop 
> 2) dev$ scp  
> 3)psql$ Apply migrations manually
> 4) vm$  sudo stystemctl start 
> 4) vm$  sudo stystemctl status  ;# Just to check
>
>
> I maintain my sources in gitlab and my database is postgres.
>
> I am planning to use gitlab-ci for preparing cross-compiled systemd 
> binaries and also sqitch for postgres migrations.
>
> I wanted to ask if there are any advises (or links to 
> tools/blogposts/scripts) from existing gitlab (or even github+ci) + golang 
> users, who do continuous deployments already. I can have some downtime and 
> 100% uptime is not important for me. Also, one instance of my server is 
> enough and there is no need for HA, load-balancing, etc. as of now, as it 
> is just an internal low-traffic service.
>
> I also thought of preparing an ubuntu ppa repository internally, on the 
> lines of 
> https://about.gitlab.com/2016/10/12/automated-debian-package-build-with-gitlab-ci/
>
> I am not using Docker (containers) because I do not want another layer 
> which may cause some unknown problems (performance, networking, etc.) which 
> I do not want to end up debugging.
>
> Any advises or suggestions or links that would help me ? Thanks.
>
> Sankar
>

-- 
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: Best way to launch/monitor several go process in production

2017-09-04 Thread Diego Medina
This
https://github.com/jpillora/overseer

may do what you need or at least give you an idea of what you can do.

The way oveerseer works is, you start your app, when you send a particular 
kill signal, it keeps the running app running and it spawns a duplicate, it 
passes new http requests to the new process while still serving current 
requests with the old binary, once the connections to the old binary are 
done (or timeout), the old process dies.

Regards,

Diego



On Sunday, September 3, 2017 at 5:35:30 PM UTC-4, emarti...@gmail.com wrote:
>
> Hello,
>
> I am looking for the 'best' way to launch and monitor several go 
> processes. Doing it with just 1 is easy enough, using monit or systemctl 
> should do the trick, however since our app takes a while to start, we want 
> to keep a few proceses running at all times so we don't have downtime 
> everytime the app needs to be restarted. Similar to how apache sub proceses 
> works. One of the solutions we are thinking is to create a go launcher that 
> will spawn sub processes and using systemctl on that launcher.
>
> Any recommendations? What do you guys use?
>
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] How to run escape analysis on subpackage

2017-09-14 Thread Diego Medina
Hi,

I have a project with a package main and then a few other packages inside 
it, something like:

$GOPATH//src/github.com/me/project-name
$GOPATH//src/github.com/me/project-name/packagea
$GOPATH//src/github.com/me/project-name/packageb

if I run

go build -gcflags "-m -m"

at $GOPATH//src/github.com/me/project-name

I get details referring to main.go

but what I'm looking for is information about packagea and I can't figure 
out what flag to pass to get this to work. Any pointers?

I tried

go build -gcflags "-m -m" github.com/me/project-name/packagea and nothing 
prints out, 



And as I was typing more examples of what didn't work, I got it, 

go build -gcflags "-m -m" packagea/file.go


Sending the email anyway in case another person runs into this.

Thanks

Diego

-- 
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 run escape analysis on subpackage

2017-09-14 Thread Diego Medina
Thanks James! I'm glad I posted the msg, and you are right, I edited the
file and then passing the package name printed info.

I had done

$go clean

hoping that was enough, but I guess that wasn't enough to clean all the
precompile code.

Thanks

Diego


On Thu, Sep 14, 2017 at 11:15 AM, James Bardin  wrote:

>
>
> On Thursday, September 14, 2017 at 10:58:27 AM UTC-4, Diego Medina wrote:
>>
>>
>> go build -gcflags "-m -m" github.com/me/project-name/packagea and
>> nothing prints out,
>>
>>
>>
> Nothing printed because it was already installed.
> You could update the timestamp on any of the package files, remove the
> existing object, or write a new one in a temporary location with
> `-o packagea.a`.
>
> Your workaround only succeeded because you were building a file rather
> than a package.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/golang-nuts/s11wByfGDoA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Diego Medina
di...@fmpwizard.com
https://blog.fmpwizard.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.


[go-nuts] Re: Serialized HTTP requests with asynchronous responses

2017-09-26 Thread Diego Medina
Hi,

Probably not the answer you were expecting, but :

> The nonces must be received by the host in ascending order.

is going to fail sooner or later, no matter which trick/feature you use. A 
more robust solution would be to code the server to accept unordered 
requests and handle them gracefully.

To give you a concrete example or where such assumption/requirement fails:

1. first requests goes out
2. server starts reading the request including the nonce
3. second request goes out with a new nonce
4. the network from req 1 fails so the server did not finish reading the 
complete payload
5. req from step 3 finishes

Now the server **doesn't** have req 1. The higher the concurrency, the 
higher the chances of this issue from happening and being harder to handle 
from the client side.

Or , would something like this https://github.com/savaki/snowflake help you 
by creating unique IDs with *some* ordering?

Final question, is the nonce used anywhere as a cryptographic IV/Salt/etc? 
If so, I wouldn't use an ID that increments, but instead use something 
really random, like crypto/rand


Regards,

Diego


On Tuesday, September 26, 2017 at 1:40:38 AM UTC-4, Donovan wrote:
>
> Hi,
>
> I have an interesting problem where I need to make a rapid series of HTTP 
> requests to the same host, each with a nonce which increments with each 
> request and a signature of the request body including that nonce, but I 
> don't want to wait for the response before sending the next request. The 
> nonces must be received by the host in ascending order.
>
> I've tried this using standard library HTTP requests, each running in 
> separate goroutines with a time delay before releasing the next nonce, to 
> try and ensure that the requests are sent in order, but this fails 
> intermittently, possibly due to network delays. I've also looked at 
> PipelineClient with MaxConns set to 1, which seems closer to what I need, 
> but it would still require an asynchronous response to prevent blocking 
> between request dispatches.
>
> https://godoc.org/github.com/valyala/fasthttp#PipelineClient
>
> Has anyone battled a problem similar to this before? Any ideas much 
> appreciated!
>
> Cheers,
> Donovan.
>

-- 
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: Why are two slices in this example less costly than one?

2017-10-13 Thread Diego Medina

>
>
> This is exactly what I was trying to figure out how I would be able to do, 
> and more specifically, if there's an easy way to find out.
>
>

the pprof tool can read a memory or cpu  profile created during your 
benchmark, and then you can see details of your function, line by line, and 
see the amount of allocations you are making, this should help you see the 
differences between one implementation vs the other 

once you are inside the pprof tool, you can run

list 

and it will give you the details

here is a post I recently wrote, in case you haven't used pprof with go 
code before 

https://blog.fmpwizard.com/2017/09/29/memory-profiling-in-go/

Regards,

Diego

 

> On Tuesday, 10 October 2017 15:38:58 UTC+2, Ian Lance Taylor wrote:
>>
>> On Tue, Oct 10, 2017 at 12:50 AM, Gabriel Aszalos 
>>  wrote: 
>> > 
>> > I would love to find out the answer to this. Even if you don't know the 
>> > answer but know how to investigate into it (using pprof or some tracing 
>> > flags), I would also appreciate being guided in the right direction and 
>> I 
>> > would love to embark on the journey of finding out myself. 
>> > 
>> > What I'm basically saying is that I'd be more interested to find out 
>> the way 
>> > in which I can tell why one is faster than the other, as opposed to 
>> hearing 
>> > just the final answer. Hope that makes sense. 
>>
>> Start by writing a standalone x_test.go program that provides both 
>> versions of the code and uses the benchmark framework to measure both. 
>> When you can repeat the issue with -bench=., run it with -benchmem to 
>> print the memory allocations.  If they are different, that is probably 
>> the cause.  Then you have to figure out why they are different.  If 
>> they are not different, you'll need to look at the generated code.  On 
>> GNU/Linux, the system's perf tool can help you identify which parts of 
>> the code take more time.  For a larger program I would suggest pprof, 
>> but pprof is better at pointing you at a specific function then it is 
>> at identifying which part of the function is slow. 
>>
>> Ian 
>>
>>
>> > On Thursday, 5 October 2017 15:22:47 UTC+2, Marvin Stenger wrote: 
>> >> 
>> >> I can reproduce the numbers. The only think I'm seeing is that the 
>> spans 
>> >> array is allocated on the stack. Not sure though if this is the only 
>> reason. 
>> >> 
>> >> Am Donnerstag, 5. Oktober 2017 13:13:56 UTC+2 schrieb Gabriel Aszalos: 
>> >>> 
>> >>> I was playing around with the implementation of FieldsFunc from the 
>> bytes 
>> >>> package and I was wondering how it would affect the benchmarks to 
>> disregard 
>> >>> the extra slice that was used there to calculate offsets. It only 
>> made sense 
>> >>> that it would make things faster. 
>> >>> 
>> >>> To my amusement (although expected), it didn't. But I'm quite curious 
>> why 
>> >>> one is faster than the other and if this reveals any good practices 
>> when 
>> >>> working with similar algorithms. The benchmark and diff I am talking 
>> about 
>> >>> can be viewed here: 
>> >>> 
>> >>> 
>> >>> 
>> https://github.com/gbbr/go/commit/2f6e92bc746fa232f2f2aea66dae3fa0c04700a5?diff=split
>>  
>> >>> 
>> >>> Many thanks for looking! 
>> >> 
>> >> 
>> > -- 
>> > 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] Re: Iota with string constants

2017-10-16 Thread Diego Medina
If it is something like weekdays (very few options), I don't see any issues 
with it. Stringer is great when as you go along using your app, you may 
need to add more values over time.

using iota and stringer is great when your list may be 15 or more items, 
and keeping them updated becomes a chore you would like to avoid.

Regards,

Diego


On Sunday, October 15, 2017 at 8:12:14 PM UTC-4, Inanc Gumus wrote:
>
> Yep, I know that one, I’m asking about the convention, idioms and the 
> performance-wise.
>
> Inanc Gumus
>
> Marvin Stenger > şunları yazdı (16 
> Eki 2017 02:45):
>
> You could also use this:
> https://godoc.org/golang.org/x/tools/cmd/stringer
>
> -- 
> You received this message because you are subscribed to a topic in the 
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/golang-nuts/mbHdiXkb7iU/unsubscribe.
> To unsubscribe from this group and all its topics, 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] time.Parse with millisecond separated by colon

2017-10-30 Thread Diego Medina
Hi,

I need to parse datetime data given in a csv file, the format I get (I get 
a lot of diff ones but the latest is):

20060102 15:04:05:000

but if I use that with time.Parse, it doesn't parse the millisecond part, 
tells me:

parsing time "20170628 12:11:00:103" as "20060102 15:04:05:000": cannot parse 
"103" as ":000"



if I change the format, from :000 to .000 and then change my source time, 
to be  12:11:00.103

it does parse. Is there a way to avoid having to edit the source file, so I 
can just take the datetime info as it is in the file?

playground example:

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

Thanks

Diego

-- 
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: time.Parse with millisecond separated by colon

2017-10-30 Thread Diego Medina
Thanks, for our case, it will be easy enough to just change : for . and 
move on from there.

Thanks

On Monday, October 30, 2017 at 4:55:03 PM UTC-4, Rob 'Commander' Pike wrote:
>
> Or you could change the : to a . and use time.Parse.
>
> -rob
>
>
> On Tue, Oct 31, 2017 at 4:47 AM, Jim Cote 
> > wrote:
>
>> See https://golang.org/src/time/format.go?s=23626:23672#L249.  The 
>> standard library is explicitly looking for the period.  Your easiest 
>> solution would be to just write your own parser.
>>
>>
>> On Monday, October 30, 2017 at 11:20:51 AM UTC-4, Diego Medina wrote:
>>>
>>> Hi,
>>>
>>> I need to parse datetime data given in a csv file, the format I get (I 
>>> get a lot of diff ones but the latest is):
>>>
>>> 20060102 15:04:05:000
>>>
>>> but if I use that with time.Parse, it doesn't parse the millisecond 
>>> part, tells me:
>>>
>>> parsing time "20170628 12:11:00:103" as "20060102 15:04:05:000": cannot 
>>> parse "103" as ":000"
>>>
>>>
>>>
>>> if I change the format, from :000 to .000 and then change my source 
>>> time, to be  12:11:00.103
>>>
>>> it does parse. Is there a way to avoid having to edit the source file, 
>>> so I can just take the datetime info as it is in the file?
>>>
>>> playground example:
>>>
>>> https://play.golang.org/p/cHTDxFYmrF
>>>
>>> Thanks
>>>
>>> Diego
>>>
>> -- 
>> 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: Go vendoring question

2017-11-01 Thread Diego Medina
I have been using https://github.com/FiloSottile/gvt for years, it's great, 
simple, you vendor only what you want, so, in this case, that one lib you 
are talking about

you can even leave the imports as they are, but point to your own fork of 
the repo by modifying the manifest file

for example, we run a modified version of mgo (mongo driver) so our 
manifest has

{
"importpath": "gopkg.in/mgo.v2",
"repository": "https://github.com/ascendantcompliance/mgo";,
"vcs": "git",
"revision": "cded8d2220d584e95dd80ddd67934ab9e80e908d",
"branch": "v2",
"notests": true
}




Regards,

Diego


On Tuesday, October 31, 2017 at 2:43:21 PM UTC-4, Travis Keep wrote:
>
> Somebody I depend on for my project made a breaking change to their git 
> repo and broke my build.
>
> I found that if I simply revert their latest commit locally that my 
> project builds.  
>
> I don't necessarily want to vendor everything because most of the 
> libraries I use I trust. But I do want to vendor the one git repo whose 
> owner keeps making breaking changes. 
>
> I looked at dep, but dep seems to vendor everything. I don't want that. I 
> just want to vendor the one unstable library, and simply use HEAD for 
> everything else.
>
> What is the best way for me to proceed?  
>
> 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.
For more options, visit https://groups.google.com/d/optout.


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

2017-11-08 Thread Diego Medina
replied on the mgo list 

https://groups.google.com/d/topic/mgo-users/F3LbWdyPGDc/discussion

(pasted here to save a click)

Hi,

> the checkbox is unchecked and form is submitted to save. Now as I have 
applied "omitempty" 

if the checkbox is unchecked, your client side code should send "false" to 
the go server, so omitempty is not applied because it is not empty, it is 
false, so saving it to mongo will actually update the field.

for truly optional fields, what I do is, declare the fields as pointers to 
the type, so, you would have

type Coupon struct {
Id   *int`json:"id,omitempty" bson:"_id,omitempty"`
Name *string `json:"name,omitempty" bson:"name,omitempty"`
Code *string `json:"code,omitempty" bson:"code,omitempty"`
Description  *string `json:"description,omitempty" 
bson:"description,omitempty"`
Status   *bool   `json:"status" bson:"status"`// I assume this 
is also optional
MaxUsageLimit*int`json:"max_usage_limit,omitempty" 
bson:"max_usage_limit,omitempty"`
SingleUsePerUser *bool   `json:"single_use_per_user,omitempty" 
bson:"single_use_per_user,omitempty"`
}


the bson/json Un/marshaller will then omit the values that are nil 
pointers, so now yo ucan tell the difference between a false checkbox, and 
a REST POST that did not include the field at all

Hope this helps.

Diego

On Wednesday, November 8, 2017 at 12:46:39 AM UTC-5, Amandeep Kaur wrote:
>
>
> Hi
>
> I am working on a Coupon form in which I have some optional fields. 
>
> *Introduction:*
>
> All the form field values are received as JSON and mapped into a Golang 
> structure. In the structure, I have added an "omitempty" flag with every 
> field. So only those form values are mapped which have some appropriate 
> value, rest of the values like 0, " ", false are ignored by the structure.
>
> Here is the Golang structure
>
> type Coupon struct {
> Id   int`json:"id,omitempty" bson:"_id,omitempty"`
> Name string `json:"name,omitempty" bson:"name,omitempty"`
> Code string `json:"code,omitempty" bson:"code,omitempty"`
> Description  string `json:"description,omitempty" 
> bson:"description,omitempty"`
> Status   bool   `json:"status" bson:"status"`
> MaxUsageLimitint`json:"max_usage_limit,omitempty" 
> bson:"max_usage_limit,omitempty"`
> SingleUsePerUser bool   `json:"single_use_per_user,omitempty" 
> bson:"single_use_per_user,omitempty"`}
>
> *Problem:*
>
>1. 
>
>When I save this form for the very first time, the form values that 
>are appropriate are saved into the Mongodb.
>2. 
>
>Now I want to update that form and suppose there is a check box, which 
>was checked at the time of saving data. While updating form, the checkbox 
>is unchecked and form is submitted to save. Now as I have applied 
>"omitempty" flag in the structure, so its not mapping the empty value to 
>the checkbox field. Since the value is not mapped into the structure, its 
>not getting saved into the Database. 
>3. 
>
>When a user edits the form for the second time, it sees the same check 
>box as checked. (But practically, the value should be updated to the DB 
> and 
>the check box should be displayed as unchecked.)
>4. 
>
>I am using the same form data (in JSON format) in a REST API. In API, 
>while updating form data, if I mention only those values which are 
> required 
>and don't pass the values which I don't want to update, then MongoDB is 
>overriding the whole document with the provided required values(Even those 
>values are also being overridden which I don't want to update as well as 
>don't pass in the API).
>
> *Requirement:*
>
> In future, I want to expose the REST API, So I don't want this thing to be 
> happened there. That is why I don't want to remove "omitempty" flag from 
> the structure fields. 
>
> Is there any way to save the empty form values or API data fields to the 
> DB while using omitempty flag in the structure?
>
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] xml Unmarshal does not see expected type

2017-11-16 Thread Diego Medina
Hi,

At work I have 3 different xml files I need to parse (different fields 
each), Because going from the xml bytes into a struct is pretty much the 
same
for all 3 types, I thought I could do something like


var payload interface{}

if kind == "A" {
  paylaod = TypeA{}
}


if kind == "B" {
  paylaod = TypeB{}
}


if kind == "C" {
  paylaod = TypeC{}
}



xml.Unmarshal([]byte(file), &payload)

but this fails. It doesn't give me an error, but Unmarshal doesn't 
recognize the payload variable as the right (new) type.

I created a very simple snippet here 

https://play.golang.org/p/QvVbM--Zdt

produces:

gen is type: main.X //<== see how the type is correct here
xml gen is {One:}
json gen is map[One:uno]
gen is type: main.X //<== here I declared the variable with the right type 
and Unmarshal works
xml gen is {One:uno}
json gen is {One:uno}

Hope this is enough information.

Thanks

Diego

-- 
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] xml Unmarshal does not see expected type

2017-11-16 Thread Diego Medina
Hi Jakob,

Thanks for your reply, maybe my original email didn't include enough
information. What you described is what I ended up doing as a work around
in my code:


if kind == "a" {
var ret trading.TypeA
if err := ParseRefData(f, &ret); err != nil {
log.Fatalf("failed to decode file: %s from zip: %s, error:
%s", row.Name, path, err)
}
prepareFeedForMongo(acmsess, stats, ret)
}
if kind == "b" {
var ret trading.TypeB
if err := ParseRefData(f, &ret); err != nil {
log.Fatalf("failed to decode file: %s from zip: %s, error:
%s", row.Name, path, err)
}
prepareFeedForMongo(acmsess, stats, ret)
}
if kind == "c" {
var ret trading.TypeB
if err := ParseRefData(f, &ret); err != nil {
log.Fatalf("failed to decode file: %s from zip: %s, error:
%s", row.Name, path, err)
}
prepareFeedForMongo(acmsess, stats, ret)
}


See how I'm calling ParseRefData and prepareFeedForMongo 3 times and
handling errors in 3 diff places, I'd like to handle the errors on one
place, and call ParseRefData and prepareFeedForMongo only once, all I'd
like to do inside each if statement is "change" the type of ret to
the expected type.

Unless this isn't possible, but I wonder why Printf %T shows me the type I
was expecting.

Thanks

Diego




On Thu, Nov 16, 2017 at 4:13 PM, Jakob Borg  wrote:

> You are setting an interface to a struct value, then passing Unmarshal a
> pointer to the interface. This is the wrong “order” of pointers and will
> result in Unmarshal overwriting the pointed to interface with the map. What
> you want to do is pass Unmarshal a pointer to your struct type:
>
> var x X{}
> err := xml.Unmarshal(data, &x)
>
> or, equivalently via an interface:
>
> var x X{}
> var intf interface{} = &x
> err := xml.Unmarshal(data, intf)
>
> This boxing is exactly the same thing that happens automatically in the
> first function call.
>
> //jb
>
>
> On 16 Nov 2017, at 21:52, Diego Medina  wrote:
>
> Hi,
>
> At work I have 3 different xml files I need to parse (different fields
> each), Because going from the xml bytes into a struct is pretty much the
> same
> for all 3 types, I thought I could do something like
>
>
> var payload interface{}
>
> if kind == "A" {
>   paylaod = TypeA{}
> }
>
>
> if kind == "B" {
>   paylaod = TypeB{}
> }
>
>
> if kind == "C" {
>   paylaod = TypeC{}
> }
>
> 
>
> xml.Unmarshal([]byte(file), &payload)
>
> but this fails. It doesn't give me an error, but Unmarshal doesn't
> recognize the payload variable as the right (new) type.
>
> I created a very simple snippet here
>
> https://play.golang.org/p/QvVbM--Zdt
>
> produces:
>
> gen is type: main.X //<== see how the type is correct here
> xml gen is {One:}
> json gen is map[One:uno]
> gen is type: main.X //<== here I declared the variable with the right type
> and Unmarshal works
> xml gen is {One:uno}
> json gen is {One:uno}
>
> Hope this is enough information.
>
> Thanks
>
> Diego
>
> --
> 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.
>
>
>


-- 
Diego Medina
Go Consultant
di...@fmpwizard.com
http://blog.fmpwizard.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.


[go-nuts] Re: Learning Go: suggestions for code review?

2017-12-13 Thread Diego Medina
Don't do relative imports (littlelang/tokenizer) or . littlelang/tokenizer 
. Unless you want to run into corner cases with tools not knowing where 
code is defined or if you want to confuse other developers.

Using the full path makes it very clear where the code is, yes, if you move 
things around.refactor you may have to edit the path, but in Go it's not 
about saving the writer of code time, it's about saving all the readers of 
code time (including yourself in a year).

That's the only big thing I noticed on your project, the rest looks good.
One minor thing may be that instead of using os.Args, I would use the 
flag's package.


Best regards,

Diego

 

On Wednesday, December 13, 2017 at 9:27:08 AM UTC-5, matthe...@gmail.com 
wrote:
>
> I've used the full github path (github.com/benhoyt/littlelang/tokenizer) 
> for my subpackages when importing them but the tradeoffs for your approach (. 
> "littlelang/tokenizer") isn't clear to me.
>
> You've put care into error handling and unit testing and the code looks 
> maintainable as a professional project to me.
>
> Matt
>
> On Tuesday, December 12, 2017 at 6:31:54 PM UTC-6, Ben Hoyt wrote:
>>
>> Hi folks,
>>
>> I've recently been learning Go on the side, so haven't had work 
>> colleagues to discuss best practices with. To speed up the learning 
>> process, I'm wondering if anyone would like to review the Go code in my 
>> side project (a toy language, kind of a cross between JavaScript and Python 
>> with Go syntax). I'm not too interested in a review of the project itself, 
>> but simply a pure code review to help me grok Go idioms and best practices.
>>
>> I realize this may be a big request, but any pointers/feedback would be 
>> useful. Is anyone here interested in giving some feedback? Or if not, is 
>> there a better place to ask? I'm happy to contribute in a similar way to 
>> other people's projects too (though I'm more at home in Python right now). 
>> I thought about the Code Review Stackexchange, but that seems more for 
>> review of short code snippets.
>>
>> My project lives at: https://github.com/benhoyt/littlelang
>>
>> Thanks,
>> Ben
>>
>>

-- 
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: Badger Write Performance

2018-01-21 Thread Diego Medina
The use of SyncWrites=false on badger's benchmark was called out on reddit 
and the benchmark author's reply was along the lines of "it's ok for our 
use case to lose the last few [seconds|ms] of data"

You draw your conclusion on where you want to keep your data.





On Thursday, January 18, 2018 at 2:33:02 PM UTC-5, dc0d wrote:
>
> Badger write performance is a bit worse than boltdb. And badger suggests 
> to batch writes. But so does boltdb.
>
> At the same time at badger's GitHub page it says it has higher write 
> performance compared to boltdb.
>
> Is there a sample of how to do high performance/throughput writes with 
> badger?
>

-- 
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: Modules - Issues releasing cron/v3

2019-07-16 Thread Diego Medina
As a regular user, I wouldn't expect go get to give me v1 all the time, I 
would expect to get all kinds of breaking builds all the time because that 
is the reality of go get.
And for those who enter tickets asking why? I would nicely explain that go 
get is the quick and dirty way to get started with go, but not the way to 
use it on real app, when you really want a stable build, it is time to use 
go modules (and vendor for extra safety), or one of the vendor options out 
there if you have reasons 
not to use go modules.


imho, using github's default branch option and set it to v3 is the way to 
go, but there may be some other go module ways of handling this, iirc, 
there is also the option of creating a whole v3 folder, not just a branch

Thanks

Diego



On Tuesday, July 16, 2019 at 11:03:42 AM UTC-4, robfig wrote:
>
> I maintain the github.com/robfig/cron package, and I have just released 
> v3 using Modules via the branch mechanism (so it's on a v3 branch), but I'm 
> having some issues. 
>
> Here are things that would be ideal:
> - When people visit github.com/robfig/cron, I would like them to see the 
> v3 version
> - Similarly, when people create pull requests, I would like them to be 
> against the v3 branch by default.
> - I would like to have godoc available in the usual place. godoc.org does 
> not seem to be module aware, so 
> https://godoc.org/github.com/robfig/cron/v3 does not work.
> - "master" reflects ongoing development of v3, rather than being frozen in 
> time as the v1 branch. (minor)
>
> I tried to accomplish this by changing the "default branch" from master to 
> v3. However, that had the effect of breaking everyone who uses "go get" 
> without version pinning, since they expected v1. I just reverted that 
> settings change.
>
> Here's my next-best solution:
> - Update the README for v1 and v2 to have a big banner to direct folks to 
> v3
> - Link to godoc via gopkg.in: https://godoc.org/gopkg.in/robfig/cron.v3
>
> That works, but it's problematic because (AFAIK) users can NOT actually 
> import `gopkg.in/robfig/cron.v3` , they 
> must import `github.com/robfig/cron/v3` , 
> so the instruction that godoc.org adds at the top of every page to import 
> this package will fail.
>
> Unless I'm missing something, not having godoc for module versions seems 
> like a pretty major problem. Is there something I'm missing?  How are other 
> maintainers dealing with this?
>
> Thanks for your advice,
> -Rob
>
>

-- 
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/a4e747b8-b043-47c3-88c9-893763e2f963%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: redirecting http to https

2019-09-25 Thread Diego Medina
You can run a go routine similar to:


go func() {
log.Fatal(http.ListenAndServe(":80", http.HandlerFunc(httpToHTTPS)))
}()


//httpToHTTPS redirects all http to https
func httpToHTTPS(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "https://"+r.Host+r.URL.String(), 
http.StatusMovedPermanently)
}


Regards,

Diego



On Tuesday, September 24, 2019 at 7:37:02 PM UTC-4, Julia Ma wrote:
>
> Hi all,
> I recently realized that request.URL.Scheme is not the correct field to 
> check whether a request is https or not (thank you to this thread 
> 
>  
> and other posts on the internet). Once I've determined that the request is 
> http, what do I set the request.TLS to to ensure the redirect is https?
> Thanks,
> Julia
>

-- 
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/b700c613-df41-475a-b49d-b30d70015ed8%40googlegroups.com.


[go-nuts] [Job] Remote Junior Go developer - Full time employee (US and parts of Europe)

2019-10-16 Thread Diego Medina
Hi,

We are looking for a new developer to join our small team. We work in the 
compliance regulations area, if that sounds vague, don't worry, we'll teach 
you the relevant parts.

You will be enhancing our current data sanitation platform. We get files 
from different vendors in all kinds of formats, csv, txt, fixed length, you 
name it, and then we clean the data and store them
in our Mongo cluster.

We are hoping to fill this as an employee position, and that limits the 
countries to:

* US
* Ireland
* UK
* Netherlands
* France
* Sweden

but if you are a contractor and this sounds interesting (and live somewhere 
else), reach out and we may be able to make an exception.

What do we offer?

A friendly work environment, where nobody is expected to know it all but 
instead, you are encourage to ask for help when needed.
We communicate using https://www.flowdock.com and may have at most 7 phone 
calls a year.

Skills & requirements:

* Go (minimum knowledge and be willing to learn the rest)
* Mongo (know how to use the mgo driver, we don't do anything fancy with 
it.)
* git
* The most important skill, be willing to accept feedback during feature 
planning and during code review.


To apply you can email your CV in pdf format to diego.med...@cssregtech.com 

(if the address is hidden by google, use my first name  dot last name and 
the domain is cssregtech.com )

Thanks

Diego Medina

VP Engineering
https://www.ascendantcompliancemanager.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/17600271-4030-4ec4-b0c8-60dbd49bc3af%40googlegroups.com.


[go-nuts] Re: Performance Counters

2016-08-29 Thread Diego Medina

Hi,

You may want to look at

https://golang.org/pkg/expvar/

If your app is already running the built in server, you can 

import _ "expvar"

and then you will see a lot of internal counters at

localhost:6060/debug/vars

you can then add your own counters to it, which will also be displayed 
under that same url


Here is a blog post about integrating it datadog (you can use any 
monitoring tool you wish though)

https://www.datadoghq.com/blog/instrument-go-apps-expvar-datadog/

Hope that's what you were looking for.

Thanks

Diego


On Monday, August 29, 2016 at 12:34:26 AM UTC-4, Mark Richman wrote:
>
> I'm relatively new to Go, coming from a Windows/.NET background primarily. 
> Does the Go runtime itself offer performance counters similar to what 
> Windows makes available via perfmon? Specifically, I'm looking to capture 
> realtime (not via a dump) metrics on heap usage, thread counts, GC 
> collections, HTTP queue length, etc.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: create a .rpm file for go app.

2016-09-21 Thread Diego Medina
You could also use 
https://equinox.io/


once you have your token. keys, etc all setup, you can build new releases 
rpm, deb, etc using 

equinox release \
--version="1.0.0" \
--platforms="darwin_amd64 linux_amd64" \
--signing-key=/Users/inconshreveable/equinox.key \
--app="app_ja6WuaZgwsF" \
--token="4kj5ypgZj3QeGvGz7LckDGvcAcdmUozUNU8YhVhEg97r7dcmFgy" \
github.com/example/tool


https://equinox.io/docs#building-your-first-release

Regards,

Diego




On Tuesday, September 20, 2016 at 2:53:39 PM UTC-4, sujith...@gmail.com 
wrote:
>
>
> Right now, to build my .rpm package, I'm using this website: 
> https://packager.io/
>
> However, I would like to automate this in our prod enviroment. Whats the 
> best way? Any plugins or tools available to build the .rpm file from the GO 
> App code? I have Dependencies saved using GODEP.
>
>
>

-- 
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 beginner asks for code review

2016-09-22 Thread Diego Medina
Hi,

First, awesome that you started using Go! some thoughts inline:

 

> 1. The sbxs_ prefix is there just because I expect this package to be part 
> of a set of related repositories and I wanted to give them some "unity" 
> through naming. Arguably a bad idea, I am not sure about it.
>

I have seen two ways other Go developers have "solve" this,

1. Create a dedicated organization/github account for this group of repos, 
like

http://www.gorillatoolkit.org/

if you see that link (you probably are familiar with it already but if not)

you have:

gorilla/context
gorilla/mux
gorilla/reverse
gorilla/rpc 
gorilla/schema
gorilla/securecookie
gorilla/sessions 
gorilla/websocket

and people in the community refers to them as " ... have you tried gorilla 
mux? ..." , etc 

2. in your github account you create a repo sbxs, and inside there you add 
a folder go_markydown

if then you have a new component that is related, you create a new folder, 
go_asciidoc inside sbxs

this is somewhat similar to juju iirc

https://github.com/juju/juju


 

>
> 2. I added "go" to the package name because I tend to experiment with 
> different languages from time to time, and therefore I have a reasonable 
> chance to have naming conflicts without it.
>
>
this is a personal preference, you have your reason, sounds good to me :)
 

> 3. I added that extra "markydown" directory just because I read on 
> Effective Go that it is a convention to give the package name the same name 
> as the directory, and I thought that "markydown" was a better package name 
> than "sbxs_go_markydown". Maybe I should just use the long package name and 
> let users rename it when importing if they wish? Or is there  some better 
> way?
>
>
skipping this one.

Thanks!



 

> Thanks again!
>
> LMB
>
>

-- 
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: Trying to understand GOPATH

2016-09-23 Thread Diego Medina
As you start working with Go, one other thing you may want to add to your 
~/.bash_profile (on linux and mac, not sure about others) is



CDPATH=.:$GOPATH/src/code.google.com/p:$GOPATH/src/github.com:$GOPATH/src/bitbucket.org
export CDPATH

so let's say you have $GOPATH as 

/home/my-name/work/golang

and a project at $GOPATH/src/github.com/fmpwizard/my-project

without the CDPATH, you would have to do :

cd $GOPATH/src/github.com/fmpwizard/my-project to go in there

with CDPATH you simply do

cd fmp (press tab and autocomplete will fill in the rest)

(not my original idea, got it From Rob 
Pike https://twitter.com/rob_pike/status/467367507305574400 )


Thanks

On Friday, September 23, 2016 at 7:48:06 AM UTC-4, leon.j...@gmail.com 
wrote:
>
> Thanks for the response, it makes sense now.
>
> On Friday, September 23, 2016 at 12:13:30 AM UTC-4, leon.j...@gmail.com 
> wrote:
>>
>> I'm new to golang, and I'm trying to understand the role of GOPATH. The 
>> OS X package from https://golang.org/dl/ installs to 
>> `/usr/local/go/bin/go`. 
>>
>> Do I have to manually symlink /usr/local/go/bin/go to my PATH because the 
>> GOPATH docs lead me to believe that GOPATH to need to be set to the 
>> directory where my go code is located. 
>>
>> Example of my code directories:
>>
>> git
>> ├── bitbucket
>> │   └── demo1
>> ├── github
>> │   ├── notes
>> │   ├── scripts
>> │   └── snippets
>> ├── github-work
>> │   ├── ruby-app1
>> │   ├── ruby-app2
>> │   └── ruby-app3
>> └── gitlab
>> ├── javascript-app1
>> ├── python-app1
>> └── (go-app1)
>>
>> I'd like to be able to keep this structure the same, but I don't see how 
>> this is possible with GOPATH pointing to a single directory. 
>>
>> What if I want to organize my code by version control location and not by 
>> language?
>>
>>

-- 
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: SimpleHttpServer built into go toolchain?

2016-09-29 Thread Diego Medina
Hi,

If you don't want to have to copy/paste that snippet of code on a new 
laptop/OS install, I have been using:

$ go get github.com/rif/spark
$ spark static_site/

for the last couple of years, works great, it's simple.

https://github.com/rif/spark

Regards,

Diego

On Thursday, September 29, 2016 at 11:10:29 PM UTC-4, Dave Cheney wrote:
>
> > Since Go is battery included and http is part of its core  library,
>
> We said batteries, not the kitchen sink.
>
> But seriously, the standard library gives you the components to build 
> these tools yourself. If the Go distro included a http server that just 
> served static files, while this would be perfect for your use case, others 
> who wanted a server that forwarded to FastCGI would be incensed that Go 
> shipped with such a limited tool, and furthermore we refused to improve it. 
> It's better to give you the tools to write exactly the program you want, 
> then you can share it with the world via go get.
>
> On Friday, 30 September 2016 12:14:26 UTC+10, Darren Hoo wrote:
>>
>> One thing that I really like about python is this one command line to 
>> serve static files:
>>
>>  python -m SimpleHTTPServer
>>
>>
>> This is very convenient. 
>>
>>
>> Now I just want to use Go to do the same thing, I have to copy the 
>> snippet from 
>>
>> https://github.com/golang/go/wiki/HttpStaticFiles and go run it.
>>
>>
>> Since Go is battery included and http is part of its core  library, why 
>> not 
>>
>> just build it into the Go toolchain, So every time I want to serve static 
>> files, 
>>
>> I can fire up go like this:
>>
>>
>>  go tool http  /usr/share/doc
>>
>>
>>  go tool http  --addr=: /usr/share/doc
>>
>>
>>
>>
>>
>>

-- 
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] time.Parse : hour out of range

2016-10-18 Thread Diego Medina
Hi,

>From a 3rd party I get a file with time like 1503  or 900 (meaning 3:03PM 
or 9:00 AM)

so I thought I could use this format:

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

x, err := time.Parse("1504", "900")

but the result is:

2009/11/10 23:00:00 parsing time "900": hour out of range

As a work around I check if the time is only 3 char long and then I prepend 
a 0, then parsing is ok.

Is this the only way or am I missing anything?

Thank you.

Diego


-- 
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] time.Parse : hour out of range

2016-10-19 Thread Diego Medina
Thanks for the answers, looks like I'll keep using my work around for the 
time being.

Diego



On Wednesday, October 19, 2016 at 1:19:08 PM UTC-4, Kyle Shannon wrote:
>
> Related to: 
>
> https://github.com/golang/go/issues/12919 
>
> On Tue, Oct 18, 2016 at 9:49 PM, Diego Medina  > wrote: 
> > Hi, 
> > 
> > From a 3rd party I get a file with time like 1503  or 900 (meaning 
> 3:03PM or 
> > 9:00 AM) 
> > 
> > so I thought I could use this format: 
> > 
> > https://play.golang.org/p/RKR71hTWGo 
> > 
> > x, err := time.Parse("1504", "900") 
> > 
> > but the result is: 
> > 
> > 2009/11/10 23:00:00 parsing time "900": hour out of range 
> > 
> > As a work around I check if the time is only 3 char long and then I 
> prepend 
> > a 0, then parsing is ok. 
> > 
> > Is this the only way or am I missing anything? 
> > 
> > Thank you. 
> > 
> > Diego 
> > 
> > 
> > -- 
> > 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. 
>
>
>
> -- 
> Kyle 
>

-- 
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] mgo , slice , reset var, need help understanding why this works

2016-10-24 Thread Diego Medina
Hi (sorry for the cryptic subject, I'm just not sure what to even call 
this):


I think this is not strictly a mgo question, I have this simplified 
function that gets documents from a mongo instance using Iter(), I then 
loop through the results, append them to a slice []interface{} but the 
resulting new slice has the last element repeated N times, where N is the 
number of item I got from the call to Iter().

In code on gist:

https://gist.github.com/fmpwizard/a1b4cc246b5875ff6bd1fbcd71940703

pasted here:


func TestBatchInsert1(t *testing.T) {
c := session.DB("testing").C("delete")
c.DropCollection()

c.Insert(bson.M{
"name": "AAA",
"num":  1,
})

c.Insert(bson.M{
"name": "",
"num":  2,
})

iter := c.Find(nil).Iter()
//var doc interface{} //if I use this line instead of a bson.M, the "issue" 
doesn't happen
var doc bson.M
var docs []interface{}

for iter.Next(&doc) {
fmt.Printf("Pre append\n\n %+v\n\n", docs)
docs = append(docs, doc)
fmt.Printf("Post append\n\n %+v\n\n", docs)
//doc = nil //This **fixes** it but why?
}
fmt.Printf("Final\n\n %+v\n\n", docs)

err := iter.Close()
if err != nil {
fmt.Printf("Failed to close iter during copy: %s", err)
}
}


the output of all that is:

Pre append

 []

Post append

 [map[_id:ObjectIdHex("580e5758ad817545b924a2c1") name:AAA num:1]]

Pre append

 [map[_id:ObjectIdHex("580e5758ad817545b924a2c2") name: num:2]]

Post append

 [map[_id:ObjectIdHex("580e5758ad817545b924a2c2") name: num:2] 
map[_id:ObjectIdHex("580e5758ad817545b924a2c2") name: num:2]]

Final

 [map[_id:ObjectIdHex("580e5758ad817545b924a2c2") name: num:2] 
map[_id:ObjectIdHex("580e5758ad817545b924a2c2") name: num:2]]


===

note how the second time we print "Pre append" the docs slice has is the 
second item in it, instead of the first one:

 [map[_id:ObjectIdHex("580e5758ad817545b924a2c2") name: num:2]]

as if I appended a pointer to the docs instead the actual value of doc.

I found two ways to avoid this issue, one is to uncomment

//doc = nil //

after calling append, I just don't understand why I need to reset it.

The other is, instead of working with

var doc bson.M
var docs []interface{}

I can use

var doc interface{}
var docs []interface{}

but using 

var doc bson.M
var docs []bson.M

also shows the **issue**

Thanks.

Diego

-- 
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] mgo , slice , reset var, need help understanding why this works

2016-10-24 Thread Diego Medina
Thanks.

after reading your reply I was able to reduce the example to just a few 
lines, the key was to know that maps in Go are pointers, like slices are 
pointers too.

https://play.golang.org/p/-x1R2P5IrF

package main

import (
"fmt"
)

func main() {
var docs []interface{}
doc1 := map[string]int{
"uno": 1,
}
docs = append(docs, doc1)
fmt.Println("doc1 appended is: ", docs)
//doc1 = nil //this would reset the doc1 variable so it is not "poining" to 
the map stored in the docs slice
//doc1 = make(map[string]int) // if we make doc1 nil, then we need to 
initialize it again
doc1["uno"] = 2
fmt.Println("Updated the doc1 map value and now docs is: ", docs)
}

prints:



doc1 appended is:  [map[uno:1]]
Updated the doc1 map value and now docs is:  [map[uno:2]]



Thanks

Diego


On Monday, October 24, 2016 at 7:10:25 PM UTC-4, kortschak wrote:
>
> I would guess this is because when iter.Next is given a nil bson.M is 
> needs to make a new value to fill (which from your output is a map). 
> When it is handed a bson.M that already has a map in it, it can use 
> that. Remember that bson.M is just interface{} and maps are pointer- 
> like. 
>
> On Mon, 2016-10-24 at 11:56 -0700, Diego Medina wrote: 
> > Hi (sorry for the cryptic subject, I'm just not sure what to even 
> > call  
> > this): 
> > 
> > 
> > I think this is not strictly a mgo question, I have this simplified  
> > function that gets documents from a mongo instance using Iter(), I 
> > then  
> > loop through the results, append them to a slice []interface{} but 
> > the  
> > resulting new slice has the last element repeated N times, where N is 
> > the  
> > number of item I got from the call to Iter(). 
> > 
> > In code on gist: 
> > 
> > https://gist.github.com/fmpwizard/a1b4cc246b5875ff6bd1fbcd71940703 
> > 
> > pasted here: 
> > 
> > 
> > func TestBatchInsert1(t *testing.T) { 
> > c := session.DB("testing").C("delete") 
> > c.DropCollection() 
> > 
> > c.Insert(bson.M{ 
> > "name": "AAA", 
> > "num":  1, 
> > }) 
> > 
> > c.Insert(bson.M{ 
> > "name": "", 
> > "num":  2, 
> > }) 
> > 
> > iter := c.Find(nil).Iter() 
> > //var doc interface{} //if I use this line instead of a bson.M, the 
> > "issue"  
> > doesn't happen 
> > var doc bson.M 
> > var docs []interface{} 
> > 
> > for iter.Next(&doc) { 
> > fmt.Printf("Pre append\n\n %+v\n\n", docs) 
> > docs = append(docs, doc) 
> > fmt.Printf("Post append\n\n %+v\n\n", docs) 
> > //doc = nil //This **fixes** it but why? 
> > } 
> > fmt.Printf("Final\n\n %+v\n\n", docs) 
> > 
> > err := iter.Close() 
> > if err != nil { 
> > fmt.Printf("Failed to close iter during copy: %s", err) 
> > } 
> > } 
> > 
> > 
> > the output of all that is: 
> > 
> > Pre append 
> > 
> >  [] 
> > 
> > Post append 
> > 
> >  [map[_id:ObjectIdHex("580e5758ad817545b924a2c1") name:AAA 
> > num:1]] 
> > 
> > Pre append 
> > 
> >  [map[_id:ObjectIdHex("580e5758ad817545b924a2c2") name: 
> > num:2]] 
> > 
> > Post append 
> > 
> >  [map[_id:ObjectIdHex("580e5758ad817545b924a2c2") name: 
> > num:2]  
> > map[_id:ObjectIdHex("580e5758ad817545b924a2c2") name: num:2]] 
> > 
> > Final 
> > 
> >  [map[_id:ObjectIdHex("580e5758ad817545b924a2c2") name: 
> > num:2]  
> > map[_id:ObjectIdHex("580e5758ad817545b924a2c2") name: num:2]] 
> > 
> > 
> > === 
> > 
> > note how the second time we print "Pre append" the docs slice has is 
> > the  
> > second item in it, instead of the first one: 
> > 
> >  [map[_id:ObjectIdHex("580e5758ad817545b924a2c2") name: 
> > num:2]] 
> > 
> > as if I appended a pointer to the docs instead the actual value of 
> > doc. 
> > 
> > I found two ways to avoid this issue, one is to uncomment 
> > 
> > //doc = nil // 
> > 
> > after calling append, I just don't understand why I need to reset it. 
> > 
> > The other is, instead of working with 
> > 
> > var doc bson.M 
> > var docs []interface{} 
> > 
> > I can use 
> > 
> > var doc interface{} 
> > var docs []interface{} 
> > 
> > but using  
> > 
> > var doc bson.M 
> > var docs []bson.M 
> > 
> > also shows the **issue** 
> > 
> > Thanks. 
> > 
> > Diego 
> >  
>

-- 
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: Stopping a server

2016-10-27 Thread Diego Medina
As a user of a package, if I "start it" by calling Start(), I will most 
likely look for a "Stop()" function but calling cancel on the context 
wouldn't feel natural because I'm not canceling the server, I would be done 
with it and don't need it any more).

Regards,


On Thursday, October 27, 2016 at 10:11:34 AM UTC-4, Nick Patavalis wrote:
>
> Hi, 
>
> I'm writing a package that allows the user to create and start server 
> instances. A server instance is created like this: 
>
>   srv := pkg.NewServer( ... params ... ) 
>
> and started like this: 
>
>   err := srv.Start() 
>
> Start does not normally return (unless an unrecoverable error 
> occurs). The user code can invoke Start() in a goroutine in order to run 
> multiple servers (which is not uncommon). 
>
> I want to give the user-code the ability to stop servers when 
> required. One thought is to use "context.Context" for this purpose. That 
> is, the server could be started like this: 
>
>   ctx, cancel := context.WithCancel(context.Background()) 
>   ... 
>   err := srv.Start(ctx) 
>
> and stopped by calling the "cancel" function of the context. 
>
> I konw that, functionally, this will work. My question is: Does this 
> look like a "reasonable" / "idiomatic" use of contexts?  Or will it 
> look "alien" to the user? I'm asking since the documentation of 
> "context" mentions it being used for "request-scoped" stuff, and this 
> is not exactly the case here. 
>
> I can instead add a Stop() method to "srv" and roll-my-own stopping 
> logic. 
>
> Which would you choose? 
>
> /npat 
>

-- 
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: folder and package structure with ddd based micro services

2016-10-31 Thread Diego Medina
Hi,
 

>  How can i run my tests "go test" for my entire domain model is they are 
> in sub folders?  
>

If I understood your question, what you are looking for is to run 

go test ./...

at the root, that will run tests at the root but also tests in the 
subfolders

Regards,

Diego
 

>
> application (application services that wrap everything)
> command (command services)
> query (query logic outside of domain)
> common
> domainmodel
> >>shared
> >>aggregate1
> >>aggregate2
> infrastructure
> >>logging
> >>config
> >>repository
> service (micro services)
>

-- 
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] Is this go gettable ? crypto/tls/generate_cert.go

2016-11-03 Thread Diego Medina

>
>
> Back on my original question, its ok if i copy paste the code into a 
> specific module with its appropriate credits ?
> Given the quick red i gave it, there s really not much to change to this 
> code, it if works already.
>
>
at the top of that file it says :

// Use of this source code is governed by a BSD-style

So, as long as your binary doesn't break the BSD license, it should be ok.

Regarding using autocert with let's encrypt for local dev, let's encrypt 
limits the number of certs you can get in (X days, I can't remember the 
limit), so if you load them just in memory, you would run into issues 
sooner or later. And, it doesn't really work for local dev, let's encrypt 
needs to reach your server to validate you own the domain (you could setup 
your router to allow external incoming request, setup dns to point to your 
house/office/ etc, but this isn't the normal dev env.)

Hope that helps.

Regards,

Diego

 

> On Thursday, November 3, 2016 at 1:54:44 PM UTC+1, Jan Mercl wrote:
>>
>> On Thu, Nov 3, 2016 at 1:40 PM  wrote:
>>
>> >  to provide support for got get, windows/debian/rpm installers ?
>>
>> I probably do not understand the goal correctly, but: If the user can do 
>> `go get` then he has the go tool installed. That means he has Go installed. 
>> That means he does not have to go get the crypto/tls package as it is 
>> already sitting in his $GOROOT/src/crypto/tls.
>>
>> -- 
>>
>> -j
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Supervisor Golang app

2016-11-29 Thread Diego Medina
Hi,


it isn't finding the actual binary of your go app. The binary could be in 
one of two places, 

if you run go install
it goes to 

$GOPATH/bin

which is /root/work/bin

if you did go build, it is at the root of your project directory

Hope that helps.

On Tuesday, November 29, 2016 at 1:03:09 PM UTC-5, gni...@gmail.com wrote:
>
> Hi my environment variables are :
>
> GOPATH="/root/work"
>
>
> GOROOT="/usr/local/go" 
>
> and my supervisor of my app are : 
>
> [program:appname]
>
> command=/work/bin/appname
>
> autostart=true
>
> autorestart=true
>
> startretries=10
>
> user=appname
>
> directory=/src/appname
>
> redirect_stderr=true
>
> stdout_logfile=/var/log/supervisor/appname.log
>
> stdout_logfile_maxbytes=50MB
>
> stdout_logfile_backups=10
>
>
>   
> IN LOG FILE :INFO 
> spawnerr: can't find command '/work/bin/appname'
>
>  What i am doing wrong ? 
>
>
>
>
>
>
>
>  
>   
>
>
>

-- 
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] Upgraded to Go 1.8beta2 and now Atom go-plus isn't working

2016-12-16 Thread Diego Medina
Hi,

I have seen similar posts to this but I could not find any of them so 
posting this.

I went ahead and installed the latest beta to try it out, both my apps at 
work work ok with it (yeah!), but now go-plus in Atom (and the autocomplete 
plugin) won't autocomplete any more, it just offers "PANIC" as any 
autcomplete.

1. What's the proper way to handle this issue.
2. Could this be added to the https://golang.org/doc/install page.

When I previously run into this issue, I ended up making a mess of my 
install, I think I deleted everything in $GOPATH and then one by one 
started go get'ting everything I needed. I was fine with it because after 
all, I love using Go, but my co-workers will be less willing to do all the 
manual work just to get a new version going, so I'm hoping there is a 
simple step I can tell them to follow to go from one version to the next.

Thanks.

Diego

-- 
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: How has your company adopted Go ?

2016-12-19 Thread Diego Medina
In our case, our original product was a web app, written in Scala, as our 
data starting growing, we had to move from real time queries to our 
database plus some data manipulation to precalculating/storing the data in 
a ready to server manner.
This worked well for a while, but eventually our backend process was 
consuming large amounts of memory. This was the a good point for us to try 
Go, so we switch part of that processing to Go to see how it goes, worse 
case scenario, a crash wasn't going to affect our main product, we could 
still run the old code. Having a safe fallback was key for adoption.

But before we used Go at work, I personally made sure I was comfortable 
enough with it that I could answer any questions our team had, or at least 
being able to go look for the answer (this mailing list, stackoverflow, 
etc).

The move was great, our incoming data has grown a lot more than what it was 
3 years ago, and I keep improving the go program from time to time. We 
still run our web application in Scala, but a few months ago we also 
started handling a couple of specific pages in Go, again, if those pages 
fail, they are not critical, so it wouldn't be a reason to stop migrating. 
A few weeks ago I got our CTO onboard with Go, which was a big milestone, 
so we'll be writing more and more of the web app in Go in the near/mid 
future.

In short, if your company doesn't like taking risks, you can go slow in 
migrating to Go, have safe guards and know where to go for help.

Thanks

Diego




On Monday, December 19, 2016 at 8:03:43 AM UTC-5, Tieson Molly wrote:
>
> What arguments or factors have contributed to your company adopting Go?
>
> Many businesses see switching to a new language or even using a new 
> language side by side with their existing  language choice as a business 
> risk.
>
>   Best regards,
>
>   Ty
>
>
>

-- 
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 Go in a locked down SOC2 environment (dependency management hell)

2017-01-06 Thread Diego Medina
> All of our build servers are locked down and cannot reach public 
Internet, only our local library mirror.

With this in mind, you could use gvt https://github.com/FiloSottile/gvt

all your devs should use it to fetch dependencies, yes, they would use open 
internet, but only while they get their app working, at commit time, you 
only commit the manifest file, a sample file looks like:

{
"version": 0,
"dependencies": [
{
"importpath": "github.com/dgryski/dkeyczar",
"repository": "https://github.com/dgryski/dkeyczar";,
"vcs": "git",
"revision": "05c8ea381e02781927d6c633076910b86c6ce770",
"branch": "master",
"notests": true
},
{
"importpath": "github.com/golang/glog",
"repository": "https://github.com/golang/glog";,
"vcs": "git",
"revision": "23def4e6c14b4da8ac2ed8007337bc5eb5007998",
"branch": "master",
"notests": true
}
]
}


This is a simple json file.

You then need to provide your layers with a way to have in a central place, 
a list of the approved Go dependencies so you can pick these fields:

importpath": "github.com/golang/glog",
"repository": "https://github.com/golang/glog";,
"vcs": "git",
"revision": "23def4e6c14b4da8ac2ed8007337bc5eb5007998",
"branch": "master",

You will also create a builder $GOPATH with all these approved dependencies 
(like someone else already suggested)


Once you have that, the build server would first run your tool to make sure 
that every single entry on the manifest file is in the lawyer approved 
list, down to the commit, if that passes, then you run gvt restore, which 
will look at the manifest file and download all the dependencies into the 
vendor folder of the current project.

Oh, and just in case you have more of those non law abiding devs, as part 
of the build, you can first make sure that the vendor folder is empty and 
only has the manifest file, so nobody can sneak in a committed dependency.

gvt restore would use the approved GOPATH so it will not need internet 
access.

I think this covers all the restrictions you need.

Hope it helps.

Diego



On Friday, January 6, 2017 at 11:35:41 AM UTC-5, Jacek Furmankiewicz wrote:
>
> Hi everyone,
>
> We are operating in a SOC2 environment, which our customers demanded as we 
> host their systems and their data.
> It's a common requirement for many companies in a cloud environment.
>
> One of the key requirements of SOC2 is that *all* external 
> libraries/depdencies are mirrored internally and 
> *NOT*fetched directly from public Internet during the code building 
> process.
>
> With our Java apps, this is simple. We have an internal Artifactory 
> instance and we mirror all the Java libraries from the Maven Central 
> repository there
> (after each and every one of them goes through legal license review, to 
> exclude GPL, etc).
>
> All of our build servers are locked down and cannot reach public Internet, 
> only our local library mirror.
> All of our Gradle build scripts are locked down to allow fetching 
> dependencies from our local Maven mirror only.
>
> As you can imagine, this is anathema to how entire dependency management 
> works in Go (and all the related tools, like go get, etc).
>
> Even if we mirrored Go git repos for the libraries we want in our internal 
> Stash repository,
> pretty much all the current Go build tools (e,g. Glide) would still go to 
> the public internet to look for dependencies of any library.
>
> e.g.:
>
> https://github.com/Masterminds/glide/issues/729
>
>
> Just wanted to hear if there are any Go shops out there that operate in a 
> SOC2 environment and what combination of tools / procedures do you use.
>
> We are very interested in Go adoption for some of our real-time 
> server-side applications, but the way dependency management works in Go
> is a total showstopper due to the stringent security requirements of SOC2.
>
> I would greatly appreciate any input, comments, suggestions from the Go 
> community.
>
> Much appreciated
> Jacek
>

-- 
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: Program design question

2017-01-19 Thread Diego Medina
If you were planning on running each binary on different servers, then it 
would somewhat make sense (but you should really measure to see how CPU 
heavy the processing is).

But if you are planning on putting both binaries on the same server, you 
may as well just have one binary. Otherwise both binaries will be competing 
for the same CPU(s).

Are the 20/30MB per user or per app? If per app, that isn't really an 
amount to worry about unless you are planning on running this on a really 
small server

Hope that helps.

Diego


On Thursday, January 19, 2017 at 4:43:13 PM UTC-5, Keith Brown wrote:
>
> I am writing a webapp using go. It will server about 200 people but will 
> be highly dynamic so efficiency is important for me. 
>
>
> The app will contact 2 segments. 1) collect data by running few commands. 
> The data will be around 30/40 MB. I plan to run it periodically, say 20 
> secs.  The data will be XML so I plan to use XML library to parse the data. 
> 2) present the data. With the data collected I want to present it on the 
> website. 
>
>
> My question, would it be better to put collection and presentation in a 
> single binary? Or should I split it up where data collection is running 
> subsequent next to webserver. But how would I share the content efficiently 
> (I want to avoid a database since it’s a bottleneck and will add some more 
> complexity).  What is a good mechanism to share memory when doing a split 
> setup? 
>
>
> I am inclined to go with separate binaries (collection and web serving). 
>
> What are your 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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Should golang.org/x/crypto/ssh.ParsePrivateKey() be extended to parse encrypted keys?

2017-02-01 Thread Diego Medina
In case anyone else gets to this post but has an ssh-agent running, you can 
use this:


import (
  "net"
  "os"

  "golang.org/x/crypto/ssh/agent"
)


if aconn, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK")); err == nil {
signerFn := agent.NewClient(aconn).Signers
signers, err := signerFn()
if err != nil {
log.Fatalln("ssh: ", err)
}
   // signers is a slice of the decrypted private ssh keys the 
agent has access to
}

Thanks

Diego


On Friday, October 7, 2016 at 4:18:21 PM UTC-4, Pietro Gagliardi (andlabs) 
wrote:
>
> While waiting for some long-running automated tasks at work to complete, I 
> passed the time by writing a simple program using github.com/pkg/sftp to 
> automate dumping the latest backups from our backup server onto my computer 
> for using them to test other parts of our workflow. I have an encrypted 
> id_rsa with a passphrase, which ssh.ParsePrivateKey() doesn't support right 
> now. I admittedly don’t understand ssh the toolchain enough to know how to 
> have ssh prompt for a passphrase without an agent (because I dislike GUI 
> agent prompters), and I didn't know (until it was pointed out to me) that 
> git was running ssh behind my back (I thought it was producing passphrase 
> prompts itself). So I examined the package’s source and a few other 
> packages to rolled together this solution, which works for me:
>
> https://play.golang.org/p/M93Dk9_ufa
>
> import (
> "crypto/x509"
> "encoding/pem"
> "io/ioutil"
>
> "golang.org/x/crypto/ssh"
> )
>
> // Pass the returned ssh.Signer to ssh.PublicKeys() to get its 
> ssh.AuthMethod
> func ParseEncryptedPrivateKey(key []byte, passphrase string) (ssh.Signer, 
> error) {
> block, _ := pem.Decode(key)
> key, err := x509.DecryptPEMBlock(block, []byte(passphrase))
> if err != nil {
> return nil, err
> }
> block.Headers = nil
> block.Bytes = key
> return ssh.ParsePrivateKey(pem.EncodeToMemory(block))
> }
>
> My question is: is there any gotcha or caveat about the above that I don't 
> know about? Because I'd like to add it to crypto/ssh, to make the lives of 
> other people dealing with passphrased keys easier.
>
> Thanks.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Struggling with working directory

2017-02-11 Thread Diego Medina
Hi,

you were very close, instead of

go install github.com/mortalcatalyst/xml/xml.go

do

go install github.com/mortalcatalyst/xml


In go, you don't install the particular file, you install the program as a 
whole (which in many cases, it involves more than one file)

And as a side note, normally you would 

$ cd $GOPATH/src/github.com/mortalcatalyst/xml
$ go install


so you don't have to specify the whole path to the project every time.

Hope that helps

P.S. as you work with Go more and more, you'll want to add these lines to 
~/.bash_profile:

CDPATH=.:$GOPATH/src/github.com:$GOPATH/src/bitbucket.org #you may add more 
domains here if you host your proejct(s) somewhere else
export CDPATH

that let's you, form anywhere in your terminal, to type:

$ cd mor 

Then press tab and the terminal will autocomplete mortalcatalyst

P.S. source of the 
tip https://twitter.com/rob_pike/status/467367507305574400

Diego





On Saturday, February 11, 2017 at 7:12:38 AM UTC-5, Sayth Renshaw wrote:
>
> Hi All
>
> I installed go on a new linux mint laptop and followed the standard go 
> guide and it works fine with the hello world example.
>
> Today i came back to work on go and cannot seem to do the install step to 
> run my script.
>
> sayth@sayth-E6410 ~ $ mkdir -p work/src/github.com/mortalcatalyst/xml
> sayth@sayth-E6410 ~ $ code ~/work/src/github.com/mortalcatalyst/xml/xml.go
> sayth@sayth-E6410 ~ $ go install github.com/mortalcatalyst/xml/xml.go
> stat github.com/mortalcatalyst/xml/xml.go: no such file or directory
>
> sayth@sayth-E6410 ~ $ cd $GOPATH
> sayth@sayth-E6410 ~/work $ go install github.com/mortalcatalyst/xml/xml.go
> stat github.com/mortalcatalyst/xml/xml.go: no such file or directory
>
> Now I am a little confused, how should I easily come in every day fire up 
> a project and get it to work and get the file to run and install?
>
> Cheers
>
> Sayth
>

-- 
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: Struggling with working directory

2017-02-13 Thread Diego Medina
Can you include the link to the guide you followed to install Go?

I always follow
https://golang.org/doc/install#install

which is, after downloading from the link on that page,:

tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz

and then adding:

/usr/local/go/bin to the PATH


And I have never had to set GOBIN

Thanks

Diego



On Mon, Feb 13, 2017 at 5:39 AM, Sayth Renshaw 
wrote:

>
>
> On Sunday, 12 February 2017 04:16:15 UTC+11, Diego Medina wrote:
>>
>> Hi,
>>
>> you were very close, instead of
>>
>> go install github.com/mortalcatalyst/xml/xml.go
>>
>> do
>>
>> go install github.com/mortalcatalyst/xml
>>
>>
>> In go, you don't install the particular file, you install the program as
>> a whole (which in many cases, it involves more than one file)
>>
>> And as a side note, normally you would
>>
>> $ cd $GOPATH/src/github.com/mortalcatalyst/xml
>> $ go install
>>
>>
>> so you don't have to specify the whole path to the project every time.
>>
>> Hope that helps
>>
>> P.S. as you work with Go more and more, you'll want to add these lines to
>> ~/.bash_profile:
>>
>> CDPATH=.:$GOPATH/src/github.com:$GOPATH/src/bitbucket.org #you may add
>> more domains here if you host your proejct(s) somewhere else
>> export CDPATH
>>
>> that let's you, form anywhere in your terminal, to type:
>>
>> $ cd mor
>>
>> Then press tab and the terminal will autocomplete mortalcatalyst
>>
>> P.S. source of the tip https://twitter.com/rob_pi
>> ke/status/467367507305574400
>>
>> Diego
>>
>>
>>
>>
>>
>>
> Hi
>
> I now seem to have hit another problem
>
> sayth@sayth-E6410 ~/work/src/github.com/mortalcatalyst/xml $ go install
> github.com/mortalcatalyst/xml
> cannot install, GOBIN must be an absolute path
>
> An absolute path? I think somehow those directions have created a bad
> install.
>
> Is there a way I can reset to defaults and is there a better install
> method so that I can get a clean and working environment. Keep running into
> errors and cannot execute code.
>
> Cheers
>
> Sayth
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/golang-nuts/YE0w1Cbb1Ac/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Diego Medina
Lift/Scala Consultant
di...@fmpwizard.com
https://blog.fmpwizard.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] Re: Struggling with working directory

2017-02-13 Thread Diego Medina
> Not sure why its being difficult.

knowing why I needed a GOPATH and what it was used for was probably the
main issue I had when I started with Go too, some 3+ years ago, we'll help
you get through it. Now, if you go back to the original instructions,
https://golang.org/doc/install#install

you then just need to decide where **your** code and any code you import
into your proejct(s) will be based off. Unlike many other languages where
you can just start a project wherever you feel like, all Go projects start
off from $GOPATH , but the regular install doesn't set this path for you
(it will in 1.8). But don't worry, all it means is do this:

$ export GOPATH=/home//go

(you can add that to ~/.bash_profile so you don't have to do it after every
reboot of your computer)

So, once you have your GOPATH environment variable ready, you can create
the structure for your new project:

$  mkdir $GOPATH/src/github.com/mortalcatalyst/xml

$ cd $GOPATH/src/github.com/mortalcatalyst/xml
$ write some awesome code now in here
$ go install # note that you do not need to specify the path to your
project, because you are already inside your project root folder

and at this point you are ready to use your new cool app :)

If any of these instructions don't help or give you an error, post back
what you got.

Thanks

Diego






On Mon, Feb 13, 2017 at 5:07 PM, Sayth Renshaw 
wrote:

> That's the one i used first but got errors that it couldn't find GOPATH
> even though i installed it to the suggested default location.
>
> So when that didn't work i delete the go directory and the details from
> .profile and then followed ://www.digitalocean.com/
> community/tutorials/how-to-install-go-1-6-on-ubuntu-16-04.
>
> Not sure why its being difficult.
>
> Cheers
>
> Sayth
>
> On Mon, 13 Feb 2017, 11:41 PM Diego Medina  wrote:
>
>> Can you include the link to the guide you followed to install Go?
>>
>> I always follow
>> https://golang.org/doc/install#install
>>
>> which is, after downloading from the link on that page,:
>>
>> tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
>>
>> and then adding:
>>
>> /usr/local/go/bin to the PATH
>>
>>
>> And I have never had to set GOBIN
>>
>> Thanks
>>
>> Diego
>>
>>
>>
>> On Mon, Feb 13, 2017 at 5:39 AM, Sayth Renshaw 
>> wrote:
>>
>>
>>
>> On Sunday, 12 February 2017 04:16:15 UTC+11, Diego Medina wrote:
>>
>> Hi,
>>
>> you were very close, instead of
>>
>> go install github.com/mortalcatalyst/xml/xml.go
>>
>> do
>>
>> go install github.com/mortalcatalyst/xml
>>
>>
>> In go, you don't install the particular file, you install the program as
>> a whole (which in many cases, it involves more than one file)
>>
>> And as a side note, normally you would
>>
>> $ cd $GOPATH/src/github.com/mortalcatalyst/xml
>> $ go install
>>
>>
>> so you don't have to specify the whole path to the project every time.
>>
>> Hope that helps
>>
>> P.S. as you work with Go more and more, you'll want to add these lines to
>> ~/.bash_profile:
>>
>> CDPATH=.:$GOPATH/src/github.com:$GOPATH/src/bitbucket.org #you may add
>> more domains here if you host your proejct(s) somewhere else
>> export CDPATH
>>
>> that let's you, form anywhere in your terminal, to type:
>>
>> $ cd mor
>>
>> Then press tab and the terminal will autocomplete mortalcatalyst
>>
>> P.S. source of the tip https://twitter.com/rob_
>> pike/status/467367507305574400
>>
>> Diego
>>
>>
>>
>>
>>
>>
>> Hi
>>
>> I now seem to have hit another problem
>>
>> sayth@sayth-E6410 ~/work/src/github.com/mortalcatalyst/xml $ go install
>> github.com/mortalcatalyst/xml
>> cannot install, GOBIN must be an absolute path
>>
>> An absolute path? I think somehow those directions have created a bad
>> install.
>>
>> Is there a way I can reset to defaults and is there a better install
>> method so that I can get a clean and working environment. Keep running into
>> errors and cannot execute code.
>>
>> Cheers
>>
>> Sayth
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "golang-nuts" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/
>> topic/golang-nuts/YE0w1Cbb1Ac/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> golang-nuts+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>>
>> --
>> Diego Medina
>> Lift/Scala Consultant
>> di...@fmpwizard.com
>> https://blog.fmpwizard.com/
>>
>


-- 
Diego Medina
Lift/Scala Consultant
di...@fmpwizard.com
https://blog.fmpwizard.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.


[go-nuts] Re: question on golang.org/x/crypto/acme/autocert

2017-02-14 Thread Diego Medina
I wrote this 
https://blog.fmpwizard.com/2016/09/30/automatic-tls-certificates-for-your-go-application/

which downloads the certs to a path you specify 

there is a complete Go app to show how it all works together

Thanks

Die


On Tuesday, February 14, 2017 at 8:11:51 AM UTC-5, Tieson Molly wrote:
>
> I am looking for some examples for golang.org/x/crypto/acme/autocert
>
> I recently updated my server, and there are some openssl version issues 
> with the 
> letsencrypt certbot that I cannot resolve.
>
> I was hoping to find a Go based solution so I could skip these python 
> dependency issues.
>
> The ideal solution would download a new cert to a specified directory.
>
>
> Best regards,
>
> Ty
>
>
>

-- 
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: Why Go doesn't see my local package?

2017-02-17 Thread Diego Medina
Hi,

I think you pasted the same content to test.go as well as second.go

in any case, if you use go run, you need to specify all the files involved:

go run test.go second.go

should do the trick

That being said, unless you are writing small scripts using Go, I would not 
recommend doing this, instead have a main.go with a package main, then if 
you have some library code you can put them in the package second and then

go install

and then 

run it as $GOPATH/bin/

P.S. you can add $GOPATH/bin to your $PATH and then just call

$

Also, don't use relative imports like the one you posted from the "The Way 
to Go", that is't really what you are supposed to do. Instead, you should 
import it like

import(
"github.com/user/test/second"
)

even when you are inside your test repository.

And finally, you don't need to set GOROOT any more either, unless you have 
a custom path to it, etc


Thanks





On Friday, February 17, 2017 at 3:42:17 AM UTC-5, fsn7...@gmail.com wrote:
>
> In /etc/profile I have:
>
> export PATH=$PATH:/usr/local/go/bin
> export GOPATH=$HOME/work
> export GOROOT=/usr/local/go
>
> I have 2 source files: test.go (main) and second.go They located in
>
> /home/u001/work/src/github.com/user/test/
>
> When I'm running go run test.go from test it gives me:
>
> test.go:5:2: open /home/u001/work/src/github.com/user/test/second: no such 
> file or directory
>
>
> Content of test.go:
>
> package second
>
> import "fmt"
>
> var x int
> var y int
>
> func init() {
> x = 44
> y = 100
> }
>
> func ShowXY() {
> fmt.Printf("X:%d;Y%d.",x,y)
> }
>
>
> Content of second.go:
>
> package second
>
> import "fmt"
>
> var x int
> var y int
>
> func init() {
> x = 44
> y = 100
> }
>
> func ShowXY() {
> fmt.Printf("X:%d;Y%d.",x,y)
> }
>
>
> How to be if two source files are in one folder, let's say they both in ~/. 
> It works when I had second.go in second/ and changed line to ../second. 
> In the book "The Way to Go", listing 4.7 - it is said that in example 
> below package is imported from the same directory.
> package main
> import (
> “fmt”
> “./trans”
> )
> var twoPi = 2 * trans.Pi
> func main() {
> fmt.Printf(“2*Pi = %g\n”, twoPi) // 2*Pi = 6.283185307179586
> }
>
>
>
>
>
>

-- 
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: Arguments for writing fast, high-load servers in Go instead of Scala?

2017-02-18 Thread Diego Medina
The reasons we have for moving our Scala heavy process app to Go are:

1. Much, much smaller memory footprint, both, initial app running and then 
loading the same number of items from our database.
2. During development, compilation time.
3. Version upgrades:
As long as you vendor your Go dependencies, you are golden (and by this 
point, unless you write libraries, you should be vendoring), Go 1.8 just 
came out, I didn't have to wait for my 5 dependencies to publish a Go 1.8 
compatible version. Every time Scala comes up with a new version, I do have 
to wait for all my deps to be built for the new Scala version (And as a 
library maintainer of a large Scala web framework, have to deal with 
updating our code/publishing/etc)
4. This may or may not be a big point for your architect, depending on 
his/her preference, deploying a Scala app just takes longer than a Go app. 
(jar size with all dependencies vs a Go binary)

That being said, I try to control risk when introducing a new tech at work, 
I hope this won't be your first Go app. I personally wrote several apps on 
the side before we started using Go at work, because I didn't want to run 
into cases where I made s silly mistake and then the rest of the team would 
use that to say Go is terrible, when in fact it was just me making a 
mistake/misusing a feature, etc.

Hope that helps.

Diego



On Saturday, February 18, 2017 at 1:55:37 AM UTC-5, Will Faught wrote:
>
> I want to make the case to a software architect where I work that we 
> should write some fast, high-load servers we need in Go rather than Scala. 
> What pragmatic arguments should I use?
>
> Note that the architect isn't against ever using Go; the question is 
> whether to use Go now, for these servers in particular. Not much detail has 
> been hashed out yet about them, aside from general speed and load 
> requirements.
>
> As a general example of a pragmatic reason one might choose Go over Scala, 
> the architect said Scala would be bad for making a standalone program that 
> checks gRPC health endpoints because the binary would be large and the 
> start-up time would be long.
>

-- 
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: Why Go doesn't see my local package?

2017-02-18 Thread Diego Medina
see inline comments:

>
>
> " don't use relative imports like the one you posted from the "The Way to 
> Go", that is't really what you are supposed to do. "
>
> Why?
>
> What is the difference with "you are supposed to do"? what is the behavior 
> of using the dot?
>
>
There are several reasons you can find on this mailing list and other 
public forums, many are about tooling support, where some don't support 
relative path all that well, to me, it's about being explicit about what 
you depend on. when I import the full path, I can then copy that import and 
the related code to another package and it will wok, but if I start playing 
into the relative path import, I have to adjust it to make it point to the 
correct place.


 

> In other worlds, like NodeJS, it's very common to have local code consumed 
> in that way. And it is independent of any package directory structure.
>
>

Go is very diff than many other languages, good practices there don't 
always translate to Go's good practices, this being one of them.

Thanks

Diego

 

> Angel "Java" Lopez
> @ajlopez
>
>
> On Fri, Feb 17, 2017 at 4:00 PM, Diego Medina  > wrote:
>
>> Hi,
>>
>> I think you pasted the same content to test.go as well as second.go
>>
>> in any case, if you use go run, you need to specify all the files 
>> involved:
>>
>> go run test.go second.go
>>
>> should do the trick
>>
>> That being said, unless you are writing small scripts using Go, I would 
>> not recommend doing this, instead have a main.go with a package main, then 
>> if you have some library code you can put them in the package second and 
>> then
>>
>> go install
>>
>> and then 
>>
>> run it as $GOPATH/bin/
>>
>> P.S. you can add $GOPATH/bin to your $PATH and then just call
>>
>> $
>>
>> Also, don't use relative imports like the one you posted from the "The 
>> Way to Go", that is't really what you are supposed to do. Instead, you 
>> should import it like
>>
>> import(
>> "github.com/user/test/second"
>> )
>>
>> even when you are inside your test repository.
>>
>> And finally, you don't need to set GOROOT any more either, unless you 
>> have a custom path to it, etc
>>
>>
>> Thanks
>>
>>
>>
>>
>>
>> On Friday, February 17, 2017 at 3:42:17 AM UTC-5, fsn7...@gmail.com 
>> wrote:
>>>
>>> In /etc/profile I have:
>>>
>>> export PATH=$PATH:/usr/local/go/bin
>>> export GOPATH=$HOME/work
>>> export GOROOT=/usr/local/go
>>>
>>> I have 2 source files: test.go (main) and second.go They located in
>>>
>>> /home/u001/work/src/github.com/user/test/
>>>
>>> When I'm running go run test.go from test it gives me:
>>>
>>> test.go:5:2: open /home/u001/work/src/github.com/user/test/second: no such 
>>> file or directory
>>>
>>>
>>> Content of test.go:
>>>
>>> package second
>>>
>>> import "fmt"
>>>
>>> var x int
>>> var y int
>>>
>>> func init() {
>>> x = 44
>>> y = 100
>>> }
>>>
>>> func ShowXY() {
>>> fmt.Printf("X:%d;Y%d.",x,y)
>>> }
>>>
>>>
>>> Content of second.go:
>>>
>>> package second
>>>
>>> import "fmt"
>>>
>>> var x int
>>> var y int
>>>
>>> func init() {
>>> x = 44
>>> y = 100
>>> }
>>>
>>> func ShowXY() {
>>> fmt.Printf("X:%d;Y%d.",x,y)
>>> }
>>>
>>>
>>> How to be if two source files are in one folder, let's say they both in 
>>> ~/. It works when I had second.go in second/ and changed line to 
>>> ../second. 
>>> In the book "The Way to Go", listing 4.7 - it is said that in example 
>>> below package is imported from the same directory.
>>> package main
>>> import (
>>> “fmt”
>>> “./trans”
>>> )
>>> var twoPi = 2 * trans.Pi
>>> func main() {
>>> fmt.Printf(“2*Pi = %g\n”, twoPi) // 2*Pi = 6.283185307179586
>>> }
>>>
>>>
>>>
>>>
>>>
>>> -- 
>> 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: Golang server background notofication process

2017-02-18 Thread Diego Medina
Hi,

See below:

 My first idea was to make some background process, which will scrape rooms 
> every 30 seconds, save the results *(in mongo, in cookies or somewhere 
> else, advise me please)*, match new scrape results with previous and save 
> differences (new rooms) in DB for future posting to user in some form 
> (email or list on html page).
>


if by scrape rooms  you mean having your program go to a website, fetch the 
html, parse it and extract data from them, going every 30 seconds may:
1. Break their term of use
2. Related to 1, they may mark your bot as spam and block it because you 
are going too often/generate too much load on their servers.

With the legal stuff aside, it would be better to store this info on your 
database, each user has have their locations in the database. Storing them 
in cookies would mean that using their cell phone browser will give them 
diff results than their computers.

Also store the new rooms data in your database, this allows you to resend 
them an email if they didn't get it, and/or render a page with all the 
listings when they go back to your site.

>
> 2) What is the best way to make that background process in go?
>
>
>
If you are just starting with Go, go simple and simply start the background 
process as a go routing, with a time.tick of x minutes

 

> 3) This would be great if you'd point me on some examples relating to the 
> case.
>
>
>

Don't have any.
 

> I appreciate your concern.
>

-- 
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: Arguments for writing fast, high-load servers in Go instead of Scala?

2017-02-18 Thread Diego Medina


On Saturday, February 18, 2017 at 10:29:03 PM UTC-5, Will Faught wrote:
>
> Definitely not my first rodeo. :) Been using Go professionally for a 
> couple years. I've done a lot of Java stuff in the past, and I suspect 
> Scala/JVM work will be as burdensome.
>

Great! hope you and your team get to use Go on this next project.

 

> On Sat, Feb 18, 2017 at 1:30 PM Diego Medina  > wrote:
>
>> The reasons we have for moving our Scala heavy process app to Go are:
>>
>> 1. Much, much smaller memory footprint, both, initial app running and 
>> then loading the same number of items from our database.
>> 2. During development, compilation time.
>> 3. Version upgrades:
>> As long as you vendor your Go dependencies, you are golden (and by 
>> this point, unless you write libraries, you should be vendoring), Go 1.8 
>> just came out, I didn't have to wait for my 5 dependencies to publish a Go 
>> 1.8 compatible version. Every time Scala comes up with a new version, I do 
>> have to wait for all my deps to be built for the new Scala version (And as 
>> a library maintainer of a large Scala web framework, have to deal with 
>> updating our code/publishing/etc)
>> 4. This may or may not be a big point for your architect, depending on 
>> his/her preference, deploying a Scala app just takes longer than a Go app. 
>> (jar size with all dependencies vs a Go binary)
>>
>> That being said, I try to control risk when introducing a new tech at 
>> work, I hope this won't be your first Go app. I personally wrote several 
>> apps on the side before we started using Go at work, because I didn't want 
>> to run into cases where I made s silly mistake and then the rest of the 
>> team would use that to say Go is terrible, when in fact it was just me 
>> making a mistake/misusing a feature, etc.
>>
>> Hope that helps.
>>
>> Diego
>>
>>
>>
>> On Saturday, February 18, 2017 at 1:55:37 AM UTC-5, Will Faught wrote:
>>>
>>> I want to make the case to a software architect where I work that we 
>>> should write some fast, high-load servers we need in Go rather than Scala. 
>>> What pragmatic arguments should I use?
>>>
>>> Note that the architect isn't against ever using Go; the question is 
>>> whether to use Go now, for these servers in particular. Not much detail has 
>>> been hashed out yet about them, aside from general speed and load 
>>> requirements.
>>>
>>> As a general example of a pragmatic reason one might choose Go over 
>>> Scala, the architect said Scala would be bad for making a standalone 
>>> program that checks gRPC health endpoints because the binary would be large 
>>> and the start-up time would be long.
>>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "golang-nuts" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/golang-nuts/Fg1I34HrtqU/unsubscribe.
>> To unsubscribe from this group and all its topics, 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] Re: Struggling with working directory

2017-02-19 Thread Diego Medina
>
>
>
> Did get it working (1.8) on windows though a side note on Docs for Fedora
> that putting the path in $HOME/.profile does not work and for me anyway I
> needed to put it in .bashrc
> https://golang.org/doc/install?download=go1.8.linux-amd64.tar.gz
>
>


Great to know you got it working!

re adding the CDPATH and GOPATH/bin , I wrote ~/.bash_profile, not
~/.profile  . Tested on Fedora 23, 24 and 25




Regards,

Diego

Also an note with system wide with fedora is that for system wide it should
> be a custom .sh script in /etc/profile.d well according the the etc/profile
> anyway.
> From etc/profile
>
> # It's NOT a good idea to change this file unless you know what you
> # are doing. It's much better to create a custom.sh shell script in
> # /etc/profile.d/ to make custom changes to your environment, as this
> # will prevent the need for merging in future updates.
>
>
>
> Thanks
>
> Sayth
>



-- 
Diego Medina
Lift/Scala Consultant
di...@fmpwizard.com
https://blog.fmpwizard.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] Re: Arguments for writing fast, high-load servers in Go instead of Scala?

2017-02-19 Thread Diego Medina
Looks like you have a pretty good list already, depending on how much they
love Scala, they may/may not invalidate some of your points but you know
them better.

On Sun, Feb 19, 2017 at 2:37 AM, Will Faught  wrote:

> Thanks to the two replies so far! Very helpful.
>
> Here are the reasons I'd thought of before sending the question. I don't
> know Scala, so maybe some of these aren't advantages relative to Scala in
> particular; if so, please let me know. Ideas and feedback are much
> appreciated!
>
> # Concurrency and parallelism
>
> - Simple, well-defined concurrency memory model
> - Happens-before guarantees for channel sending and receiving
> - Lock and atomic primitives
> - Built-in build/test data race detector
> - Goroutines (lightweight/green threads)
> - Part of the language
> - Small and fast (4 KB in memory, no context switching)
> - Multiplexed onto all processor cores for automatic parallelism
> - Channels
> - Part of the language
> - Simple send/receive/close semantics
> - Concurrent sends and receives are safe
> - Buffered and unbuffered
> - Send any type, even other channels
> - Enable concurrent composition of components (think pipelines, fan
> out/in)
> - Orchestration
> - Built-in support for orchestrating concurrent work
> - Work deadlines, timeouts, and cancellations that can span APIs and
> processes
> - Concurrent code looks synchronous
> - No callbacks, promises, or futures
> - Performance
> - Fast, native, statically-linked builds
> - Small disk and memory footprints (basic server: 11 MB on disk and
> 2.3 MB in memory)
> - GC pauses are usually under 100 microseconds and often as low as 10
> microseconds
> - GC tuning unnecessary and GC performance scales with memory size
> automatically
> - Hundreds of thousands of goroutines per process is practical
> - All tests can run in parallel
> - Regexps are guaranteed to run in time linear to the size of the input
>
> # Tooling
>
> - Easy development: quick and simple to clone repos and then build, test,
> and run code
> - Single command-line tool that does everything
> - Built-in testing, benchmarking, profiling, package managing,
> documentation, coverage
> - Code buildable from source alone; no third-party build tool (make, ant)
> needed
> - Fast builds (object files are cached; only changed code is rebuilt)
> - Cross compilation for various operating system and architectures
> - Deploying an executable is just copying a single file
> - Thorough, official language spec and standard library documentation
> - Modern standard library with built-in transport clients/servers and
> encoders/decoders
> - Simple build tag logic with file name suffixes and file comments
> - Built-in dependency vendoring
> - Built-in code formatter and linter
> - Built-in code generation
> - Clean builds (no warnings or logs; successful builds print nothing; no
> build artifacts)
>
> # Design
>
> - Uses interface composition, not class inheritance; avoids complex type
> hierarchies
> - Built-in equality/comparisons and hashing
> - Simple package model for encapsulation and distribution/use
> - Unit tests for service interfaces can double as integration tests
>
> On Friday, February 17, 2017 at 10:55:37 PM UTC-8, Will Faught wrote:
>>
>> I want to make the case to a software architect where I work that we
>> should write some fast, high-load servers we need in Go rather than Scala.
>> What pragmatic arguments should I use?
>>
>> Note that the architect isn't against ever using Go; the question is
>> whether to use Go now, for these servers in particular. Not much detail has
>> been hashed out yet about them, aside from general speed and load
>> requirements.
>>
>> As a general example of a pragmatic reason one might choose Go over
>> Scala, the architect said Scala would be bad for making a standalone
>> program that checks gRPC health endpoints because the binary would be large
>> and the start-up time would be long.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/to
> pic/golang-nuts/Fg1I34HrtqU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Diego Medina
Lift/Scala Consultant
di...@fmpwizard.com
https://blog.fmpwizard.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.


[go-nuts] Re: Re[2]: Golang server background notofication process

2017-02-19 Thread Diego Medina
Hi,

Instead of starting them from an http handler, I would store in the
database the locations and their users. Then, from main() I would start
just one go routine that will check the db for any pending location that
needs to be fetched, if found, then go do work, sleep for x seconds, then
check the database again.

That way, when a user no longer wants to be notified about location Z, you
just remove their user from the database and then go routine will not find
it any more.

Thanks



On Sun, Feb 19, 2017 at 5:32 AM,  wrote:

> Thanks for your answer!
>
> Am I right, when starting goroutine like this? (With infinite loop inside
> goroutine function)
>
> func (ctl *Controller) startWatchUserLocation(username, location string) {
>  for {
>data, err := ctl.ScrapeRoomsWithLocation(username, location) *<-
> scraping info from html*
> if err != nil {
>
>log.Println(err)
>  }
>
>  fmt.Sprint(data)
>  ctl.writeScrapeResultsToDB(data)  *<- writing info in
> database*
>  data = make([]byte, 0)
>  time.Sleep(30 * time.Second)
>   }
> }
>
> And then in http handler I call :
>
> func (ctl *Controller) ScraperHandler(w http.ResponseWriter, r
> *http.Request) {
>
>username := r.FormValue("username")
>location := r.FormValue("location")
>*go* ctl.startWatchUserLocation(username, location)
> }
>
> And one more quetion: how can I close specific background
> process(goroutine with infinite loop) when client want to stop tracking
> some location?
> For example, clients sends another http requset, with some flag "Stop
> traking" and close its goroutine?
>
>
>
>
> Воскресенье, 19 февраля 2017, 1:02 +03:00 от Diego Medina <
> fmpwiz...@gmail.com>:
>
> Hi,
>
> See below:
>
>  My first idea was to make some background process, which will scrape
> rooms every 30 seconds, save the results *(in mongo, in cookies or
> somewhere else, advise me please)*, match new scrape results with
> previous and save differences (new rooms) in DB for future posting to user
> in some form (email or list on html page).
>
>
>
> if by scrape rooms  you mean having your program go to a website, fetch
> the html, parse it and extract data from them, going every 30 seconds may:
> 1. Break their term of use
> 2. Related to 1, they may mark your bot as spam and block it because you
> are going too often/generate too much load on their servers.
>
> With the legal stuff aside, it would be better to store this info on your
> database, each user has have their locations in the database. Storing them
> in cookies would mean that using their cell phone browser will give them
> diff results than their computers.
>
> Also store the new rooms data in your database, this allows you to resend
> them an email if they didn't get it, and/or render a page with all the
> listings when they go back to your site.
>
>
> 2) What is the best way to make that background process in go?
>
>
>
> If you are just starting with Go, go simple and simply start the
> background process as a go routing, with a time.tick of x minutes
>
>
>
> 3) This would be great if you'd point me on some examples relating to the
> case.
>
>
>
>
> Don't have any.
>
>
> I appreciate your concern.
>
>
>


-- 
Diego Medina
Lift/Scala Consultant
di...@fmpwizard.com
https://blog.fmpwizard.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.


[go-nuts] Re: Issue with Goroutine and http.RedirectHandler

2017-02-20 Thread Diego Medina
Most likely this is your browser that "remembers" that going to one url was 
redirecting to the "incorrect" url, and it doesn't even hit your local 
server any more. To make sure this is the case, use curl from the command 
line with the -v paarameter to see all the headers:


curl -v http://127.0.0.1:8000

and see if the redirect shows the right url there.

Hope it helps.

Diego

On Monday, February 20, 2017 at 7:45:40 AM UTC-5, Rejoy wrote:
>
> Hi,
>
> I am trying to create a go routine to direct the request to another url:
>
> go http.ListenAndServe(":8000", http.RedirectHandler("
> https://127.0.0.1:8001",301))
>
> I had earler made a mistake and had typed in "https://127.0.0.1/:8001"; 
> for the url string.  But now after rectifying the mistake to the above, I 
> am still being redirected to the incorrect url.
>
> When I type in the url  ""https://127.0.0.1:8001";, the page is rendered 
> correctly.
>
> Is there a need to explicitly stop go routines. Strangely even after 
> restarting the m/c, the request is being redirected incorrectly. 
>
> Thanks
> Rejoy
>
>
>

-- 
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: Golang Messenger Bot frameworks

2017-02-22 Thread Diego Medina
Hi,

1. Would help if you could post a link to the challenge/API
2. iric, Facebook uses https://wit.ai/ for their chat bots, and they have 
an http API so using regular Go you don't need any sdk/framework

Thanks

On Wednesday, February 22, 2017 at 8:15:19 AM UTC-5, Nyah Check wrote:
>
> Hi Gophers,
>
> I a looking to participate in the Facebook Messenger Bot challenge. 
> Looking at the API. The recommended bot framework has no golang support. I 
> don't know if any one here knows any good Bot AI frameworks I could use.
>
> Inverential Peace,
> Nyah
>
> -- 
> "The heaviest penalty for declining to rule is to be ruled by someone 
> inferior to yourself." --*Plato* 
>

-- 
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: Are relative import paths idiomatic?

2017-02-22 Thread Diego Medina
Hi,

Not recommended, it's better to be explicit by using the full import path, 
even if it feels odd at first, other users reading your code will know 
exactly where the packages are.
For more info, see the last two replies here

https://groups.google.com/d/topic/golang-nuts/8grbqER8h54/discussion

from a few days ago.

Thanks



On Wednesday, February 22, 2017 at 11:52:08 AM UTC-5, so.q...@gmail.com 
wrote:
>
> Is it recommended or acceptable to use relative import paths, particularly 
> for nested packages? or should I typically always use the full path?
>

-- 
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 Messenger Bot frameworks

2017-02-22 Thread Diego Medina
great!, I use their http api directly with Go and works really well.

On Wed, Feb 22, 2017 at 1:31 PM, Nyah Check  wrote:

> Hi Diego,
>
> Here is the link: https://messengerchallenge.splashthat.com/
>
> 2. iric, Facebook uses https://wit.ai/ for their chat bots, and they have
>> an http API so using regular Go you don't need any sdk/framework
>>
> Yeah, I saw that. It appears there's a python API not Go. I'll try the
> regular HTTP then.
>
> Thanks,
> Nyah
> --
> "The heaviest penalty for declining to rule is to be ruled by someone
> inferior to yourself." --*Plato*
>



-- 
Diego Medina
Lift/Scala Consultant
di...@fmpwizard.com
https://blog.fmpwizard.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.


[go-nuts] Re: File organization in a github-ed Go project

2017-02-28 Thread Diego Medina
Note that if you write a project that other users would use, you will force 
them to update their $GOPATH to make your app work.
Which I think it a lot worse than making people who fork your project 
update the import path And like someone else said, if I need to fork a 
project, I most likely already vendor the dependency, so I simply make 
small changes to the file(s) in the vendor folder

Thanks

Diego



On Tuesday, February 28, 2017 at 5:24:28 AM UTC-5, Basile Starynkevitch 
wrote:
>
>
>
> On Monday, February 27, 2017 at 3:18:18 PM UTC+1, Basile Starynkevitch 
> wrote:
>>
>>
>>
>> On Monday, February 27, 2017 at 3:02:24 PM UTC+1, C Banning wrote:
>>>
>>> Try organizing your project as:
>>>
>>> monimelt
>>>
>>> src
>>>
>>> cmd (or "monimelt", if there's just one app)
>>>
>>> objvalmo
>>>
>>> serial 
>>>
>>>  
>>>
>>>  Then include $HOME/monimelt in your GOPATH.
>>>

  
>> Thanks for the suggestion.
>>
>> BTW, I did commit in bbc5c3789788 
>> 
>>  
>> the change of using directory names same as package names. So I have 
>> monimelt/objvalmo/objvalmo.go 
>>  
>> & monimelt/serialmo/serialmo.go 
>>  
>> files (implementing packages objvalmo & serialmo respectively)
>>
>> But does that avoid me to have to use long paths in import directives? 
>> Would that allow me to code import "serialmo" instead of import "
>> github.com/bstarynk/monimelt/serialmo" in my file objvalmo.go (to ease 
>> the forking of my github project)?
>>
>> Regards
>>
>> -- 
>> Basile Starynkevitch 
>>
>>
> Actually I did that (adding $HOME/monimelt to my GOPATH)  and now I am 
> simply importing "serialmo"
>
> BTW, I am beginning to believe that I could drop the go tool and use gb 
> build tool  instead.
>

-- 
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: Is it a concurrency issue?

2017-03-03 Thread Diego Medina
maps are not thread safe, so when you read/write to them, you need to use a 
mutex, see the "concurrency" sections here

https://blog.golang.org/go-maps-in-action

That is a good explanation with code samples.

Thanks

Diego



On Friday, March 3, 2017 at 8:31:12 AM UTC-5, 詹青朋 wrote:
>
> Hey guys,
>
> Here is my code, 
> https://github.com/myzhan/boomer/blob/dc6893a72c2b32c27ff6d7646a55b135493ba7e1/stats.go#L33
>
> I'm trying to figure out *why I got nil from "this.**Entries(a map)"*, 
> and I'm really confused.
>
> I hava checked if the key exists, and if not, I put a new key in 
> "this.Entries".
>
> If "clearAll" is called, "this.Entries" will be repalced by a new map.
>
> "init()" starts a goroutine to do all the things, get a entry from 
> "this.Entries" or call "clearAll". 
>
> Is it a concurrency issue?
>
> Thanks for your help.
>

-- 
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 Path & Github Sync

2017-04-05 Thread Diego Medina
Something that wasn't too clear to me when I started using Go several years 
ago was "where is the .git folder going to end up as part of the GOPATH 
path", if this is what you are also wondering, the answer is:


go 
--- bin
--- pkg
--- src
--flmain
--flowlogs
--github.com
you
--myProject
--/// At this level is where your githubg repo starts, this 
is where you will run git init from as the first step, you have to manually 
mkdir -p $GOPATH/src/github.com/yourusername/myProject

so, if flowlogs is also a project hosted on github, you will want to change 
where that is in your GOPATH, and put it under .you/.. so that 
it is at the same level as MyProject


Hope that helps.

Diego



On Wednesday, April 5, 2017 at 3:24:16 PM UTC-4, Justin Israel wrote:
>
>
>
> On Thu, Apr 6, 2017, 6:55 AM Mukund 8kmiles  > wrote:
>
>> Hi 
>>
>> Is there a best practice or recommended folder structure followed for 
>> maintaining a GH repo inside GOPATH 
>>
>> I maintain my GO source in the default GOPATH which is /home//go
>>
>> go 
>> --- bin
>> --- pkg
>> *--- src*
>> *--flmain*
>> *--flowlogs*
>> *---*
>>
>> I would like to maintain the same path for Github repo and gopath. Is 
>> there a standard practice available without copying files between folders?
>>
>
> There should be no difference between github projects, and other projects, 
> in terms of how you store them. 
>
> go 
> --- bin
> --- pkg
> --- src
> --flmain
> --flowlogs
> --github.com
> you
> --myProject
>
> There shouldn't be a need for copying files around. Can you be a but more 
> specific about the problem you are having? Really every project should be 
> using some kind of version control and be organised under a namespacing 
> structure similar to github to prevent clashes. 
>
>
>> Thanks & Regards
>> Mukund
>>
>> -- 
>> 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: Best practice for client API with both context-aware and non-context-aware methods

2017-04-16 Thread Diego Medina
Like others have said, go with #2, and to help those developers who are new 
to Go, provide easy to find (maybe in the README) examples of what to do 
when they don't actually have any useful context value to pass. That will 
save them time searching around to see what context is, what to use it for 
and what to do when you still don't want it/need it.

Regards,

Diego


On Sunday, April 16, 2017 at 2:06:05 PM UTC-4, Dragos Harabor wrote:
>
> #2. It's easy enough to pass context.TODO() to quickly get a client going.
>
> On Friday, April 14, 2017 at 5:49:55 PM UTC-7, Jonathan Hall wrote:
>>
>> I'm working on a client client API, and am accepting a `context.Context` 
>> argument as the first argument to each function.
>>
>> However, for ease of use, I'm also providing non-context aware versions 
>> of each method.  So my API looks roughly like:
>>
>> FooContext(ctx context.Context, args...)
>> Foo(args...)
>>
>> where Foo(args...) just calls FooContext(context.Background(), args...).
>>
>> Multiply this times about 25 methods across a few different types, and I 
>> have a very cluttered package (and godoc).
>>
>> I borrowed this approach from the `sql` package.  But the sql package has 
>> about half as many methods, so it seems less cluttered. It also has to 
>> retain backward compatibility with context-unaware code.
>>
>> Is there anything like a "best practice" in this area, given that (unlike 
>> the `sql` package) I have no backward compatibility to maintain?
>>
>> Some options I've considered:
>>
>> 1. Keep things as they are.
>> 2. Only expose the 'Context' versions of my methods (and drop the 
>> 'Context' suffix)
>> 3. For each type, add a single `Background()` method, which returns a 
>> clone type, that uses a background context. So `client.Foo()` becomes 
>> `client.Background().Foo()`.  This doesn't reduce clutter, but it helps to 
>> organize it on the godoc page, by grouping all the Context-aware methods 
>> together, and the unaware together.
>>
>> I think I'm leaning toward #2.  I imagine a fair number of Go newbies 
>> will find the context argument to be "strange", but I hope documentation 
>> will fix that.
>>
>> Are there other alternatives I should consider?
>>
>> Much thanks,
>>
>> Jonathan
>>
>>

-- 
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] ast - Missing Ident.Obj

2017-04-17 Thread Diego Medina
Hi,

I'm using go/ast (and token/types. etc) to parse a Go project, it all works 
well when my program only has one package, but there are times where I have 
code like this:

file-a.go
=
package a

...

selector := b.Selector(CompanyID)

...


and then

file-b.go

package b



func  Selector(n string) string{
...
}


Simple, in package a I call a function from package b, the issue is that 
when I'm walking the ast for pacakge a, I reach selector as an *ast.Ident 
and then I check 

the .Obj value and it is nil.

Is there a way to "fill in" this information?
For now, the information I'm looking for is the Decl value, 

 
I tried using golang.org/x/tools/go/loader to solve this but it has the 
same issue, it doesn't "fill in" the missing information, it does give me a 
different way to access the declaration, but it also does a lot more work 
that I don't need and makes my too run slower.

Hope I was clear.

Thanks

Diego


-- 
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: ast - Missing Ident.Obj

2017-04-17 Thread Diego Medina
Sorry, I didn't include enough information, you are right, this is more 
about the type checker,

I have a call to

conf.Check(pkg.path, fset, astFiles, &info)

that does the typecheck gets the astFiles from the given package (a in this 
example) , but I didn't find a way to pass multiple packages to conf.Check

If I mix files from diff packages in astFiles, I get an error from the type 
checker saying something like, expected package a but found b for file 
xyz.go


conf is:

conf := &types.Config{
Error: func(e error) {
fmt.Println("failed to typecheck: ", e)
os.Exit(1)
},
Importer: importer.Default(),
}


Thanks


On Monday, April 17, 2017 at 12:55:52 PM UTC-4, mhh...@gmail.com wrote:
>
> Can you clarify your expectation about ast ?
>
> in my very humble understanding, Obj is for type checker more than ast.
> I re call when i worked with it, i had to hide it when i wanted to 
> visualize the tree
> I even created a gist,
> https://gist.github.com/mh-cbon/3ed5d9c39e9635cfed0f89698133
> to use in place of https://golang.org/pkg/go/ast/#example_Print
>
> On Monday, April 17, 2017 at 3:45:23 PM UTC+2, Diego Medina wrote:
>>
>> Hi,
>>
>> I'm using go/ast (and token/types. etc) to parse a Go project, it all 
>> works well when my program only has one package, but there are times where 
>> I have code like this:
>>
>> file-a.go
>> =
>> package a
>>
>> ...
>>
>> selector := b.Selector(CompanyID)
>>
>> ...
>> 
>>
>> and then
>>
>> file-b.go
>> 
>> package b
>>
>> 
>>
>> func  Selector(n string) string{
>> ...
>> }
>> 
>>
>> Simple, in package a I call a function from package b, the issue is that 
>> when I'm walking the ast for pacakge a, I reach selector as an *ast.Ident 
>> and then I check 
>>
>> the .Obj value and it is nil.
>>
>> Is there a way to "fill in" this information?
>> For now, the information I'm looking for is the Decl value, 
>>
>>  
>> I tried using golang.org/x/tools/go/loader to solve this but it has the 
>> same issue, it doesn't "fill in" the missing information, it does give me a 
>> different way to access the declaration, but it also does a lot more work 
>> that I don't need and makes my too run slower.
>>
>> Hope I was clear.
>>
>> Thanks
>>
>> Diego
>>
>>
>>

-- 
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: ast - Missing Ident.Obj

2017-04-17 Thread Diego Medina
Thanks, I'll go ahead and prepare a small sample project that shows exactly 
what I'm trying to do and then I'll post back.

Regards,

Diego

On Monday, April 17, 2017 at 5:59:25 PM UTC-4, mhh...@gmail.com wrote:
>
> Hi,
>
> no problem.
>
> I think you are looking to load multiple package at once, something that d 
> load import declaration as well,
>
> https://godoc.org/golang.org/x/tools/go/loader#Config.FromArgs
>
> https://godoc.org/golang.org/x/tools/go/loader#Config.Import
>
> https://play.golang.org/p/TzbncKLd7b
>
> I think we can help better if you can uncover,
>
> - "expected package a but found b for file xyz.go"
> - "For now, the information I'm looking for is the Decl value, "
>
> Must be a simple difficulty to fix.
>
> On Monday, April 17, 2017 at 8:29:22 PM UTC+2, Diego Medina wrote:
>>
>> Sorry, I didn't include enough information, you are right, this is more 
>> about the type checker,
>>
>> I have a call to
>>
>> conf.Check(pkg.path, fset, astFiles, &info)
>>
>> that does the typecheck gets the astFiles from the given package (a in 
>> this example) , but I didn't find a way to pass multiple packages to 
>> conf.Check
>>
>> If I mix files from diff packages in astFiles, I get an error from the 
>> type checker saying something like, expected package a but found b for file 
>> xyz.go
>>
>>
>> conf is:
>>
>> conf := &types.Config{
>> Error: func(e error) {
>> fmt.Println("failed to typecheck: ", e)
>> os.Exit(1)
>> },
>> Importer: importer.Default(),
>> }
>>
>>
>> Thanks
>>
>>
>> On Monday, April 17, 2017 at 12:55:52 PM UTC-4, mhh...@gmail.com wrote:
>>>
>>> Can you clarify your expectation about ast ?
>>>
>>> in my very humble understanding, Obj is for type checker more than ast.
>>> I re call when i worked with it, i had to hide it when i wanted to 
>>> visualize the tree
>>> I even created a gist,
>>> https://gist.github.com/mh-cbon/3ed5d9c39e9635cfed0f89698133
>>> to use in place of https://golang.org/pkg/go/ast/#example_Print
>>>
>>> On Monday, April 17, 2017 at 3:45:23 PM UTC+2, Diego Medina wrote:
>>>>
>>>> Hi,
>>>>
>>>> I'm using go/ast (and token/types. etc) to parse a Go project, it all 
>>>> works well when my program only has one package, but there are times where 
>>>> I have code like this:
>>>>
>>>> file-a.go
>>>> =
>>>> package a
>>>>
>>>> ...
>>>>
>>>> selector := b.Selector(CompanyID)
>>>>
>>>> ...
>>>> 
>>>>
>>>> and then
>>>>
>>>> file-b.go
>>>> 
>>>> package b
>>>>
>>>> 
>>>>
>>>> func  Selector(n string) string{
>>>> ...
>>>> }
>>>> 
>>>>
>>>> Simple, in package a I call a function from package b, the issue is 
>>>> that when I'm walking the ast for pacakge a, I reach selector as an 
>>>> *ast.Ident and then I check 
>>>>
>>>> the .Obj value and it is nil.
>>>>
>>>> Is there a way to "fill in" this information?
>>>> For now, the information I'm looking for is the Decl value, 
>>>>
>>>>  
>>>> I tried using golang.org/x/tools/go/loader to solve this but it has 
>>>> the same issue, it doesn't "fill in" the missing information, it does give 
>>>> me a different way to access the declaration, but it also does a lot more 
>>>> work that I don't need and makes my too run slower.
>>>>
>>>> Hope I was clear.
>>>>
>>>> Thanks
>>>>
>>>> Diego
>>>>
>>>>
>>>>

-- 
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: Building with "go install" vs "go build"

2017-04-18 Thread Diego Medina
> Often, this involves incrementing the version [...]

If the process of saying "this binary is good to go, deploy it locally for 
use" already involve more than go install, maybe you could also "deploy" 
the binary to a different location than $GOPATH/bin . The benefit there is 
that you can take advantage of the incremental/faster compile of go 
install, without having a broken binary.

Unless that has other negative side effects in your own setup. But, if you 
are ok with the speed of go build, no need to change.



On Tuesday, April 18, 2017 at 1:02:03 PM UTC-4, Marvin Renich wrote:
>
> * Dave Cheney > [170418 09:57]: 
> > > Apparently Dave Cheney says to prefer "go install" over "go build"[3], 
> > except when cross-compiling [4]. However, many of these posts are older, 
> > and Golang moves at such a rapid clip that it's difficult to keep track 
> of 
> > what everybody is doing. 
> > 
> > This information is still correct. 
> > 
> > On Friday, 10 February 2017 02:55:25 UTC+11, Jonathan Yu wrote: 
> > > 
> > > Hello Gophers! 
> > > 
> > > There's a fair amount of documentation available[0] about how "go 
> install" 
> > > works, particularly in contrast to "go build,"[1,2] but not a lot 
> about 
> > > which one is more idiomatic/preferred.  Using the standard toolchain, 
> it 
> > > seems there's three ways to build your applications: 
>
> I use "go build" in the "edit, build, test, repeat" cycle, and only use 
> go install when I have what I consider to be a working program.  Often, 
> this involves incrementing the version and adding a version tag to the 
> repo. 
>
> If I used go install during edit-test, I would often have a non-working 
> executable in my path, so I would not be able to use the program for 
> "real" work while I am knee-deep in a bug fix or implementing a new 
> feature. 
>
> Dave's mileage obviously varies from mine, which is fine.  However, I 
> believe my use case and reasoning is common enough that I believe it is 
> counterproductive to try to declare one way or the other to be "The 
> Idiomatic Way".  This just boils down to personal preference and work 
> flow, and trying to tell others that one way is the "preferred" way is 
> wrong. 
>
> ...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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: "Selling" Go to Management

2017-04-30 Thread Diego Medina
All those sound like good points, but it depending on how technical your 
mid/high level management are, you may want to adjust the wording.

if your audience are very technical, go fmt, and not having to read/learn 
code style sounds great, if they are not very technical, they will care 
less about where the developers put an opening bracket, but will care more 
about the fact that whoever does code review, will spend less time 
commenting on "small details like bracket position" and more time adding 
value to the company (by either writing more code themselves or being able 
to accept new code faster)

Good luck on the presentation!


On Sunday, April 30, 2017 at 3:41:14 AM UTC-4, Miki Tebeka wrote:
>
> Hi,
>
> I'm giving a 1 hour talk on Go to mid/high level management. Here are the 
> points I thought to bring up (not in order), I'd appreciate any 
> comments/ideas.
>
> * The free lunch is over
> - threads/async are difficult to work with
> * Small language
> - Easy to learn
> * Simple C based syntax
> - Easy to understand
> - Static typing
> * Forces you to check errors
> - Stable code
> * import "C"
> - Integration with legacy code
> * "go fmt" and tooling in general
> - The go tool
> - The upcoming "dep"
> * Static executable
> - Easy deployment
> * Fast compilation
> - Quick development cycles
> * Production grade HTTP server
> - With HTTP 2.0 support
> * Efficient & Fast
> - iron.io post on going from 30 RoR to 2 Go servers
>
> Also, there was a post I read about a company which dropped nginx/haproxy 
> and started to use the Go HTTP server directly with incoming traffic, 
> anyone has the link?
>
> Thanks,
> --
> Miki 
>

-- 
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: what can I do with this 'workspace' Google have given me?

2017-05-18 Thread Diego Medina
Hi,

Having a default "go" folder inside your home directory is a recent change 
(I believe it was introduced in 1.8)

The mac installer may do extra steps, but my guess is that you started 
using Go before you set GOPATH to the dropbox folder, a simple 

go get 

would create the $HOME/go  folder and subfolders you see.

If from now on you will only use your dropbox path as GOPATH, then it 
should be safe to delete the $HOME/go folder (may want to just rename it to 
be safe) and Go will not recreate it. I you do see it come back, then 
something isn't right with how you set up $GOPATH


BTW, the default $HOME/go path became a default GOPATH as a way to help new 
users get started with Go before they get familiar with how to setup env 
variables, etc but you can always override it if this path isn't right for 
you.

Hope that helps.

Diego




On Thursday, May 18, 2017 at 10:27:55 AM UTC-4, Sam Pollard wrote:
>
> I’m new to GO and fairly new to the command line on Mac (but having a lot 
> of fun learning :-) )
>
> Apologies in advance if this has been covered elsewhere. I’ve tried 
> searching but not found the answer.
>
>
> I’ve installed GO on two separate Macs, and started learning GO, written a 
> couple of extremely simple programs, got them running, all’s well.
>
>
> I’ve created my workspace inside my Dropbox folder and done what I think I 
> need to do inside my .bash_profile to make sure my GOPATH knows where to 
> find stuff.
>
>
> That done, I then realise that the installation of Go left a folder called 
> ‘go’ inside my home folder. That ‘go’ folder has subdirectories called bin, 
> src, pkg. 
>
> I’m assuming that this is Google’s way of saying, you’re going to need a 
> workspace, let us create one for you. 
>
> That workspace is not empty. There are, indeed, several layers of nested 
> subfolders, containing quite a lot of ‘stuff’, the purpose of which I’m not 
> at all clear about at the moment. I can only assume it’s ‘stuff’ which 
> Google thinks I may need at some point. 
>
> (The binaries named go, godoc, gofmt are tucked away in usr/local/go/bin 
> where we’d expect them to be).
>
>
> I must admit, it seems odd that in the documentation I couldn’t find any 
> reference to this ‘workspace’, nor do any of the various tutorials/videos 
> that I’ve watched mention it.
>
>
> My question: can I simply move the contents of that ‘go’ folder to the 
> workspace I’ve created in my Dropbox folder?
>

-- 
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] Installing a package

2017-07-03 Thread Diego Medina
Hi,

3 things:

1. can you post here what you get when you type 

echo $GOPATH


just to make sure your GOPATH isn't being updated in some other place you 
didn't know about

2. How are you installing a package?

3. can you post what is being placed in /home ?

Thanks

Diego

On Monday, July 3, 2017 at 1:43:51 AM UTC-4, Martin Spasov wrote:
>
> I do not have two elements in my path o.O
>
> The only path in my GOPATH is ''/home/Documents/GoProjects''.
>
> On Monday, July 3, 2017 at 1:27:09 AM UTC+3, Matt Harden wrote:
>>
>> Move that to the beginning of your GOPATH (first entry instead of last) 
>> and it should work for you.
>>
>> By the way, I normally only have one entry in my GOPATH. Out of 
>> curiosity, why do you have more than one?
>>
>> On Sun, Jul 2, 2017, 14:20 Martin Spasov  wrote:
>>
>>> hey, my src, pkg and bin directories are in the GoProjects folder which 
>>> is the last one in the path
>>> On Mon, Jul 3, 2017 at 12:17 AM, Justin Israel  
>>> wrote:
>>>
>>> I think two different things are being described here. 
>>>
>>> GOPATH=/path/to/src:/path/to/src2
>>>
>>> The first path should be the one that gets the pkg install location. 
>>>
>>> On Mon, Jul 3, 2017, 9:02 AM Martin Spasov  wrote:
>>>
 Does that mean that it is not possible to chose where you want to 
 install the pkg ?
 On Mon, Jul 3, 2017 at 12:00 AM, Matt Harden  
 wrote:

 I believe it's the first folder in GOPATH, not the last.

 On Sun, Jul 2, 2017 at 1:21 PM  wrote:

> From what I found here when you install packages with go get, they get 
> installed in the last folder of your GOPATH env variable. Mine is 
> ''/home/Documents/GoProjects'' but the installed packages end up in 
> ''/home''. It is probably a stupid question, but I honestly do not know 
> what is wrong 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...@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...@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: Switching from rsc.io/letsencrypt to x/crypto/acme/autocert

2017-07-05 Thread Diego Medina
yes, you provide the storage implementation and the library will use it 
when it needs to store/retrieve certs



On Wednesday, July 5, 2017 at 10:48:26 AM UTC-4, Daniel Martí wrote:
>
> Hi all, 
>
> One project I contribute to started using rsc.io/letsencrypt years ago. 
> Now that it's recommended to switch to the latter, I've been looking 
> into getting it done. 
>
> But I'm confused as to what happened to Manager.Marshal and 
> Manager.Unmarshal. We use these to store the state somewhere and get it 
> back at a later time. 
>
> Were these removed on purpose from acme/autocert? What's the recommended 
> alternative? 
>
> I've seen Manager.Cache but it seems different. Instead of getting or 
> setting the state at will, you instead supply the storage 
> implementation. Is this what we should be using? 
>
> Thanks! 
>
> -- 
> Daniel Martí - https://mvdan.cc/ 
>

-- 
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: pprof samples

2020-04-22 Thread Diego Medina
Hi,

This doesn't answer your question but usually when I need to profile our 
app, I first use expvar to report different internal stats like what the 
app is doing (how many records is it walking from the db, any batch 
process, etc), send those to datadog (any monitoring works fine) and then I 
know "which code" is the one that is causing high CPU/memory.

Then it's a matter to writing simple go benchmark code (sometimes even 
talking to the db, I don't bother with mocking) and use pprof on the 
benchmark code

Hope that helps.

Diego


On Monday, April 20, 2020 at 8:36:00 PM UTC-4, Aditya Saxena wrote:
>
> Hi,
>
> I am trying CPU profiling a program that runs for an hour. However when I 
> start pprof it says Total samples are only for 1.32 min. Why are the 
> samples not collected for the whole duration of the program ? Is there a 
> missing setting I need to enable ?
>
> Duration: 1.14hrs, Total samples = 1.32mins ( 1.94%)
>
> 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/46d295cb-3fdf-47aa-9ffb-3905ecef06d0%40googlegroups.com.


[go-nuts] Monorepo several binaries and build only some

2020-09-14 Thread Diego Medina

Hi,

Is there a way to know if a binary has to be rebuilt, due to changes to 
some of its dependencies?

Let's say I have a repo with this structure:

/cmd/tool1/main.go
/cmd/tool2/main.go
/pkg/users/update.go
/pkg/math/avg.go


tool1 imports the math package
tool2 imports both, math and user packages

As part of our CI/CD, I need to know that if a Pull Request only updates 
the user pacakge, only tool2 needs to be deployed to production.

This is of course a simplified example, in real life we'll have a few more 
binaries and a much higher number of packages.

Thanks

Diego





-- 
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/fd7fffeb-eb60-4ef8-8024-5cabb47741c1n%40googlegroups.com.


[go-nuts] Re: Monorepo several binaries and build only some

2020-09-14 Thread Diego Medina
Thanks!

On Monday, September 14, 2020 at 5:02:53 PM UTC-4 Alex wrote:

> Sorry, return values were reversed. "true\n" if it needs rebuilding
>
> On Tuesday, 15 September 2020 at 5:00:23 am UTC+8 Alex wrote:
>
>> You can run the command: *go list -f {{.Stale}}* 
>> It will print a "true\n" or "false\n" if the package/program in the 
>> current folder needs to be rebuilt.
>>
>> On Tuesday, 15 September 2020 at 1:15:32 am UTC+8 fmpw...@gmail.com 
>> wrote:
>>
>>>
>>> Hi,
>>>
>>> Is there a way to know if a binary has to be rebuilt, due to changes to 
>>> some of its dependencies?
>>>
>>> Let's say I have a repo with this structure:
>>>
>>> /cmd/tool1/main.go
>>> /cmd/tool2/main.go
>>> /pkg/users/update.go
>>> /pkg/math/avg.go
>>>
>>>
>>> tool1 imports the math package
>>> tool2 imports both, math and user packages
>>>
>>> As part of our CI/CD, I need to know that if a Pull Request only updates 
>>> the user pacakge, only tool2 needs to be deployed to production.
>>>
>>> This is of course a simplified example, in real life we'll have a few 
>>> more binaries and a much higher number of packages.
>>>
>>> Thanks
>>>
>>> Diego
>>>
>>>
>>>
>>>
>>>
>>>

-- 
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/aae2a1fb-2301-45eb-b3d0-f759f3715267n%40googlegroups.com.


[go-nuts] Re: Help: Encrypting and Decrypting ASCII armor PGP Messages with golang.org/x/crypto/openpgp

2020-10-10 Thread Diego Medina
There is only a small change I had to do to get it to encrypt and decrypt:


inside your encryptMessage() func, change:

_, err = encryptorWriter.Write([]byte(message))
//messageReader := bytes.NewReader([]byte(message))
//_, err = io.Copy(encoderWriter, messageReader)

using the Write() method vs io.Copy works

Also, you don't need the chunk about the private key in the encrypt function

Updated playground link

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

Thanks

Diego



On Tuesday, August 18, 2020 at 1:00:50 PM UTC-4 srlor...@gmail.com wrote:

> Hi,
>
>
> i have been trying to decrypt and encrypt ASCII armor PGP Messages that i 
> receive and send to a API.
>
>
> I Wrote a function for decrypting messages and another one for encrypting 
> messages. The Decrypting function Works and i can decrypt the API's 
> messages. But My encrypt function Seems to be broken as Neither the API or 
> my decrypt function can decrypt the Messages encrypted by my encrypt 
> function.
>
>
> Decrypting the encrypted messages from my encrypt function always result 
> in the following error: 
>
> "Error reading message: openpgp: unsupported feature: unknown 
> SymmetricallyEncrypted version"
>
>
> I have uploaded a example to the Go Play Ground : 
> https://play.golang.org/p/JhhZ4xWWYvn
>
>
> Any help is Appreciated.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6dc18bc2-5d0d-4e40-b6a9-b073d5acde3an%40googlegroups.com.


[go-nuts] Re: [CODE REVIEW] How to improve structure of Service and DAO Layers

2020-10-10 Thread Diego Medina
Hi Karan,

>I don't have a background in Java/C#[...]

This is actually good, there is less for you to "unlearn"

If you don't want to pass parameters to create a user, like passing the 
userID, name, etc, because it "seems wrong/verbose", then don't worry about 
it.
In Go (any I apply this to other languages too), it's better to be explicit 
with the parameters that your functions or methods need, vs being "clever" 
and try to hide the fact that to create
a models.User instance, you need 10 pieces of data.

When I write Go code or when I do code review in our company, I ask 
questions like:

* Will future junior devs have a hard time reading/understanding the code?
If the answer is yes, then I need to rewrite it, code should be easy to 
follow (most of the time, of course there are going to be exceptions, but 
try to write simple code as much as you can)
* If I get a call at 3am to debug our app, will it take me hours to 
remember why this code is written like this?
Again, the idea is, code should be essy to follow, no hiding and no adding 
abstractions just because people do that in Java/etc
P.S. Of course I don't want to even get a 3am call :)

Hope this helps.

Diego


On Wednesday, August 19, 2020 at 12:39:27 PM UTC-4 Karan Singh wrote:

> I am having a bit of difficulty in designing my Go code.
>
> I'll try to demonstrate things with a very simple example of adding a new 
> user to the database. I have 3 major components in this example: a handler, 
> a service and a dao layer.
>
>1. 
>
>My Handler is only doing one thing: Calling a service.
>2. 
>
>The service is managing all the business logic and then calling the 
>DAO to interact with the database.
>3. 
>
>The DAO also has only responsibility: Storing in the database.
>
> Also, just for context I am making GraphQL(gqlgen) requests to interact 
> with my ElasticSearch(olivere/elastic) database, but that shouldn't affect 
> the design too much.
>
> MY CODE:
>
> *https://play.golang.org/p/Wm9qubLJIGM 
> *
>
> I have read a lot of posts about using structs/interfaces to handle the 
> service layer and DAO layer, but I am unable to implement the same in my 
> usecase.
>
> I don't have a background in Java/C# so I'm not well versed with OOP 
> Principles but I did read a lot on MVC based on other answers.
>
> My code works for now, but is it bad code?
>
> I don't want to be passing parameters from one function to another. Is 
> there a way to that with receivers on methods?
>

-- 
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/3c15bd16-25d4-46c8-a754-2b33eda23faen%40googlegroups.com.


[go-nuts] Not getting 1.15.5 as the latest Go version - getgo

2020-11-17 Thread Diego Medina
Hi,

Today I tried the getgo [1] binary but instead of providing Go 1.15.5, it 
installed 1.15.4. I looked around the code and ended up in

https://golang.org/VERSION?m=text

which reports 1.15.4 as the latest. Is this the right place to report this 
to get it fixed?


[1] https://github.com/golang/tools/tree/master/cmd/getgo


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/f8c33591-43eb-42cf-84c4-e8ea6008ec7cn%40googlegroups.com.


[go-nuts] Re: Not getting 1.15.5 as the latest Go version - getgo

2020-11-17 Thread Diego Medina
great, thanks! Then I'll see about raising an issue/PR with the project 
that uses that url.



On Tuesday, November 17, 2020 at 2:09:19 PM UTC-5 seank...@gmail.com wrote:

> VERSION reports the version the site is under, use 
> https://golang.org/dl/?mode=json instead
>
> On Tuesday, November 17, 2020 at 5:21:43 PM UTC+1 fmpw...@gmail.com wrote:
>
>> Hi,
>>
>> Today I tried the getgo [1] binary but instead of providing Go 1.15.5, it 
>> installed 1.15.4. I looked around the code and ended up in
>>
>> https://golang.org/VERSION?m=text
>>
>> which reports 1.15.4 as the latest. Is this the right place to report 
>> this to get it fixed?
>>
>>
>> [1] https://github.com/golang/tools/tree/master/cmd/getgo
>>
>>
>> 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/46ddb3aa-d2bd-4222-a788-1181dc1cc07cn%40googlegroups.com.


[go-nuts] Re: Not getting 1.15.5 as the latest Go version - getgo

2020-11-17 Thread Diego Medina
I entered https://github.com/golang/go/issues/42676 and I sent the related 
CL

On Tuesday, November 17, 2020 at 2:23:45 PM UTC-5 Diego Medina wrote:

> great, thanks! Then I'll see about raising an issue/PR with the project 
> that uses that url.
>
>
>
> On Tuesday, November 17, 2020 at 2:09:19 PM UTC-5 seank...@gmail.com 
> wrote:
>
>> VERSION reports the version the site is under, use 
>> https://golang.org/dl/?mode=json instead
>>
>> On Tuesday, November 17, 2020 at 5:21:43 PM UTC+1 fmpw...@gmail.com 
>> wrote:
>>
>>> Hi,
>>>
>>> Today I tried the getgo [1] binary but instead of providing Go 1.15.5, 
>>> it installed 1.15.4. I looked around the code and ended up in
>>>
>>> https://golang.org/VERSION?m=text
>>>
>>> which reports 1.15.4 as the latest. Is this the right place to report 
>>> this to get it fixed?
>>>
>>>
>>> [1] https://github.com/golang/tools/tree/master/cmd/getgo
>>>
>>>
>>> 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/b50a89f0-45eb-4cd7-8832-76b58a2c7544n%40googlegroups.com.