AW: [go-nuts] Using Mysql and Golang combined resources

2020-09-15 Thread Lutz Horn
The net contains many sources for this kind of information. Just a random pick:

https://medium.com/@hugo.bjarred/mysql-and-golang-ea0d620574d2


Von: golang-nuts@googlegroups.com  im Auftrag von 
Ayush Paudel 
Gesendet: Montag, 14. September 2020 13:11
An: golang-nuts
Betreff: [go-nuts] Using Mysql and Golang combined resources

can anyone suggest me some resources to start using MySQL with Golang? I am 
familiar with Go and want to learn using MySQL with Go.

thankyou!

--
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/2c00d529-1151-4c07-b9d5-3eede07677f3n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/AM7P191MB106016EA7415A536B0CA5EB09E200%40AM7P191MB1060.EURP191.PROD.OUTLOOK.COM.


AW: [go-nuts] Re: The latest version of package in pkg.go.dev

2020-08-15 Thread Lutz Horn
Take a look at this: https://gist.github.com/loisaidasam/b1e6879f3deb495c22cc

Von: Tong Sun
Gesendet: ‎15.‎08.‎2020 17:51
An: golang-nuts
Cc: seank...@gmail.com
Betreff: Re: [go-nuts] Re: The latest version of package in pkg.go.dev

Oh, thanks.

The very reason that I do that is to avoid the following situation:

for i in `jot 12`; do echo $i > f; git commit -am "$i"; git tag v0.0.$i; done

$ git tag -l
v0.0.1
v0.0.10
v0.0.11
v0.0.12
v0.0.2
v0.0.3
v0.0.4
v0.0.5
v0.0.6
v0.0.7
v0.0.8
v0.0.9

If no leading 0s allowed, how do you guys solve the above problem?


On Sat, Aug 15, 2020 at 5:01 AM seank...@gmail.com  wrote:
>
> that's an invalid semver, no leading 0s  allowed
>
> https://semver.org/#spec-item-2 :
> A normal version number MUST take the form X.Y.Z where X, Y, and Z are 
> non-negative integers, and MUST NOT contain leading zeroes. X is the major 
> version, Y is the minor version, and Z is the patch version. Each element 
> MUST increase numerically. For instance: 1.9.0 -> 1.10.0 -> 1.11.0.
>
> On Saturday, August 15, 2020 at 4:08:06 AM UTC+2 sunto...@gmail.com wrote:
>>
>> How to force update the latest version of package in pkg.go.dev?
>>
>> My https://github.com/go-easygen/easygen/releases/tag/v5.1.01 has been 
>> release for over 10 days, but the 
>> https://pkg.go.dev/github.com/go-easygen/easygen?tab=versions is still 
>> showing an old version.
>>
>> From https://proxy.golang.org/ I saw
>>
>>> explicitly request that version via go get module@version. After one minute 
>>> for caches to expire, the go command will see that tagged version. If this 
>>> doesn't work for you, please file an issue.
>>
>>
>>
>> So I did:
>>
>>
>> go get github.com/go-easygen/eas...@v5.1.01
>>
>> go: downloading github.com/go-easygen/easygen 
>> v4.0.1-0.20200804033944-7bacacfacf6a+incompatible
>> go: github.com/go-easygen/easygen v5.1.01 => 
>> v4.0.1-0.20200804033944-7bacacfacf6a+incompatible
>> go: finding module for package gopkg.in/yaml.v2
>> . . .
>>
>> $ date
>> Fri Aug 14 21:56:06 EDT 2020
>>
>> $ lynx -dump -width=78 
>> "https://pkg.go.dev/github.com/go-easygen/easygen?tab=versions;; date
>> . . .
>> v1 - github.com/go-easygen/easygen
>>
>>  * [32]v4.1.0+incompatible - Jun 19, 2019
>>  * [33]v4.0.0+incompatible - Mar 24, 2019
>>  * [34]v3.0.0+incompatible - May 4, 2018
>> . . .
>> Fri Aug 14 22:06:18 EDT 2020
>>
>>
>> So do I need to file an issue, or I've missed something?
>>
>> Thx
>>
>>
> --
> 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/ECa7ZlbLNW0/unsubscribe.
> To unsubscribe from this group and all its topics, 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/074b1e7d-7b1c-43c0-abc6-d20eb2625c7dn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMmz1OdXGXc5D86oMdC2ABZ%2BuSER_P8hb7piimNPac3enihjeA%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/AM7P191MB10609EBB105DD66872F626429E410%40AM7P191MB1060.EURP191.PROD.OUTLOOK.COM.


Re: [go-nuts] Is it possible to interpose exported functions.

2020-08-07 Thread Lutz Horn

Am 07.08.20 um 09:05 schrieb Yonatan Gizachew:

//export Test
func Test() {
fmt.Println("test code")
}


Yes, now  `Test` is exported.

Lutz

--
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/AM7P191MB1060AD2D824DE290A8587C129E490%40AM7P191MB1060.EURP191.PROD.OUTLOOK.COM.


Re: [go-nuts] Is it possible to interpose exported functions.

2020-08-07 Thread Lutz Horn

Am 07.08.20 um 05:00 schrieb emeg...@gmail.com:

//export test
func  test() {
fmt.Println("test code")
}


`test` is not exported. It would be, if it was called `Test` with a 
capital `T`.


Lutz

--
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/DB8P191MB1063FA4C7DCBC0251C9B28119E490%40DB8P191MB1063.EURP191.PROD.OUTLOOK.COM.


Re: [go-nuts] template

2020-07-22 Thread Lutz Horn

I am running a website for which we use templates.


Do you use https://golang.org/pkg/html/template/? If yes, how do you use 
them? If no, this question is off-topic for this mailing list.


Lutz

--
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/AM7P191MB1060A58CEA463342E216714B9E790%40AM7P191MB1060.EURP191.PROD.OUTLOOK.COM.


AW: [go-nuts] where is temp file created by http server

2020-07-16 Thread Lutz Horn
See the documentation of `os.TempDir` at https://golang.org/pkg/os/#TempDir

> On Windows, it uses GetTempPath, returning the first non-empty value from 
> %TMP%, %TEMP%, %USERPROFILE%, or the Windows directory.

Lutz


Von: golang-nuts@googlegroups.com  im Auftrag von 
hao dong 
Gesendet: Donnerstag, 16. Juli 2020 12:44
An: golang-nuts
Betreff: [go-nuts] where is temp file created by http server

As I have learned, http server will store user-upload file on disk when its 
size exceed 32MB.
I read the source code, and find out the large file to store in os.TempDir(), 
however, after uploading a large file, I can not find the file in the temp dir.
Cloud someone enlight me, where is the temp file ?

--
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/0232db86-9bfb-42ae-b24b-49ea57a222ado%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/AM7P191MB106017ACC261B245242CF7BA9E7F0%40AM7P191MB1060.EURP191.PROD.OUTLOOK.COM.


AW: [go-nuts] ignore json tag for field list in a struct field

2020-07-03 Thread Lutz Horn
This code throws an error:

./prog.go:10:10: struct field Field2 repeats json tag "field_1" also at 
prog.go:10

see https://play.golang.org/p/sFZ-6GWUO0J

Why not use this:

type a_1_struct_name struct {
Field1 string `json:"field_1"`
Field2 string `json:"field_2"`
}


Von: golang-nuts@googlegroups.com  im Auftrag von 
amarjeetanandsi...@gmail.com 
Gesendet: Freitag, 3. Juli 2020 16:11
An: golang-nuts
Betreff: [go-nuts] ignore json tag for field list in a struct field

If there is a json tag with multiple fields in a single line, is there any json 
parser which will consider the json field name?
Like in below, "encoding/json" ignores the fields to unmarshal if there are 
multiple fields in a single line with a json tag.
EX: below code will print nothing.


type a_1_struct_name struct {
   Field1, Field2 string `json:"field_1"`
}

func main() {
   a := a_1_struct_name{}
   j := `{"field_1": "field_1_val"}`
   if err := json.Unmarshal([]byte(j), ); err != nil {
  log.Fatal(err)
   }
   fmt.Println(a)
}

But if we remove the json tag `json:"field_1"` and the change the value of 
json(j) accordingly, it prints {field_1_val }

I am writing a program to get the json equivalent tag of struct fields using 
reflect.
My question is, is it safe to ignore the fieldList(comma separated struct 
fields in a single line) if there is a json tag with it?

--
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/1932cc53-b7b6-44d2-b855-1639e4c32ac0o%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/AM7P191MB1060D7B923A795E0455FE6B89E6A0%40AM7P191MB1060.EURP191.PROD.OUTLOOK.COM.


Re: [go-nuts] A modest format suggestion

2020-04-25 Thread Lutz Horn

Instead of this:

|
// Great is a really great function.
     func Great(
         anArg int,// This explains anArg
         anotherArg string,// This explains anotherArg
)(err error){
...
|

I'd think that this:

|
// Great is a really great function.
     func Great(
         anArg int,// This explains anArg
         anotherArg string,// This explains anotherArg
)(err error){
...


Two arguments why this is not needed and would encourage bad coding 
practice.


* If the names `anArg` and `anotherArg` don't reveal intention, they are 
bad names. It should be encouraged to change them to intention revealing 
names.


* The comment for the whole function should describe the meaning of the 
parameters, if necessary. This comment is shown by IDEs, comments on 
parameters are not. It should be encouraged to write complete function 
comments.


Lutz

--
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/038916a0-65c7-9038-9a9b-96f0d718c8a7%40lhorn.de.


Re: [go-nuts] Understind how to apply timeout using gouritine

2020-02-24 Thread Lutz Horn
> I've tried to adapt from from "Concurrency in Go by Katherine Cox-Buday" to 
> understand how to apply timeout. But I don't get it.

What are you trying to do? What is the expected behaviour, what happens instead?

BTW, this code does not compile, there are same unbalanced curly brackets.

Lutz

-- 
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/574339002.516005.1582535319399%40webmail.strato.de.


Re: [go-nuts] Why Discord is switching from Go to Rust

2020-02-07 Thread Lutz Horn
> "Remarkably, we had only put very basic thought into optimization as the Rust 
> version was written. Even with just basic optimization, Rust was able to 
> outperform the hyper hand-tuned Go version. This is a huge testament to how 
> easy it is to write efficient programs with Rust compared to the deep dive we 
> had to do with Go."

This article does not tell use when the switch from Go to Rust was made. But it 
is interesting to see that they compare the ancient Go version 1.9 with 
bleeding endge Rust. I am no expert for GC in Go but I would strongly assume 
that since Go 1.9 much has been improved to handle situations like those 
described in the article.

Lutz

-- 
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/2051487124.89895.1581080343939%40webmail.strato.com.


AW: [go-nuts] JSON: Having trouble parsing map keys with dots like {"foo.bar":"baz"}

2020-01-28 Thread Lutz Horn
Remove the blank in ``json: "baz.bar"` and make it `json:"baz.bar"`. This 
works: https://play.golang.com/p/i9SURYgGO66


Von: golang-nuts@googlegroups.com  im Auftrag von 
m...@markhansen.co.nz 
Gesendet: Dienstag, 28. Januar 2020 12:14
An: golang-nuts
Betreff: [go-nuts] JSON: Having trouble parsing map keys with dots like 
{"foo.bar":"baz"}

Hi folks, for background, I'm trying to read the Kaiterra 
API using encoding/json, which has JSON 
values like this:

{"id":"-0001-0001--7e57c0de","info.aqi":{"ts":"2018-03-26T08:53:20Z","data":{"pm10":120,"pm25":214}}}

I'm having trouble parsing the "info.aqi" field using encoding/json. I set the 
"info.aqi" field as a struct tag `json: "info.aqi"`, but the struct is just 
empty after parsing.

It seems more likely I'm holding it wrong, but I'm wondering if perhaps this is 
a bug in Go's JSON parsing?

I thought I'd make a minimal repro test, which fails:

package main

import (
"encoding/json"
"strings"
"testing"
)

type Foo struct {
BazBar string `json: "baz.bar"`
Quxstring `json: "qux"`
}

func TestDotKeyJsonParsing(t *testing.T) {
f := {}
d := json.NewDecoder(strings.NewReader(`{"baz.bar": "hello", "qux": "hi"}`))
err := d.Decode(f)
if err != nil {
t.Fatalf("json decoding failed: %v", err)
}
if f.Qux != "hi" {
t.Fatalf("Expected f.Qux to be hi")
}

if f.BazBar != "hello" {
t.Errorf("wanted: hello, got: %q", f.BazBar)
}
}

And the Qux field passes fine, but the BazBar field is not set, so the test 
fails there:
--- FAIL: TestDotKeyJsonParsing (0.00s)
/Users/mark/projects/godot/dot_test.go:26: wanted: hello, got: ""


--
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/539f857c-d96a-45af-9a74-c328753bd12d%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/AM7P191MB1060C7A5A59B82BF870605209E0A0%40AM7P191MB1060.EURP191.PROD.OUTLOOK.COM.


AW: [go-nuts] go modules and internal packages

2020-01-27 Thread Lutz Horn
Take a look at these blog articles:

https://blog.golang.org/using-go-modules
https://blog.golang.org/migrating-to-go-modules

Lutz


Von: golang-nuts@googlegroups.com  im Auftrag von 
R Srinivasan 
Gesendet: Dienstag, 28. Januar 2020 00:29
An: golang-nuts
Betreff: [go-nuts] go modules and internal packages

I have so far not migrated towards the new go modules. I am beginning the 
process. Looking for ideas.

I split my applications into indepe

--
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/fea9c93a-bb07-4f90-adcf-ebc5f6c71ae5%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/AM7P191MB1060BB65E859A41C446176D19E0A0%40AM7P191MB1060.EURP191.PROD.OUTLOOK.COM.


[go-nuts] AW: About go-playground

2020-01-21 Thread Lutz Horn
Note that `now := time.Now().Local()` on the playground always is `2009-11-10 
23:00:00 + UTCZ`. Your loop works correctly and ends with `[2009-11-09 
2009-11-16]`.

Try to run it locally and see.

Lutz


Von: golang-nuts@googlegroups.com  im Auftrag von 
Sahil Agrawal 
Gesendet: Mittwoch, 22. Januar 2020 06:18
An: golang-nuts@googlegroups.com
Betreff: [go-nuts] About go-playground

I tried to run a time script. But according to the code, it should return a 
very long list of date range. But it failed to do so. Can you please give me an 
explanation or some documentation which specifies that golang doesn't support 
time values (like it doesn't support for file handling operations.)

PFA file




Thanks and Regards,
Sahil Agrawal


--
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/AM5PR03MB3057DBC2104DF2379A7DF3E6FA0C0%40AM5PR03MB3057.eurprd03.prod.outlook.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/AM7P191MB106012BBA2C4414DBA3C10669E0C0%40AM7P191MB1060.EURP191.PROD.OUTLOOK.COM.


AW: [go-nuts] Sybase SQLAnywhere driver for Unix systems

2020-01-07 Thread Lutz Horn
If there is none listed on 
https://github.com/avelino/awesome-go#database-drivers or 
https://github.com/golang/go/wiki/SQLDrivers you are out of luck.

Lutz


Von: golang-nuts@googlegroups.com  im Auftrag von 
reda laanait 
Gesendet: Dienstag, 7. Januar 2020 09:09
An: golang-nuts@googlegroups.com
Betreff: [go-nuts] Sybase SQLAnywhere driver for Unix systems


Hello,

Is there a Golang driver for Sybase SQLAnywhere DB that works in a Unix system? 
I only find this, which works only on 
windows.

Otherwise, Is there any workaround to fix that e.g implementing a wrapper of 
another language driver?

Thanks
--
LAANAIT Ahmed Reda
--
Computer Engineer at
TamTam international

--
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/CAJg1kZP_68-XsdSXHzkSm2mOPuP%2BptLpihCsmcOtLJ734XyZcw%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/VI1PR06MB39338E22C3B4E190F8A8236F9E3F0%40VI1PR06MB3933.eurprd06.prod.outlook.com.


AW: [go-nuts] MarshalJSON() output encrypted json

2019-12-27 Thread Lutz Horn
The string

"my custom encryption stuff"

is not valid JSON. Why does your type implement MarshalJSON if it does not 
produce JSON?

Lutz

Von: Gert
Gesendet: ‎27.‎12.‎2019 07:55
An: golang-nuts
Betreff: [go-nuts] MarshalJSON() output encrypted json

https://play.golang.org/p/6qKkJhVsnU1

type Payload struct{}

func (p Payload) MarshalJSON() ([]byte, error) {
return []byte("my custom encryption stuf"), nil
}

func main() {
p := Payload{}
j, err := json.Marshal(p)
if err != nil {
fmt.Println(err)
}
fmt.Println(string(j))
}


json: error calling MarshalJSON for type main.Payload: invalid character 'm' 
looking for beginning of value


How do you skip the check from json.Marshal and just return the []byte directly 
whatever they are?

--
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/554c8ca8-2bca-4321-9ee5-0524e28422a3%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/VI1PR06MB393377ABE87F1AFED2D325379E2A0%40VI1PR06MB3933.eurprd06.prod.outlook.com.


AW: [go-nuts] Not able to connect with mysql database

2019-10-11 Thread Lutz Horn
Does the user 'root' have the permission to access the database on the MySQL 
server running on 'localhost'?

Note that this is not a Go problem but a MySQL problem. You should try to 
access the database using the mysql command line client berfore using it in an 
application.

Lutz


Von: golang-nuts@googlegroups.com  im Auftrag von 
Sarchcheelanbca Bala 
Gesendet: Freitag, 11. Oktober 2019 13:49
An: golang-nuts
Betreff: [go-nuts] Not able to connect with mysql database

Hi Team am not able to connect my go program with mysql. Getting the below 
error.

I have attached main.go file for your reference


2019/10/11 17:11:42 http: panic serving [::1]:59577: Error 1045: Access denied 
for user 'root'@'localhost' (using password: YES)
goroutine 74 [running]:
net/http.(*conn).serve.func1(0xc4ae60)
c:/go/src/net/http/server.go:1767 +0x140
panic(0x771740, 0xcce400)
c:/go/src/runtime/panic.go:679 +0x1c0
main.Index(0x8828a0, 0xc000284000, 0xcc0600)
c:/go/firstsql/main.go:36 +0x4e4
net/http.HandlerFunc.ServeHTTP(0x8192a0, 0x8828a0, 0xc000284000, 0xcc0600)
c:/go/src/net/http/server.go:2007 +0x4b
net/http.(*ServeMux).ServeHTTP(0xade820, 0x8828a0, 0xc000284000, 0xcc0600)
c:/go/src/net/http/server.go:2387 +0x1c4
net/http.serverHandler.ServeHTTP(0xc00015e000, 0x8828a0, 0xc000284000, 
0xcc0600)
c:/go/src/net/http/server.go:2802 +0xab
net/http.(*conn).serve(0xc4ae60, 0x883020, 0xc3c8c0)
c:/go/src/net/http/server.go:1890 +0x87c
created by net/http.(*Server).Serve
c:/go/src/net/http/server.go:2927 +0x395
2019/10/11 17:11:42 http: panic serving [::1]:59581: Error 1045: Access denied 
for user 'root'@'localhost' (using password: YES)
goroutine 31 [running]:
net/http.(*conn).serve.func1(0xc0001d43c0)
c:/go/src/net/http/server.go:1767 +0x140
panic(0x771740, 0xcc8280)
c:/go/src/runtime/panic.go:679 +0x1c0
main.Index(0x8828a0, 0xc0001dc1c0, 0xce2500)
c:/go/firstsql/main.go:36 +0x4e4
net/http.HandlerFunc.ServeHTTP(0x8192a0, 0x8828a0, 0xc0001dc1c0, 0xce2500)
c:/go/src/net/http/server.go:2007 +0x4b
net/http.(*ServeMux).ServeHTTP(0xade820, 0x8828a0, 0xc0001dc1c0, 0xce2500)
c:/go/src/net/http/server.go:2387 +0x1c4
net/http.serverHandler.ServeHTTP(0xc00015e000, 0x8828a0, 0xc0001dc1c0, 
0xce2500)
c:/go/src/net/http/server.go:2802 +0xab
net/http.(*conn).serve(0xc0001d43c0, 0x883020, 0xcec340)
c:/go/src/net/http/server.go:1890 +0x87c
created by net/http.(*Server).Serve
c:/go/src/net/http/server.go:2927 +0x39

--
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/c46a6b48-1109-4698-ac21-c7f04464b936%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/VI1PR06MB5150B886F882E95DF7B43B319E970%40VI1PR06MB5150.eurprd06.prod.outlook.com.


Re: [go-nuts] How to print arrays with commas and brackets

2019-10-09 Thread Lutz Horn
I tried to print array with brackets and commas in golang. I want to 
get

array like this.
["record1", "record2". "record3"]


Encode the array to JSON:

```
package main

import (
"encoding/json"
"fmt"
"log"
"os"
)

func main() {
strings := [3]string{"foo", "bar", "baz"}
stringsJson, err := json.Marshal(strings)
if err != nil {
log.Fatal("Cannot encode to JSON ", err)
}
fmt.Fprintf(os.Stdout, "%s", stringsJson)
}
```

Output:

["foo","bar","baz"]

Lutz

--
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/6939742d3ca8ea4240b700fdbf64b73f%40posteo.de.


Re: [go-nuts] Golang library for - ORM & Schema Migration

2019-09-28 Thread Lutz Horn

alex.besogo...@gmail.com:
But the main issue is that Go SQL interface SUCKS. It's verbose, hard to 
use and is difficult to integrate with additional tooling (try adding 
generic tracing support, I dare you!). So often your SQL code is hidden 
in reams of wrapper code that sets arguments and reads the results.


That's true. In the Java world, few people use the JDBC API directly, 
which has similar flaws. But this does not mean that JPA and Hibernate 
have to be used. Libraries like JDBI[1] exist that provide a much more 
usable API without the necessities of the ORM concept.


Ragarding the "migration" part of the question, in the Java world 
libraries like Flyway[2] allow fine grained control of schema migrations.


For both use cases similar libraires surely exist for Go. But maybe the 
question was about migrating ORM code and the DB schema together. I am 
not aware of any solution that does this.


Lutz

[1] http://jdbi.org/
[2] https://flywaydb.org/

--
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/0aab4dd2-374b-1915-b6f7-77089c42733f%40posteo.de.


Re: [go-nuts] Golang library for - ORM & Schema Migration

2019-09-27 Thread Lutz Horn
On Fri, Sep 27, 2019 at 05:34:28PM +0700, Dimas Prawira wrote:
> Many Gophers don't like ORM as :

Just to emphasize this point:

https://korban.net/posts/postgres/2017-11-02-the-case-against-orms/

Lutz

-- 
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/20190927120547.GA4127%40pc-lutz.ecm4u.intra.


Re: [go-nuts] Basic Data structures and Algorithms with Go

2019-02-11 Thread Lutz Horn
The first chapter of my book from packt  is available on 
golangweekly. Book Title: "Basic  Data structures and Algorithms with

Go".


Some quick observations:

The code indention of many code snippets is broken. Example:
https://i.postimg.cc/6QFyMVjr/twic-Value.png

The terminal windows are *huge* and contain almost nothing. Example:
https://i.postimg.cc/dQ5KvQFX/term.png

A paragraph like this on page 2 does not help at all.


In the next code snippet, the Range keyword is explained in detail.
The Range keyword can be used to access index and value for each
element


Nothing is "explained" about `range` in the following code snippet.

Does Packt Publishing have an editor who makes sure quality standards 
are adhered to? Or can anybody just publish anything?


The recommended book about Go is still http://www.gopl.io/

Lutz

--
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] Help- Empty request header and body

2019-02-11 Thread Lutz Horn

Am new in golang and am trying to write an API but my request header and
body is always empty.


Well, that's a *lot* of code. Please trim it so it forms a SSCCE 
(http://www.sscce.org/).


Lutz


--
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] Enumerate query result fields using "github.com/go-ole/go-ole/oleutil"

2019-02-11 Thread Lutz Horn

Any ideas on how I can get a list of fields (not values) after executing
something like this?


Try these:

* https://golang.org/pkg/database/sql/#Rows.Columns
* https://golang.org/pkg/database/sql/#Rows.ColumnTypes

These methods give you information about the columns of a sql.Row.

Lutz


--
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] database/sql: NextResultSet API always return false

2019-02-01 Thread Lutz Horn

So your example may be unexpected behavior (or bug) of lib/pq.

Please file an issue report on lib/pq.


Done: https://github.com/lib/pq/issues/828

Lutz



--
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] database/sql: NextResultSet API always return false

2019-02-01 Thread Lutz Horn

After reading Lutz's sample code.  I found lib/pq has different semantics.
I'm not sure which is the right semantics, intended by database/sql APIs.


That's interesting!

Does the code of NextResultSet from sql.go shed any light on this?

https://golang.org/src/database/sql/sql.go?s=76505:76541#L2684

Lutz


--
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] database/sql: NextResultSet API always return false

2019-01-31 Thread Lutz Horn

Then why this method is not works as expected using
github.com/go-sql-driver/mysql for MySQL.


It would have helped me if you'd have mentioned MySQL in your question. 
Your question was incomplete. Please take alook at


http://www.catb.org/esr/faqs/smart-questions.html


Take a look at this: https://play.golang.org/p/tCLKxiXPZ5e


I can reproduce this problem for MySQL. Sadly I don't find any issue 
about NextResultSet always returning false:


https://github.com/go-sql-driver/mysql/search?q=NextResultSet=Issues

Lutz

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


Re: [go-nuts] How to do for inserting input data(http request post method) into postgresql database

2019-01-31 Thread Lutz Horn
I used  net/http package to build up the http server with golang. 
Also,I make the simple Html page for front end . But I don't know how

to do for inserting input data(http request post method) into
postgresql database ? Any one could provide the sample code ?


This may not be the best Go code ever written but it does what you ask 
for: read a HTTP POST request body and write it into a PostgreSQL database:


Handle the HTTP POST request JSON body:

https://github.com/lutzhorn/shortenyoururl-go/blob/ece65aa0bc7b4bbd12d4b3daf039e762b16728f9/handler.go#L135

Insert the scanned body into the database:

https://github.com/lutzhorn/shortenyoururl-go/blob/ece65aa0bc7b4bbd12d4b3daf039e762b16728f9/handler.go#L179

https://github.com/lutzhorn/shortenyoururl-go/blob/ece65aa0bc7b4bbd12d4b3daf039e762b16728f9/db.go#L95

Regards

Lutz

--
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] database/sql: NextResultSet API always return false

2019-01-31 Thread Lutz Horn

Hi,


I just want to know in which case NextResultSet
 return true?


This method works as expected using github.com/lib/pq for PostgreSQL. 
Take a lookt at this:


https://gist.github.com/lutzhorn/1aa7de538d1edd0b3904799b5bb972fd

The output is:

{'\x01' "cmelling0"}
{'\x02' "mbarkess1"}
{'\x03' "ssquibb2"}
{'\x04' "akirk3"}
{'\x05' "kelcomb4"}
{'\x06' "lcoldbathe5"}
{'\a' "ibutcher6"}
{'\b' "wdarnbrook7"}
{'\t' "bcoraini8"}
{'\n' "wplews9"}


Lutz

--
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] Some problem I heard in my class: there are n chess players and they play with all others 1 game and no more than 1 game per day.

2019-01-26 Thread Lutz Horn
Hi Anca,

Am 26.01.19 um 09:27 schrieb Anca Emanuel:
> How do you make an planing for that event ?
> 
> Here is my 
> implementation: 
> https://github.com/ancaemanuel/comb/blob/master/chess_tournament.go
> 
> This was not an easy problem. After some years of thinking an pencil work I 
> have an optimal solution.

Some remarks:

* Your code needs some comments that explain why it does what it does.
* The names you choose (n, d, i, j, k) don't tell us anything about
their meaning. Use intention revealing names.
* Did you try to write some test
(https://golang.org/doc/code.html#Testing) for your code? How do you
know it is correct without them?

Lutz


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


AW: [go-nuts] How to change the GBK with golang default charset?

2018-05-03 Thread Lutz Horn
What do you mean by "change the GBK"? Do you want to use GBK? For what: input, 
output?

Lutz

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


AW: [go-nuts] Go could really use a while statement

2018-05-02 Thread Lutz Horn
> No, I meant a while  { ... } loop

for foo > 1 {
}

is exactly what you are looking for. You can even write

for true {
}

to get an infinite loop you will have to break from.

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


AW: [go-nuts] Licensing terms when using Go code

2018-05-02 Thread Lutz Horn
Go is BSD licensed (https://golang.org/LICENSE). This is an easy license:

> Copyright (c) 2009 The Go Authors. All rights reserved.
>
> Redistribution and use in source and binary forms, with or without
> modification, are permitted provided that the following conditions are met:
>
> * Redistributions of source code must retain the above copyright notice, this 
> list of conditions and the following disclaimer.

So you must retain the copyright notice ("Copyright (c) 2009 The Go Authors.") 
and the disclaimer. You can then license your code any way you like.

Lutz

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


AW: [go-nuts] Question about int inside json

2018-04-29 Thread Lutz Horn
Use `int64` instad of `int`.

https://play.golang.com/p/j10cDz7z-N0


Von: golang-nuts@googlegroups.com  im Auftrag von 
pick...@kamelos.org 
Gesendet: Samstag, 28. April 2018 20:04
An: golang-nuts
Betreff: [go-nuts] Question about int inside json


Hallo all,

I've a "stupid" question about the type "int" when used inside json.
Almost every documentation I've found says int is 32 bit long, so that I expect 
a range from -2.147.483.648 to 2.147.483.647.



So I "mistakely" did that:

type Comment struct {
 IDint   `json:"id"`
 URL   string`json:"url"`
 Comment   string`json:"comment"`
 Html  string`json:"html"`
 Name  string`json:"name"`
 Timestamp time.Time `json:"timestamp"`
 Parentint   `json:"parent"`
}



then some code, where c is *Comment, and..


t := time.Now()
c.ID = int(t.UnixNano() / 100)


but, when I wrote c.ID into a JSON file, it resulted in:

1524937580003

which is correct, but cannot fit in 32 bits.

The version I'm using is
go version go1.9.4 linux/amd64


is it a bug of this specific version, or is something I didn't got about int 
inside struct json structs, like c.ID?

many thanks

Milo










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

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


Re: [go-nuts] Update golang version

2018-03-25 Thread Lutz Horn
> How to update golang version to 1.10 via windows 10?

Download the installer from
https://dl.google.com/go/go1.10.windows-amd64.msi and execute it. It
will discover the existing version and upgrade it.

Lutz

-- 
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] Known unknown escape sequence in Go

2018-03-23 Thread Lutz Horn
> I'm trying with simple Perl character class regular expression, which 
> should be supported by Go (link) 
[...]
> and I found that `*\w*` or `*\S*` Perl character class are not supported. 

You must escape the backslash as '\\w' etc:

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

Lutz

-- 
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] The result of yaml.Unmarshal() is different between osX and linux

2018-03-16 Thread Lutz Horn
package main import ( "fmt" "io/ioutil" "os" yaml "gopkg.in/yaml.v2" ) 
type

[...]

This is hard to read. Please post your code with proper line breaks.

Lutz

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


Re: [go-nuts] How to integrate ckeditor and ckfinder for golang website ?

2018-03-08 Thread Lutz Horn

I'm designing a golang website, You need to integrate ckeditor and
ckfinder for your website. Thank you very much.


Do you mean the tools provided by https://ckeditor.com/?

You integrate them into your web site by following the documentation of 
these products:


* https://docs.ckeditor.com/ckeditor4/latest/
* https://docs.ckeditor.com/ckfinder/latest/

This is not related to Go.

Lutz

--
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] General question: complex search form and query params

2018-03-02 Thread Lutz Horn

Nowadays I suppose
best way to do something like this is using GraphQL (for ex.
https://github.com/graphql-go/graphql).


But GraphQL != SQL. Building SQL from HTTP query parameters is not made 
more simple and secure by building GraphQL from HTTP query parameters.


Lutz

--
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] interface question

2018-03-02 Thread Lutz Horn

How can i get a list about which interface is implemented by this
struct methods?  (Because in Go there is no explicit interface
declaration.)


os.Open returns an os.File (https://golang.org/pkg/os/#Open).

os.File (https://golang.org/pkg/os/#File) has functions and methods 
listed in the index of os (https://golang.org/pkg/os/#pkg-index).


Lutz

--
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 misfeature?

2017-10-25 Thread Lutz Horn

This prints "foo=2" which surprised me because I was unaware that T1
had got another foo via T3 (with less composition depth).

If I put T4 directly into T1, Go would detect the ambiguity of t1.foo
(because the composition depth is the same).


There is no ambiguity because `T4.foo` is not promoted to a field of 
`T1`. `T4.foo` *is* a promoted field of `T2` but promotion is not 
transitive.


see https://play.golang.org/p/GFgJGTSGGd

Read about this on:

*  https://golang.org/ref/spec#Struct_types
* https://golang.org/ref/spec#Selectors

Lutz

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


Re: [go-nuts] Why isn't golang input and output is buffered?

2017-08-30 Thread Lutz Horn
For those types of problems where i need to take large amounts of input, 
It's taking long time to just take input than to do processing.


Can you provide example code for how you read the input?

Lutz

--
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] Upload File Size Limit in Go 1.9

2017-08-30 Thread Lutz Horn
Limiting is done by the form parse: 
https://golang.org/pkg/net/http/#Request.ParseMultipartForm


No, this is not limiting:


The whole request body is parsed and up to a total of maxMemory bytes
of its file parts are stored in memory, with the remainder stored on
disk in temporary files. ParseMultipartForm calls ParseForm if
necessary.


This is just offloading to disk. The whole request including all 
complete body parts is still parsed and available.


Unless the OP tells us what kind of limiting he has in mind, it is hard 
to give advice.


Lutz

--
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] Upload File Size Limit in Go 1.9

2017-08-30 Thread Lutz Horn

Am 29.08.2017 um 21:40 schrieb Andrew:
Go 1.9 has "The new |FileHeader.Size| 
 field describes 
the size of a file in a multipart message."


Suppose I upload multiple files using *multiple*>


Can I use FileHeader.Size to limit *each* uploaded file size? Or there's 
other ways?


As far as I understand this field, it does not limit anything. It is a 
RO property of the multipart.FileHeader. If your request has multiple 
parts, there will be a multipart.FileHeader for each. You don't set 
them, you read them.


What is it you are trying to do?

Lutz

--
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 url shortener service

2017-08-24 Thread Lutz Horn

Hi,

Am 23.08.2017 um 23:12 schrieb doug...@cornershopapp.com:
i have created a simple url shortener service, for practice and learn 
with go, what do you think !


https://github.com/douglasmakey/ursho


It looks like implementing an URL shortener is a natural choice for 
wetting your toes with Go. I've done something very similar: 
https://github.com/lutzhorn/shorturl


My project adds a simple web GUI, uses http://hashids.org/ instead of DB 
row IDs, and sends an email about a newly inserted URL.


Your project has a nice structure. Especially separation of into 
packages and the use of `base.go` are good ideas. Creating the table 
from code makes deployment easier.


Did you think about using DB transactions, for example in `Load`?

Lutz

--
Lassen Sie uns unsere E-Mails verschlüsseln! So geht's:
https://emailselfdefense.fsf.org/de/
Meinen öffentlichen Schlüssel finden Sie hier:
https://www.lhorn.de/0xC52DFC3A.asc

--
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 newline escaping

2017-08-15 Thread Lutz Horn
Hi,

Am 15.08.17 um 08:31 schrieb patrickjtray...@gmail.com:
> I simply want the XML files my program outputs to not have newline
> characters escaped into . My input XML files contain newlines and I
> want to preserve them.

The  is the XML entity for LF. This is correct XML which contains
exactly what you put into it:

line 1line 2

Any XML parser will be able to handle the LF. For example, xmllint does:

> $ xmllint -format content.xml
> 
> 
>   line 1
> line 2
> 

So there is no but that needs to be fixed.
xml.NewEncoder(os.Stdout).Encode() works as expected and produces output
that is valid.

Lutz

-- 
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] A humble request/challenge

2017-08-09 Thread Lutz Horn

Hi Jabari,

Am 08.08.2017 22:18 schrieb Jabari Zakiya:

Here's a link to read and download the paper:


Was your paper published in some scientific journal?

You've asked similar questions already[0]. How may replies did you get 
so far? Did anybody implement your algorithm in any other language you 
don't master yourself?


Besides, as having a degree in Mathematics: can you provide a proof that 
a) your algorithm is correct, and b) what runtime complexity it has?


Regards

Lutz

[0] https://u.lhorn.de/ma9g

--
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] Using bash to source a python environment

2017-06-16 Thread Lutz Horn

Hi,

cmd := exec.Command("/bin/sh", "-c", ". /path to python 
environment/bin/activate")

but actually yhe environment is not activated


How do you check this? What do you want to do *after* this call to 
exec.Command?


Lutz

--
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] CoC WG members from outside the USA?

2017-06-16 Thread Lutz Horn

Hi,

https://github.com/golang/proposal/blob/master/design/13073-code-of-conduct.md#open-issues 
says:


The Working Group does not yet include anyone from Asia, Europe, or 
Africa. In particular, Europe and China are home to a large swath of Go 
users, so it would be valuable to include some people from those areas 
in the working group.


Looking at https://golang.org/conduct#reporting I wonder if this 
situation has changed. Is anybody listed there from Asia, Europe, or 
Africa? If not, what is done to make the CoC and discussion about it an 
issue not only for people in the USA?


Regards

Lutz

--
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] goxpath: An XPath 1.0 parser

2017-06-14 Thread Lutz Horn

Hi,

Am 14.06.2017 15:57 schrieb seamus via golang-nuts:

Yes referring to https://github.com/ChrisTrenkamp/goxpath
...
You would be Chris Trenkamp.


Then you will probably get better answers if you open an issue on this 
GitHub project. The people here on go-nuts did not write this library 
nor can they tell you what the current status of it is.


Regards

Lutz

--
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] goxpath: An XPath 1.0 parser

2017-06-14 Thread Lutz Horn

Hi,


I've been doing some work on goxpath to use it to evaluate xpath
expressions used in YANG. One issue I just hit is the XSLT current()
function is used in the YANG files, this fails to evaluate as
current() isn't included in the implementation. Did you consider it at
all ?


* Are you talking about https://github.com/ChrisTrenkamp/goxpath?
* What is YANG?
* Whom do you address as "you"?

Regards

Lutz

--
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] Create methods for structs at runtime

2017-06-14 Thread Lutz Horn

Hi,


Given an interface, how can I create a struct instance with the
methods of the interface at runtime?


What is your usecase for this? What problem are you trying to solve?

Lutz

--
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] beginner seeks peer review

2017-05-17 Thread Lutz Horn

Hi,

the more I work with Go the more I like it. Reading code written by 
other people, even by beginners, is straight forward.



https://github.com/kbfastcat/nrmetrics


go_vet and the misspell check found some minor issues:

https://goreportcard.com/report/github.com/kbfastcat/nrmetrics

My observations:

--

In the lines

https://github.com/kbfastcat/nrmetrics/blob/master/nrpost/nrpost.go#L19

https://github.com/kbfastcat/nrmetrics/blob/master/nrpost/nrpost.go#L30

https://github.com/kbfastcat/nrmetrics/blob/master/redis-agent/config.go#L27

https://github.com/kbfastcat/nrmetrics/blob/master/redis-agent/config.go#L33

I would

  return nil, err

instead of an unused first item.

--

Why don't you export metric on

https://github.com/kbfastcat/nrmetrics/blob/master/redis-agent/getstats.go#L38

when you do export the other types?

--

Could you write tests for parseInt64 and parseFloat64 that actually have 
multiple lines as the info argument? The slice you get at


https://github.com/kbfastcat/nrmetrics/blob/master/redis-agent/getstats.go#L127

only contains one element in your tests.

--

The names parseInt64 and parseFloat64 are a little misleading. I would 
expect them to only accept on string argument that contains an int64 or 
a float64 plus some to be ignored characters. But your functions look 
for the marker given as the s argument and then get the number right of 
the colon.


Maybe names that better tell the reader what the functions are doing 
could be chosen.


--

The help strings of the two flags at

https://github.com/kbfastcat/nrmetrics/blob/master/redis-agent/redis-agent.go#L21

just duplicate the flag names in a unhelpful way. You should describe 
the meaning of the flags.


--

I am sure others here can give you more helpful advice. But this what I, 
a beginner like you, find from reading your code.


Lutz


--
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: Feedback welcome: "Shorten your URL"

2017-05-02 Thread Lutz Horn

Hi,


To serve static files,
you can use one of the many pre defined go http handlers,

  fs := http.FileServer(http.Dir("static"))
  http.Handle("/", fs)

found this article, among many others,
http://www.alexedwards.net/blog/serving-static-sites-with-go


Yes, that's a good point. Reading the bytes every time is not a good 
idea.



I suspect this code here
https://github.com/lutzhorn/shorturl/blob/master/db.go#L34
might be optimized to avoid cpu consumption.

If you d flood that url, that would trigger as many heavy computations 
as

req,
so all reqs will be impacted by the slow cpu,
including those not doing this computation (and that is where is the 
pb).


You might put that computation into a limited worker pool
to slow down only that url and not impact all the server.


Compuation of a a new hashid should only happen on a POST request inside 
NewURL. The newHashID is not named very good, it does not to the 
computation, it constructs an object that is then later used to make the 
actual computation. But I will keep an eye on this.



https://github.com/lutzhorn/shorturl/blob/master/db.go#L74
you might try something like this to avoid repeating the rollback on 
error,

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


That looks interessting.

Thanks!

Lutz

--
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: Feedback welcome: "Shorten your URL"

2017-05-02 Thread Lutz Horn

Hi Val,


I'll go with 2 remarks and leave other concerns to other reviewers :
- using ioutil.ReadFile to serve some static html isn't the most 
idiomatic.

Have a look at html/template .


I had a vague feeling that this should be easier :) Thanks, I'll take a 
look at html/template.



- why write
func(handler *Handler) {
handler.Index(w, req)
}(handler)

instead of
handler.Index(w, req)   ?

Is there an expected benefit that I'm not seeing?


You are right, there is no benefit in wrapping this method call into an 
anonymous function. Changing the handler registration will be much 
shorter without it.


Thanks!

Lutz


--
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] Feedback welcome: "Shorten your URL"

2017-05-02 Thread Lutz Horn

Hi Go Nuts,

to practice my Go skills, I've implemented a simple web application that 
allows you to shorten an URL. The application consists of a backend 
written in Go and a web frontend using jQuery with some plugins and 
Bootstrap for layout.


The code is available on GitHub at https://github.com/lutzhorn/shorturl, 
the application is deployed on https://u.lhorn.de.


I would very much appreciate any feedback you can give especially on the 
Go part. Coming from a Java and Python background, I'm trying to get 
into the Go way of programming, In Python there is a 'Pythonic' way to 
write code, I am sure there is something similar in Go: File structure, 
name choice, exporting names, error handling, ...


If you have a little time, please tak a look at the code, play with the 
deployed application, and please give me feedback.


Thanks!

Lutz


--
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] master to slave communication - design suggestions

2017-04-26 Thread Lutz Horn
> I am working on building a distributed system where a bunch of
> workers (can scale to few thousands) are connected to a manager.
> Workers send certain local events to the manager and the manager then
> should broadcast that event to all other workers. Workers shouldn't
> miss any event (for reasons like network issue, or they are rebooting
> etc.).  For now the master high availability is not a serious
> requirement. But would prefer a design that doesn't over complicate
> things when master HA has to be added. master and slaves are fully go
> code and unlikely to change.

Did you consider a system like RabbitMQ[0] as the messaging layer? It
supports all the features you describe including dynamic joining/leaving
of clients.

Client libraries for many languages exist[1], including Go[2].

Regards

Lutz

[0] https://www.rabbitmq.com/
[1] https://www.rabbitmq.com/devtools.html
[2] https://github.com/streadway/amqp

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