Re: [go-nuts] Executing JAR from Go

2024-04-16 Thread Roland Müller
That my point too.

Am Dienstag, 16. April 2024 schrieb Kurtis Rader :
> On Mon, Apr 15, 2024 at 10:34 PM Roland Müller  wrote:
>>
>> The class should be written as org.Sign instead of org/Sign.
>
> Agreed. My point was that the O.P. wrote "org/Sign" in their Go source
code and didn't show us the command they ran interactively. There may be
multiple problems with the O.P.'s Go code. But until they tell us what
command they successfully ran at an interactive shell we can only guess at
what is wrong with their Go source code.
> --
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank

-- 
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/CA%2B8p0G0ZLh%3DYL_SZKOq%2BNUQB3nTBOnR97hNrsK7N0URCNrrkXQ%40mail.gmail.com.


Re: [go-nuts] Executing JAR from Go

2024-04-15 Thread Roland Müller
The class should be written as org.Sign instead of org/Sign.

Am Dienstag, 16. April 2024 schrieb Kurtis Rader :
> On Mon, Apr 15, 2024 at 4:02 AM Shivli Srivastava 
wrote:
>>
>> When I run the command on my terminal , everything works as fine but
running it using exec.Command gives Error: Could not find or load main
class org.Sign
>> Caused by: java.lang.ClassNotFoundException: org.Sign .
>
> Show us the command you ran interactively. Was it literally the following
(since that is what your Go code runs):
> java -cp
/Users/shivli.srivastava/Downloads/jars/bcmail-jdk15on-159.jar:/Users/shivli.srivastava/Downloads/jars/bcpkix-jdk15on-155.jar:/Users/shivli.srivastava/Downloads/jars/bcprov-jdk15on-155.jar:/Users/shivli.srivastava/Downloads/jars/xml-apis-1.4.01.jar:/Users/shivli.srivastava/Downloads/jars/xercesImpl-2.12.2.jar:DigitalSign.jar
org/Sign
> If you copy/paste the above command into your interactive shell what
happens?
> --
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>
> --
> 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/CABx2%3DD9T7tZhc2s0P%2Bz6c9xCn2%3DnFiGKykVq0i4-%2Bg9C_xS7vQ%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/CA%2B8p0G2a43ycJC0NqOuv-VzbnD5UnMLPX0JA9Q8ezJPBZo%2BbPw%40mail.gmail.com.


Re: [go-nuts] the environment variable GOROOT doesn't load for work with go

2023-10-06 Thread Roland Müller

Hello,

the path of the go.exe binary is quite suspicious. C:\Windows is the 
windows system folder and system32 - as far as I know - contains some 
partly legacy stuff.


Valid locatios for programs are "C:\Program Files" or "C:\Program 
Files(32)" (out of my memory - since I am sitting in front of a Linux 
box @moment)


To what locations do your GOROOT and GOPATH put?

BR,

Roland

On 10/6/23 18:05, Dorian ROSSE wrote:

hello,


*the environment variable GOROOT doesn't load* for work with go so i 
can't use any go thus the environment set and put in 
_c:/windows/system32/go/bin/go.exe_/ doesn't work,/


/_thanks you in advance to brig to myself the fully using of my 
variable envirnments GOROOT and GOPATH,_/

/_
_/
regards.


Dorian ROSSE.
--
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/ca6c5b7a-b4c8-46cf-b955-f51bceb746a6n%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/bf68319f-b104-3c97-57c2-9c97fd4ac1b3%40gmail.com.


Re: [go-nuts] Offline version of A Tour of Go

2023-09-26 Thread Roland Müller
The tour can be locally installed.

https://pkg.go.dev/golang.org/x/website/tour#section-readme

go get golang.org/x/tour

In the tour/ directory
go run .

Then local Tour of Go is here:
http://localhost:3999/

Am Dienstag, 26. September 2023 schrieb 王富民awaw :
> Hi Friends of Go
> Is there an offline version of A Tour of Go?
> Could be in PDF or Powerpoint or preferably Go's beautiful present format.
> A quick Google search didn't reveal anything relevant.
> 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.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/65d30564-2fb2-4f1f-9bc3-bfdd159b2febn%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/CA%2B8p0G2C3QYbmzfmN%2BGwwpXfZem8OzbjSNe4SyeB5pONt8pM7g%40mail.gmail.com.


Re: [go-nuts] Re: Why doesn't the database/sql package in Go support using placeholders "?" to replace the database name and username in SQL statements?

2023-09-20 Thread Roland Müller
Even standard SQL does not support using bind variables for everything that
uses SQL syntax and does not belong to DML (=data manipulation language)

Am Montag, 18. September 2023 schrieb Vladimir Varankin :
> A thing, that it may be valuable to explain further, is that Go's
"database/sql" doesn't come with a built-in query builder.
> The package implements the database connection pooling/management, but it
passes the user's SQL input and its arguments to the "driver". Depending on
the particular database kind, the driver may or may not try to interpret
the query (and the args), before it passes them to the database server.
> In the specific example of MySQL/MariaDB, the support for placeholder "?"
is a part of this database's flavour of SQL. Thus, it's likely, the driver
you're using, passes the query with a placeholder to the DB server, but the
DB's support of placeholders is limited to only a subset of queries (or
places inside a query) — as the link to SO's answer, shared previously,
explained.
> Hope this makes it a little bit more clear.
> On Sunday, September 17, 2023 at 10:45:27 AM UTC+2 Brian Candler wrote:
>>
>> According to this SO answer, CREATE USER in mysql doesn't support
placeholders:
>>
https://stackoverflow.com/questions/20647115/how-to-write-create-user-with-mysql-prepared-statement
>> "+1 for a legitmiate use of QUOTE() which is really the sanest thing
that can be done here, since CREATE USER doesn't support ? placeholders"
>> You can test this by trying a simple DML statement, e.g.
>> UPDATE users SET name=? where name=?
>>
>> On Sunday, 17 September 2023 at 01:02:08 UTC+1 John Zh wrote:
>>>
>>> Hi !
>>> I am going to make some kind of manager app over MySQL clusters by
using Golang. But I found that when I try to exec some SQL line includes
user name or db name, the SQL line can't be correctly parameterized.
>>> For example:
>>> Using GORM based on database/sql or directly using database/sql
>>> ```
>>> err := db.Exec("CREATE USER ? IDENTIFIED BY ?", a.Name, a.Pwd).Error
>>> ```
>>> Got
>>> ```
>>> [1.824ms] [rows:0] CREATE USER 'Reiis' IDENTIFIED BY '12345'
>>> Error 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right syntax
to use near '? IDENTIFIED BY ?' at line 1
>>> ```
>>> Seems like it does not replace "?" with a.Name, but rather passes the
SQL command with "?" directly to MySQL.  What is more wired, it prints the
SQL command with correctly replaced parameters in the log.
>>> I don't know the the underlying reason behind this phenomenon, is it
intentionally designed like that?
>>> 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.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/1cc07940-48c3-4d53-b97e-d74faa4c76can%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/CA%2B8p0G2hRP4mwa2nP%2BzsGqnc_%2BiPv3vcTpk9gJaqrctWgKVzsg%40mail.gmail.com.


Re: [go-nuts] Export fs.FS as FUSE fs

2023-06-29 Thread Roland Müller
Hello,
I am struggling to understand the purpose of extension.
FS is an interface to access file systems from go code. Is your new
extension acting as a handler and allows to expose any Go FS to be mounted
and acessed at operating system level?

https://en.m.wikipedia.org/wiki/Filesystem_in_Userspace#/media/File%3AFUSE_structure.svg

Br/Üdvözlettel
Roland

Am Samstag, 24. Juni 2023 schrieb Tamás Gulácsi :
> Ok, I've put some hours into it, and implemented it:
https://pkg.go.dev/github.com/tgulacsi/go@v0.25.0/fsfuse
> It uses github.com/jacobsa/fuse to export a mountable io/fs.FS.
> I've only tested with os.DirFS, with that, it works as expected.
> I'd love to get some feedback - if anynone interested, I can export it to
some more direct/slimmer repo.
> Tanás Gulácsi
>
> Tamás Gulácsi a következőt írta (2023. június 23., péntek, 8:08:32 UTC+2):
>>
>> Hi,
>> Does anyone know an existing solution for exporting an fs.FS as a FUSE
filesystem?
>> As fs.FS is standard now, this would open several new possibilities,
>> as a lot of interesting fs.FS implementations exist (zip, tar, DB,
embedded, union ),
>> and this one little glue code could export them all!
>> Thanks in advance,
>> Tamás
>
> --
> 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/f8edf7e1-a864-4ab0-b7e6-773246485da1n%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/CA%2B8p0G2Suf%2B_Jv20aOTdb%2Bv8ezT5_g4xGa5FvR-a%3DpcnPzodYw%40mail.gmail.com.


Re: [go-nuts] Variable Declaration inside infinite loop

2023-01-26 Thread Roland Müller
Am Mittwoch, 25. Januar 2023 schrieb 'Jakob Borg' via golang-nuts <
golang-nuts@googlegroups.com>:
> On 25 Jan 2023, at 12:26, Shashwat  wrote:
>>
>> Is it safe to declare a variable inside an infinite loop ?
>>
>> for {
>> a := 0
>> a += 1
>> }
>>
>> Won't this cause memory allocation in every iteration ?
>>
>> As the declared variables will be allocated memory in the stack and not
heap memory, so garbage collector can't clear the allocated memory, and
eventually process will be terminated, isn't it?
>
> No. Apart from compiler optimisations, consider that the variable goes
out of scope at the end of each iteration.
>

In Java this may cause memory fragmentation when the amount of allocated
memory varies and the variables use much memory.

Dont know whether this may occur in Go too.

- Roland

> //jb
>
> --
> 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/CE4EFF63-BD16-46F8-96EF-69000F7D9ACD%40kastelo.net
.
>

-- 
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/CA%2B8p0G3nxAxWu0cNAJR_FWYQWvPdJHSP9v5X6VLhWFdh%2BxxenQ%40mail.gmail.com.


Re: [go-nuts] Occasional hard lockup w/ 100% CPU usage in go applications

2022-11-01 Thread Roland Müller
Hello,

Am Dienstag, 1. November 2022 schrieb Robert Engels :
> Also, enabling and generating core dumps is somewhat OS version specific
- even between Linux versions - so you probably need to check your docs.
>

dumping core files is a kernel feature, but I think most Linux distros have
it disabled nowadays.

To allow unlimited core files enter following command as root:
# ulimit -c unlimited

BR,
Roland

> On Nov 1, 2022, at 11:14 AM, Robert Engels  wrote:
>
> 
> Are you certain you aren’t integrating with some C library that is
interfering with the default signal handling?
>
> On Nov 1, 2022, at 11:12 AM, Steven Sokol  wrote:
>
> Yep, I need to figure out how to generate a core dump. I've tried all
the usual methods without success. Any suggestions for alternate methods
would be greatly appreciated.
> When the process is killed (SIGKILL) the system does return to its normal
load. (Under production conditions systemd immediately restarts it.)
>
> On Tuesday, November 1, 2022 at 10:38:12 AM UTC-5 ren...@ix.netcom.com
wrote:
>>
>> Perf doesn’t help. Perf only shows a sampling over time (eg where the
cpu has spent) and as you see in the logs it doesn’t work for pre-existing
threads.
>> You need to figure out how to generate a core dump.
>> When you go process dies does the system function as normal?
>>
>> On Oct 31, 2022, at 11:52 AM, Steven Sokol  wrote:
>>
>> Ok, here's what perf shows:
>>
>> root@pi4cm1(rw):/# perf record -a -g sleep 5
>> Reading /proc/4199/task/4199/maps time out. You may want to increase the
time limit by --proc-map-timeout
>> [ perf record: Woken up 8 times to write data ]
>> Warning:
>> 1 map information files for pre-existing threads were
>> not processed, if there are samples for addresses they
>> will not be resolved, you may find out which are these
>> threads by running with -v and redirecting the output
>> to a file.
>> The time limit to process proc map is too short?
>> Increase it by --proc-map-timeout
>> [ perf record: Captured and wrote 6.510 MB perf.data (80088 samples) ]
>>
>>
>>
>>┌─Warning:─┐
>>│1 map information files for pre-existing threads were │
>>│not processed, if there are samples for addresses they│
>>│will not be resolved, you may find out which are these│
>>│threads by running with -v and redirecting the output │
>>│to a file.│
>>│The time limit to process proc map is too short?  │
>>│Increase it by --proc-map-timeout │
>>│  │
>>│  │
>>│Press any key...  │
>>└──┘
>>
>>
>>
>> Samples: 80K of event 'cpu-clock:pppH', Event count (approx.):
2002200
>>   Children  Self  Command  Shared Object Symbol
>> +   41.96% 0.00%  fvUnisocket  [vectors] [.]
0x0fc0
>> +   41.65%41.65%  fvUnisocket  [vectors] [.]
0x0fc0
>> +   30.14%29.94%  fvUnisocket  fvUnisocket   [.]
kernelcas
>> +5.05% 0.00%  fvUnisocket  [vectors] [.]
0x0fa0
>> +5.04% 5.01%  fvUnisocket  fvUnisocket   [.]
runtime/internal/atomic.Cas
>> +5.01% 5.01%  fvUnisocket  [vectors] [.]
0x0fa0
>> +4.56% 4.53%  fvUnisocket  fvUnisocket   [.]
runtime/internal/atomic.goLoad64
>> +2.97% 0.00%  fvUnisocket  [vectors] [.]
0x0fd8
>> +2.95% 2.95%  fvUnisocket  [vectors] [.]
0x0fd8
>> +2.52% 0.00%  fvUnisocket  [vectors] [.]
0x0fcc
>> +2.50% 2.50%  fvUnisocket  [vectors] [.]
0x0fcc
>> +2.26% 0.00%  swapper  [kernel.kallsyms] [k]
cpu_startup_entry
>> +2.25% 0.00%  swapper  [kernel.kallsyms] [k]
do_idle
>> +2.12% 0.00%  swapper  [kernel.kallsyms] [k]
default_idle_call
>> +2.09% 2.09%  swapper  [kernel.kallsyms] [k]
arch_cpu_idle
>> +1.74% 0.00%  swapper  [unknown] [k]
0x002018ac
>> +1.74% 0.00%  swapper  [kernel.kallsyms] [k]
secondary_start_kernel
>> +1.48% 1.47%  fvUnisocket  fvUnisocket   [.] cas
>> +1.19% 1.19%  fvUnisocket  fvUnisocket   [.]
runtime/internal/atomic.goStore64
>>  0.96% 0.95%  dump1090 dump1090  [.]
convert_uc8_nodc_nopower
>> +0.65% 0.00%  fvUnisocket  [kernel.kallsyms] [k]
__irq_usr
>> +0.65% 0.00%  fvUnisocket  [kernel.kallsyms] [k]
gic_handle_irq
>> +0.65% 0.00%  fvUnisocket  [kernel.kallsyms] [k]
__handle_domain_irq
>> +

Re: [go-nuts] Shared Goruntime across different microservices written in GO

2022-09-28 Thread Roland Müller
Microservices are located in containers and making these services to use a
common binary would break the basic idea of microservices.

Every service is a separate unit that shares only the absolute necessary
things for collaboration with other services rather than its implementation.

BR,
Roland

Am Mittwoch, 28. September 2022 schrieb Gladiators Squad <
squadgladiators1...@gmail.com>:
> Hi Everyone,
> is there any way to separate go runtime from go binaries?. So that it can
be shared across different micro services written in go. Instead of having
separate go run time in each services.


> 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/736c26c4-643b-4f5c-836a-e8d9878a473bn%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/CA%2B8p0G1a5agnb2QPWRPZnoWr29MZUmE9R%3Djohikqe0%3DcJ9U73w%40mail.gmail.com.


Re: [go-nuts] How to send bytes of data to struct

2022-09-28 Thread Roland Müller
Following tutorial about usage of encoding/json should address your
question.

https://tutorialedge.net/golang/parsing-json-with-golang/

BR,
Roland

Am Sonntag, 25. September 2022 schrieb Vishnu B :
> I am new to golang, I have a function that receives the JSON data as
bytes(data variable) I want to send that data to a struct(Item Struct),
When I use the data or string(data) it doesn't accept it. if it uses JSON
({Type:"NETFLOW_V5",ObservationPointID:0,ObservationDomainID:0,TimeReceived:1664011665,IcmpName:""},
>  })  directly it accepts it. How do I use the data variable in the
struct?
> func (d *BigQueryDriver) Send(key, data []byte) error {
>
>  items := []*Item{
>
{Type:"NETFLOW_V5",ObservationPointID:0,ObservationDomainID:0,TimeReceived:1664011665,IcmpName:""},
>  }
> if err := inserter.Put(context.Background(), items); err != nil {
> return err
> }
> return nil
>
> --
> 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/3d66cd8a-938d-4aab-a027-4c3b3a6f3ad2n%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/CA%2B8p0G0GoA9SVq_UyQ2D27n_0UT16%3DUce9ATcTj_Aoi0QPrpZA%40mail.gmail.com.


Re: [go-nuts] custom linux shell that can run bash shell

2022-06-04 Thread Roland Müller
Hello,

Am Freitag, 3. Juni 2022 schrieb Harsh Rathore :
> Hello everyone,
> so I am trying to make a custom linux shell in golang, among other
things, I want this shell to be able to run BASH shell.
> Like when we are prompted with sh shell
> $

Of course it is feasable to make a Golang remake of interactive or batch
processing Linux shell. However doing that you have to answer the question
why a Golang rewrite would be better than just using the existing shell(s).

BR,
Roland

> executing /bin/bash, provides bash prompt
> $ /bin/bash
> user@hostName:~#
> similarly, I want my golang shell to provide me with bash shell
> myPrompt> /bin/bash
> user@hostName:~#
>
> I have tried multiple things:
> 1. Replicating bash prompt, when /bin/bash is received, and getting
os.Stdin, and executing using os/exec Output() function.
> 2. Trying to make stdpipes and then channel input/output via them, while
using cmd.Start() and cmd.Waint().
> these did not help, I am looking for some help from the experts.
> Thank you if you read this.
> Super thank you, if you have a solution :).
> PFA: My shell.go 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/fa86ccc6-c847-4c8f-bea3-65b938b0d4cdn%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/CA%2B8p0G1Sbi3JdcOe%3DFi9Ck0c0i73bBEsiHV3hPxu_MgdCK1eHg%40mail.gmail.com.


Re: [go-nuts] Golang and virustotal

2022-05-11 Thread Roland Müller
Hello,

Am Mi., 11. Mai 2022 um 13:44 Uhr schrieb Klaus Post :

> Hi!
>
> You can try 'garble' and see if that helps:
> https://github.com/burrowers/garble
>
> For me, it seems to reduce the number of false positives, but there are
> still some left.
>
> /Klaus
>

Just a silly question: is the occurrence of false positives also influenced
whether the binary has been cross-compiled e.g. in Linux or natively in
Windows?

Until now I compiled all my Windows exes in my Linux PC and the "success
rate" of the Virus scanner is 100% :-)

Regards,
Roland

-- 
> 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/35b078ad-88c5-49e1-8348-b016eb0a2cabn%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/CA%2B8p0G2X%2BfxHkzwmrkDUKoWv%2B%3D6kEzGr5rz%3DZvuBPSu-7whBqQ%40mail.gmail.com.


Re: [go-nuts] Golang application local timezone doesn't change with the system timezone

2022-03-02 Thread Roland Müller
Hello,

Am Mi., 2. März 2022 um 09:48 Uhr schrieb Brian Candler :

> On Tuesday, 1 March 2022 at 22:54:35 UTC carl...@gmail.com wrote:
>
>> If I had running services written in Go, they would not be aware of the
>> timezone change.
>>
>
> I think the current behaviour is reasonable, because it's rare that a
> running, persistent *service* needs to know of a change of the *system*
> timezone.
>
> If this is a web server interacting with a user, then either it should use
> the browser timezone, or have a user preference for timezone.  If it's
> writing log files then it should be using UTC or a chosen fixed timezone
> (otherwise there's ambiguity about what time events happened).  If it's
> talking to a database with date/time columns, the same applies.
>
> Yes, I agree. In rare cases when a service has to re-evaluate its settings
it should be the responsibility of the program changing the configuration
to initiate reloading settings or re-starting the service.

How to do that is dependent on the operation system:
* In the old times on Unix or Linux a HUP signal was send to inform a
service (=daemon) to re-read its configuration and maybe to restart. In
systemd the systemctl reload command could be used.
* for Windows I have no idea

BR,
Roland



> --
> 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/7bc6b39e-9b60-4ae6-9df1-f8a2abceb0bcn%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/CA%2B8p0G1aD9xHiMDanbLnNBoz3ftagqU95512u8VBmNVFRMa6GQ%40mail.gmail.com.


Re: [go-nuts] go mod tidy stop when downloading

2022-02-24 Thread Roland Müller

Hello,

On 2/24/22 08:20, Rijal Asep Nugroho wrote:

i am run go mod tidy, and always stop when downloading kafka-go.
is the kafka-go library the problem?
or how to find out what's going on?
is there an option to view log information or something?
thanks.


May be these two flags are helpful for getting more information or to 
make tidy continue when something fails.



$ go help mod tidy

...

The -v flag causes tidy to print information about removed modules
to standard error.

The -e flag causes tidy to attempt to proceed despite errors
encountered while loading packages.

...

See https://golang.org/ref/mod#go-mod-tidy for more about 'go mod tidy'.


BR,

Roland




go mod tidy
go: finding module for package github.com/gin-gonic/gin 

go: finding module for package github.com/urfave/cli 

go: finding module for package 
github.com/opentracing/opentracing-go/mocktracer 

go: finding module for package github.com/uber/jaeger-client-go 

go: finding module for package github.com/go-pg/pg/v10 

go: finding module for package github.com/go-redis/redis/v8 

go: finding module for package github.com/opentracing/opentracing-go 

go: finding module for package github.com/uber/jaeger-client-go/utils 

go: downloading github.com/uber/jaeger-client-go 
 v1.6.0
go: downloading github.com/go-pg/pg  
v8.0.7+incompatible
go: downloading github.com/gin-gonic/gin 
 v1.7.7
go: downloading github.com/go-pg/pg/v10 
 v10.10.6
go: downloading github.com/opentracing/opentracing-go 
 v1.2.0
go: downloading github.com/urfave/cli  
v1.22.5
go: downloading github.com/go-redis/redis 
 v6.15.9+incompatible
go: downloading github.com/go-redis/redis/v8 
 v8.11.4
go: finding module for package github.com/waresix/w6lib/kafka 

go: finding module for package github.com/waresix/w6lib/logger 

go: finding module for package google.golang.org/grpc 

go: finding module for package 
gopkg.in/DataDog/dd-trace-go.v1/ddtrace/opentracer 

go: finding module for package 
gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer 


go: finding module for package gopkg.in/gcfg.v1 
go: downloading github.com/uber/jaeger-client-go 
 v2.30.0+incompatible

go: downloading gopkg.in/gcfg.v1  v1.2.3
go: downloading gopkg.in/DataDog/dd-trace-go.v1 
 v1.36.0
go: downloading google.golang.org/grpc  
v1.44.0
go: finding module for package github.com/sirupsen/logrus 

go: finding module for package google.golang.org/grpc/codes 

go: finding module for package google.golang.org/grpc/metadata 

go: downloading github.com/sirupsen/logrus 
 v1.8.1
go: finding module for package google.golang.org/protobuf/proto 

go: finding module for package github.com/google/uuid 

go: finding module for package github.com/lib/pq 

go: downloading google.golang.org/protobuf 
 v1.27.1

go: downloading github.com/lib/pq  v1.10.4
go: downloading github.com/google/uuid  
v1.3.0
go: finding module for package github.com/hoisie/mustache 

go: finding module for package github.com/leekchan/accounting 

go: finding module for package 
google.golang.org/protobuf/encoding/protojson 

go: finding module for package google.golang.org/grpc/status 

go: finding module for package github.com/golang-migrate/migrate/v4 

go: downloading github.com/leekchan/accounting 
 v1.0.0
go: finding module for package 
github.com/golang-migrate/migrate/v4/database 

go: downloading 

Re: [go-nuts] fmt.Sscanf strange behaviour

2022-01-25 Thread Roland Müller
The tool you are looking for is most probably the regex module:

https://pkg.go.dev/regexp

BR
Roland

Am Mittwoch, 26. Januar 2022 schrieb Victor Giordano :
> Thanks for the insight again. It is appreciated.
> Till next time.
> V
> El mar, 25 ene 2022 a las 18:05, Ian Lance Taylor ()
escribió:
>>
>> On Tue, Jan 25, 2022 at 12:45 PM Victor Giordano 
wrote:
>> >
>> > Thanks Ian, I will take your advice and use another approach, I regret
this cuz it would be nice to have something already working.
>> >
>> > Without any intent to offense or say something hard, as a client of
the library it kind looks quite buggy, the parenthesis are still an issue
disregarding that the values are actually space-delimited. The error
messages clearly are an invitation to see the source for deeper
understanding rather than given any clues.
>>
>> Your newer example is still working as documented.  The %s swallows
>> everything up to the space, including the right parenthesis.  Then
>> there is nothing to match the right parenthesis in the format string.
>>
>> This behavior dates back to the C function sscanf that the Go code is
>> based on.  The %s code can be useful for space-separated fields, but
>> is not very useful for anything else.
>>
>> Ian
>
>
> --
> V
>
> --
> 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/CAPUu9sv-bF7KM_xTdPCP9SP%2BuCarz04DvjKGBuvS92sYV%2BP4iQ%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/CA%2B8p0G3emJJHU6dtnTH1i4Rfkk2rNLWrSoH5_59a2BrHWVrsDg%40mail.gmail.com.


Re: [go-nuts] Re: golang-announce is blocked in Google Groups?

2022-01-21 Thread Roland Müller
Same applies for me. Most of mail for this group would be moved to 'Spam'.
Only a custom rule prevents that to take place.

Am Fr., 21. Jan. 2022 um 20:31 Uhr schrieb Bruno Albuquerque :

> FWIIW, the same happens here. When creating a filter (assuming one is
> using GMail) you can tell it to never send emails that match the filter to
> Spam and that6 is what I ended up doing.
>
>
> On Fri, Jan 21, 2022 at 8:43 AM Peter Aronoff 
> wrote:
>
>> On Thu, Jan 20, 2022 at 2:35 PM Ian Lance Taylor  wrote:
>>
>>> On Thu, Jan 20, 2022 at 4:51 AM peterGo  wrote:
>>> >
>>> > Jochen,
>>> >
>>> > I get that message too.
>>> >
>>> > https://groups.google.com/g/golang-announce
>>> >
>>> > Google is also trying to lock me out of my gmail accounts, but they do
>>> that all the time.
>>> >
>>> > I don't think Google puts their best people on security.
>>>
>>> Hmmm, it is working for me at the moment.  Are other people still
>>> seeing the warning?
>>
>>
>>> It's unfortunately the case that announce groups tend to pick up these
>>> spam warnings, as people forget they signed up for the group and then
>>> mark messages as spam.
>>>
>>
>>
>> I'm not sure whether this is the same issue, but most email from
>> golang-nuts ends up in my spam folder. I keep marking them all as not spam,
>> but so far, without any effect. Roughly 80% of the mail for this group ends
>> up in the spam folder. Additional info: I recently created this Gmail
>> account (for all things go-related), and I have a rule to funnel all email
>> from golang-nuts into its own folder. Despite the rule, most email from the
>> group goes straight to spam.
>>
>> Peter
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/golang-nuts/CAHnuShzJk-7rQp4V0391j_Sr5asQJ%2BG%3Dzr7NGtGo%3DLU6UXSsrA%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/CAEd86TxJyyuqRHmeng-_A5CpeLuJRxPpO4EVH%3D_ryC%2BvnDc%3DuQ%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/CA%2B8p0G3wKWVkJ%3DzOVjRAZKM1V5yFKBpgESSu7LVjvPSAy5q1HQ%40mail.gmail.com.


Re: [go-nuts] Fatal error : on running go vet cmd

2022-01-13 Thread Roland Müller
Hello


Am Mi., 12. Jan. 2022 um 23:19 Uhr schrieb Ian Lance Taylor :

> On Wed, Jan 12, 2022 at 1:17 PM Tejas Gowda 
> wrote:
> >
> > I am using linux enviorment, installed go 1.6
>

In Fedora 34 there must be glibc-headers-x86 installed to get C headers.
However, if gcc is installed by package management (rpm or dnf in Fedora
case) then this package will be installed thru the dependencies.

$ rpm -qf /usr/include/stdlib.h
glibc-headers-x86-2.33-20.fc34.noarch

BR,
Roland


> 1.16 rather than 1.6, I hope.
>
> What Linux distro?
>
> Ian
>
> > On Thursday, January 13, 2022 at 2:29:00 AM UTC+5:30 Ian Lance Taylor
> wrote:
> >>
> >> On Wed, Jan 12, 2022 at 10:58 AM Tejas Gowda 
> wrote:
> >> >
> >> > # runtime/cgo
> >> > _cgo_export.c:3:20: fatal error: stdlib.h: No such file or directory
> >> > #include 
> >> > ^
> >> > compilation terminated.
> >>
> >> That looks like you have a C compiler installed but no C library
> installed.
> >>
> >> Hard to say more without more information, like what kind of system
> >> you are using and exactly what you did.
> >>
> >> Ian
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "golang-nuts" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to golang-nuts+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/1ce9b7e4-e4d7-4340-a13f-d9c58e3c431cn%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/CAOyqgcU17A%2B5RSvtVNoYRJddEK1Fj1FHyUc3Z5zQ4mLpA_tLHg%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/CA%2B8p0G1EQRLgJA0S2%3Dg1bnyhzMuW_YCxpQpbb473OrFnPwC9Uw%40mail.gmail.com.


Re: [go-nuts] Do pointer receiver methods need to be checked for nil?

2021-11-25 Thread Roland Müller
Definitely yes. I just sent a message in another thread in this discussion
group

BR,
Roland

Quoting myself:

Obviously, even just calling a "methods" of some struct instance that is
not initialized succeeds in Go. A panic occurs only when the program tries
to derefer nil pointer:

'func (ev *Event) do()' only uses the pointer but does not derefer it.
Thus, no panic.

Here 'func (ev Event) do2()' derefers nil pointer already before call.
Panic in main.main()

https://go.dev/play/p/O_C0RpXb46h

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x47f812]

goroutine 1 [running]:
main.main()
/tmp/sandbox1681946220/prog.go:14 +0x112


Here 'func (ev *Event) getS()' derefers the pointer. Panic happens inside
the main.getS()
https://go.dev/play/p/lto_JSFC2Qd

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x47f8d4]

goroutine 1 [running]:
main.(*Event).getS(0x4b2a40)
/tmp/sandbox1571083836/prog.go:35 +0x14



Am Fr., 26. Nov. 2021 um 06:39 Uhr schrieb shinya sakae <
sakashin10291...@gmail.com>:

> Hi.
> I've been using Go for a while now, and I've noticed something.
> Do pointer receiver methods need to be checked for nil?
> In the standard package, it may or may not be checked.
> I'd like to hear your opinions.
>
> --
> 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/8bada92b-f179-4133-adcf-0cf971671b00n%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/CA%2B8p0G02gUnphuyLMnuYk6De7RHao77jxVOq0cOLtMM7WCDDZA%40mail.gmail.com.


Re: [go-nuts] some incorrect code in blog.

2021-11-25 Thread Roland Müller
Hello David,

the behavior of File.Close() on nil was a surprise for me too.

Obviously, even just calling a "methods" of some struct instance that is
not initialized succeeds in Go. A panic occurs only when the program tries
to derefer nil pointer:

'func (ev *Event) do()' only uses the pointer but does not derefer it.
Thus, no panic.

Here 'func (ev Event) do2()' derefers nil pointer already before call.
Panic in main.main()

https://go.dev/play/p/O_C0RpXb46h

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x47f812]

goroutine 1 [running]:
main.main()
/tmp/sandbox1681946220/prog.go:14 +0x112


Here 'func (ev *Event) getS()' derefers the pointer. Panic happens inside
the main.getS()
https://go.dev/play/p/lto_JSFC2Qd

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x47f8d4]

goroutine 1 [running]:
main.(*Event).getS(0x4b2a40)
/tmp/sandbox1571083836/prog.go:35 +0x14


BR,

Roland



Am Do., 25. Nov. 2021 um 22:54 Uhr schrieb David Karr <
davidmichaelk...@gmail.com>:

> I meant, did you test it with a bad path, and with the defer before the
> error check?  I believe you implied that this didn't result in a failure.
> It would have happened on exit from the method, if anything.
>
> On Thu, Nov 25, 2021 at 12:49 PM Roland Müller  wrote:
>
>> Yes. Actually I only tested with a non-existing file.
>>
>> But if you mean that case were also the directory is missing: behavior is
>> still the same.
>>
>> BR,
>> Roland
>>
>> func main() {
>> f, err := os.Open("/tmp/dat_is_net_do/dat")
>> //defer f.Close()
>> fmt.Printf("%v\n", f)
>> if err != nil {
>>   fmt.Println("NO FILE")
>>   //return
>>}
>>defer f.Close()
>>fmt.Println("END")
>> }
>>
>>
>> Am Do., 25. Nov. 2021 um 21:43 Uhr schrieb David Karr <
>> davidmichaelk...@gmail.com>:
>>
>>> And did you test that with a file path that would fail?
>>>
>>> On Thu, Nov 25, 2021, 11:40 Roland Müller  wrote:
>>>
>>>> Hello,
>>>>
>>>> actually trying this with os.Open() the program behaves the same
>>>> regardless whether the defer is before or after the error handling, Thus,
>>>> no panic :-)
>>>>
>>>> Isn't anything declared with defer always running after the user code
>>>> in the given func ends? I am too tired now to look this up.
>>>>
>>>> BR,
>>>>
>>>> Roland
>>>>
>>>> package main
>>>>
>>>> import (
>>>> "fmt"
>>>> "os"
>>>> )
>>>>
>>>> func main() {
>>>> f, err := os.Open("/tmp/dat")
>>>> //defer f.Close()
>>>> fmt.Printf("%v\n", f)
>>>> if err != nil {
>>>>   fmt.Println("NO FILE")
>>>>   //return
>>>>}
>>>>defer f.Close()
>>>>fmt.Println("END")
>>>> }
>>>>
>>>> Output:
>>>> 
>>>> NO FILE
>>>> END
>>>>
>>>>
>>>> On 11/25/21 10:19, Fannie Zhang wrote:
>>>>
>>>> OK, I see. Thank you.
>>>>
>>>>
>>>>
>>>> *From:* Kurtis Rader  
>>>> *Sent:* Thursday, November 25, 2021 10:26 AM
>>>> *To:* Fannie Zhang  
>>>> *Cc:* golang-nuts 
>>>> 
>>>> *Subject:* Re: [go-nuts] some incorrect code in blog.
>>>>
>>>>
>>>>
>>>> Notice the date of that blog article: 2010-08-04. It's more than eleven
>>>> years old. Blog articles are not updated as the language changes. However,
>>>> in this case the example in that article is correct. If `os.Open()` returns
>>>> an error then the `src` return value is invalid.
>>>>
>>>>
>>>>
>>>> On Wed, Nov 24, 2021 at 6:14 PM Fannie Zhang 
>>>> wrote:
>>>>
>>>> Hi all,
>>>>
>>>>
>>>>
>>>> There is some incorrect code in
>>>> https://go.dev/blog/defer-panic-and-recover blog.
>>>>
>>>>
>>>>
>>>> The original code is
>>>>
>>>> *func CopyFile() {*
>>>>
>>>> *   ...*
&g

Re: [go-nuts] some incorrect code in blog.

2021-11-25 Thread Roland Müller
Yes. Actually I only tested with a non-existing file.

But if you mean that case were also the directory is missing: behavior is
still the same.

BR,
Roland

func main() {
f, err := os.Open("/tmp/dat_is_net_do/dat")
//defer f.Close()
fmt.Printf("%v\n", f)
if err != nil {
  fmt.Println("NO FILE")
  //return
   }
   defer f.Close()
   fmt.Println("END")
}


Am Do., 25. Nov. 2021 um 21:43 Uhr schrieb David Karr <
davidmichaelk...@gmail.com>:

> And did you test that with a file path that would fail?
>
> On Thu, Nov 25, 2021, 11:40 Roland Müller  wrote:
>
>> Hello,
>>
>> actually trying this with os.Open() the program behaves the same
>> regardless whether the defer is before or after the error handling, Thus,
>> no panic :-)
>>
>> Isn't anything declared with defer always running after the user code in
>> the given func ends? I am too tired now to look this up.
>>
>> BR,
>>
>> Roland
>>
>> package main
>>
>> import (
>> "fmt"
>> "os"
>> )
>>
>> func main() {
>> f, err := os.Open("/tmp/dat")
>> //defer f.Close()
>> fmt.Printf("%v\n", f)
>> if err != nil {
>>   fmt.Println("NO FILE")
>>   //return
>>}
>>defer f.Close()
>>fmt.Println("END")
>> }
>>
>> Output:
>> 
>> NO FILE
>> END
>>
>>
>> On 11/25/21 10:19, Fannie Zhang wrote:
>>
>> OK, I see. Thank you.
>>
>>
>>
>> *From:* Kurtis Rader  
>> *Sent:* Thursday, November 25, 2021 10:26 AM
>> *To:* Fannie Zhang  
>> *Cc:* golang-nuts 
>> 
>> *Subject:* Re: [go-nuts] some incorrect code in blog.
>>
>>
>>
>> Notice the date of that blog article: 2010-08-04. It's more than eleven
>> years old. Blog articles are not updated as the language changes. However,
>> in this case the example in that article is correct. If `os.Open()` returns
>> an error then the `src` return value is invalid.
>>
>>
>>
>> On Wed, Nov 24, 2021 at 6:14 PM Fannie Zhang 
>> wrote:
>>
>> Hi all,
>>
>>
>>
>> There is some incorrect code in
>> https://go.dev/blog/defer-panic-and-recover blog.
>>
>>
>>
>> The original code is
>>
>> *func CopyFile() {*
>>
>> *   ...*
>>
>> *   if err != nil {*
>>
>> *  return*
>>
>> *   }*
>>
>> *   defer src.Close()*
>>
>> *   ...*
>>
>> *}*
>>
>>
>>
>> I think the correct code should be
>>
>> *func CopyFile() {*
>>
>> *   ...*
>>
>> *   defer src.Close()*
>>
>> *   if err != nil {*
>>
>> *  return*
>>
>> *   }*
>>
>> *   ...*
>>
>> *}*
>>
>>
>>
>> I do not know how to modify the go blog, can anyone help? Thank you.
>>
>>
>>
>> Best regards,
>>
>> Fannie Zhang
>>
>> --
>> 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/726e95ed-9b14-46a5-bb09-7821616f4ff9n%40googlegroups.com
>> <https://groups.google.com/d/msgid/golang-nuts/726e95ed-9b14-46a5-bb09-7821616f4ff9n%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>>
>>
>>
>> --
>>
>> Kurtis Rader
>>
>> Caretaker of the exceptional canines Junior and Hank
>> IMPORTANT NOTICE: The contents of this email and any attachments are
>> confidential and may also be privileged. If you are not the intended
>> recipient, please notify the sender immediately and do not disclose the
>> contents to any other person, use it for any purpose, or store or copy the
>> information in any medium. 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/golang-nuts/PAXPR08MB6640963981E13AC180B4E19594629%40PAXPR08MB6640.eurprd08.prod.outlook.com
>> <https://groups.google.com/d/msgid/golang-nuts/PAXPR08MB6640963981E13AC180B4E19594629%40PAXPR08MB6640.eurprd08.prod.outlook.com?utm_medium=email_source=footer>
>> .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/golang-nuts/4d0b379f-c2a0-a314-e2d3-5fec36528845%40gmail.com
>> <https://groups.google.com/d/msgid/golang-nuts/4d0b379f-c2a0-a314-e2d3-5fec36528845%40gmail.com?utm_medium=email_source=footer>
>> .
>>
>

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


Re: [go-nuts] some incorrect code in blog.

2021-11-25 Thread Roland Müller

Hello,

actually trying this with os.Open() the program behaves the same 
regardless whether the defer is before or after the error handling, 
Thus, no panic :-)


Isn't anything declared with defer always running after the user code in 
the given func ends? I am too tired now to look this up.


BR,

Roland

package main

import (
    "fmt"
    "os"
)

func main() {
    f, err := os.Open("/tmp/dat")
    //defer f.Close()
    fmt.Printf("%v\n", f)
    if err != nil {
  fmt.Println("NO FILE")
  //return
   }
   defer f.Close()
   fmt.Println("END")
}

Output:


NO FILE
END


On 11/25/21 10:19, Fannie Zhang wrote:


OK, I see. Thank you.

*From:* Kurtis Rader 
*Sent:* Thursday, November 25, 2021 10:26 AM
*To:* Fannie Zhang 
*Cc:* golang-nuts 
*Subject:* Re: [go-nuts] some incorrect code in blog.

Notice the date of that blog article: 2010-08-04. It's more than 
eleven years old. Blog articles are not updated as the language 
changes. However, in this case the example in that article is correct. 
If `os.Open()` returns an error then the `src` return value is invalid.


On Wed, Nov 24, 2021 at 6:14 PM Fannie Zhang  wrote:

Hi all,

There is some incorrect code in
https://go.dev/blog/defer-panic-and-recover blog.

The original code is

/func CopyFile() {/

/   .../

/   if err != nil {/

/      return/

/   }/

/   defer src.Close()/

/   .../

/}/

I think the correct code should be

/func CopyFile() {/

/   .../

/   defer src.Close()/

/   if err != nil {/

/      return/

/   }/

/   .../

/}/

I do not know how to modify the go blog, can anyone help? Thank you.

Best regards,

Fannie Zhang

-- 
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/726e95ed-9b14-46a5-bb09-7821616f4ff9n%40googlegroups.com

.


--

Kurtis Rader

Caretaker of the exceptional canines Junior and Hank

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended 
recipient, please notify the sender immediately and do not disclose 
the contents to any other person, use it for any purpose, or store or 
copy the information in any medium. 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/PAXPR08MB6640963981E13AC180B4E19594629%40PAXPR08MB6640.eurprd08.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/4d0b379f-c2a0-a314-e2d3-5fec36528845%40gmail.com.


Re: [go-nuts] cgo error I don't understand

2021-11-04 Thread Roland Müller
Hello,

the entry in the path for mingwin is wrong: it should be either start with
C:\ or another drive letter or in case it's an absolute path with double
backslash.

Br
Roland

Am Freitag, 5. November 2021 schrieb Robert Solomon :
> The full error is:
> # github.com/go-gl/glfw/v3.3/glfw
> cgo: exec gcc: gcc resolves to executable relative to current directory
(.\\msys64\mingw64\bin\gcc.exe)
> # github.com/go-gl/gl/v3.2-core/gl
> cgo: exec gcc: gcc resolves to executable relative to current directory
(.\\msys64\mingw64\bin\gcc.exe)
>
>
> echo %path is:
> C:\Program
Files\git\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program
Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA
Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\gnupg\bin;C:\Program
Files\Go\bin;C:\Program Files\Git\cmd;C:\Program
Files\Git\mingw64\bin;C:\Program
Files\Git\usr\bin;C:\Users\Owner\AppData\Local\Microsoft\WindowsApps;C:\Users\Owner\go\bin;C:\Users\Owner;C:\Program
Files\go\bin;\msys64\mingw64\bin
>
>
> On Thursday, November 4, 2021 at 7:54:14 PM UTC-4 Ian Lance Taylor wrote:
>>
>> On Thu, Nov 4, 2021 at 4:41 PM Robert Solomon  wrote:
>> >
>> > The results of go env are below. If I'm reading this correctly, CC=gcc.
>> >
>> > set GO111MODULE=auto
>> > set GOARCH=amd64
>> > set GOBIN=
>> > set GOCACHE=C:\Users\Owner\AppData\Local\go-build
>> > set GOENV=C:\Users\Owner\AppData\Roaming\go\env
>> > set GOEXE=.exe
>> > set GOEXPERIMENT=
>> > set GOFLAGS=
>> > set GOHOSTARCH=amd64
>> > set GOHOSTOS=windows
>> > set GOINSECURE=
>> > set GOMODCACHE=C:\Users\Owner\go\pkg\mod
>> > set GONOPROXY=
>> > set GONOSUMDB=
>> > set GOOS=windows
>> > set GOPATH=C:\Users\Owner\go
>> > set GOPRIVATE=
>> > set GOPROXY=https://proxy.golang.org,direct
>> > set GOROOT=C:\Program Files\Go
>> > set GOSUMDB=sum.golang.org
>> > set GOTMPDIR=
>> > set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
>> > set GOVCS=
>> > set GOVERSION=go1.17.2
>> > set GCCGO=gccgo
>> > set AR=ar
>> > set CC=gcc
>> > set CXX=g++
>> > set CGO_ENABLED=1
>> > set GOMOD=C:\Users\Owner\go\src\go.mod
>> > set CGO_CFLAGS=-g -O2
>> > set CGO_CPPFLAGS=
>> > set CGO_CXXFLAGS=-g -O2
>> > set CGO_FFLAGS=-g -O2
>> > set CGO_LDFLAGS=-g -O2
>> > set PKG_CONFIG=pkg-config
>> > set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics
-Qunused-arguments -fmessage-length=0
-fdebug-prefix-map=C:\Users\Owner\AppData\Local\Temp\go-build4162893276=/tmp/go-build
-gno-record-gcc-switches
>>
>> Hmmm. What is the path environment variable?
>>
>> Ian
>>
>>
>> > On Thursday, November 4, 2021 at 6:20:10 PM UTC-4 Ian Lance Taylor
wrote:
>> >>
>> >> On Wed, Nov 3, 2021 at 5:40 PM Robert Solomon 
wrote:
>> >> >
>> >> > I'm setting up a new Windows10 computer. I installed Go 1.17.2 and
mingw64 for cgo. When I tried to compile a project that uses cgo, I got
this error:
>> >> >
>> >> > cgo: exec gcc: gcc resolves to executable relative to current
directory (.\\msys64\mingw64\bin\gcc.exe)
>> >> >
>> >> > This is a program that compiles fine on my older win10 computer.
>> >> >
>> >> > I don't think this matters, but I'm compiling a program of mine
that uses fyne, which uses cgo.
>> >>
>> >> This suggests that the CC environment variable is set to
>> >> ".\\msys64\mingw64\bin\gcc.exe" with a leading dot. That is not an
>> >> absolute path. That is not permitted for the reasons given at
>> >> https://golang.org/issue/43783.
>> >>
>> >> Ian
>> >
>> > --
>> > You received this message because you are subscribed to the Google
Groups "golang-nuts" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
an email to golang-nuts...@googlegroups.com.
>> > To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/e60e5b03-92d4-4f01-a516-1fca7e2905bdn%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/306f2cba-ae3b-4e77-94d1-6064f53bba1bn%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/CA%2B8p0G0fMjK7f27L%2BJKFxAnuBW9h1CmEUwkqM_gw-fYJM81cBg%40mail.gmail.com.


Re: [go-nuts] smtp.SendMail not using the from argument

2021-09-09 Thread Roland Müller
Hello,

Am Do., 9. Sept. 2021 um 20:19 Uhr schrieb Dean Schulze <
dean.w.schu...@gmail.com>:

> I'm sending emails with smtp.SendMail() via gmail.  I set the from
> argument to smtp.SendMail() to a different email address than my gmail
> username, but the emails still get sent with the From: as my gmail address.
>
> Do I need to do something else to change the From: in the emails, or is
> gmail always going to use my gmail address?
>
> I guess gmail uses the address bound to the used account, which would be
in my opinion quite reasonable behavior.

BTW this question is a bit OT here since not related to Go rather than
mailing policy of Google accounts.

BR,
Roland

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/04eb41bd-9002-443b-8921-c3ddcd833c87n%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/CA%2B8p0G20TRSqG81EwkqVKFgVWMVgSkTcUbwKQBVMz9HbKfsirg%40mail.gmail.com.


Re: [go-nuts] Makefiles for Go Programs

2021-09-02 Thread Roland Müller
Hello,

A big thank you to everybody who contributed to this thread! I guess it
will take some time to process the things learned from this discussion.

BR,
Roland


Am Mi., 25. Aug. 2021 um 12:28 Uhr schrieb Stephen Illingworth <
stephen.illingwo...@gmail.com>:

> I use Makefiles with Go projects. For many of the reasons already given
> but it's especially useful for me for cross compilation to the target
> platforms at release time. So, when running "make release" I have "test"
> and "generate" targets as dependencies to make sure I've not missed
> anything.
>
> I don't need a build system to do that but it's good to have a script for
> that kind of thing, IMO.
>
> I also use it in the git pre-commit hook. For example, I have "make lint"
> in that script which runs whatever linter I'm using at the moment and I can
> be assured that it's the same linter I'm using at the command line.
>
> As for why not another build system, for the same reason as other
> respondents have said. Make has been around forever and I don't need
> anything more sophisticated.
>
> > Make does not come alone for end-users. Usually it comes bundled with
> several hundreds of megabytes of > the devel packages  user gets after
> issuing eg. `sudo apt-get install build-essential`.
>
> Surely, you would just do: `sudo apt-get install make`
>
>
> On Tuesday, 24 August 2021 at 12:14:50 UTC+1 ohir wrote:
>
>> Dnia 2021-08-24, o godz. 07:54:35
>> Reto  napisał(a):
>>
>> > It may be nicer, however the beauty of make is that it is ubiquitous,
>> > everybody already has it.
>>
>> No, not everybody has it. Esp. on Windows host.
>>
>> > With mage, your installation instructions now need to contain how /
>> > where to get mage in the first place, leaving the user with a random
>> > binary somewhere which they probably never ever need nor update again.
>>
>> Nope. If user is going to compile from sources she also needs to install
>> Go compiler and tools. Once she has it the mage is a `go install` command
>> away. Shorter than typical line of "prerequisites" needed by non-developer
>> user on most of linux distros. (If she is about to install binary she does
>> not need mage at all - 99% deployments of Go based apps are just the single
>> executable.)
>>
>> > leaving the user with ... they probably never ever need nor update
>> again.
>>
>> Make does not come alone for end-users. Usually it comes bundled with
>> several hundreds of megabytes of the devel packages
>> user gets after issuing eg. `sudo apt-get install build-essential`. Then
>> she's left with a bit more more unused stuff than a single
>> mage binary.
>>
>> TC,
>>
>> --
>> Wojciech S. Czarnecki
>> << ^oo^ >> OHIR-RIPE
>>
> --
> 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/039b0cac-a81c-40ae-bb46-f12d11261707n%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/CA%2B8p0G0vb6RbwP4cQ3yNHk%3DGY%2BFW9Frx3e-M24vifW8QPsOn9g%40mail.gmail.com.


Re: [go-nuts] Re: Makefiles for Go Programs

2021-08-23 Thread Roland Müller
Am Mo., 23. Aug. 2021 um 18:48 Uhr schrieb jake...@gmail.com <
jake6...@gmail.com>:

> On Sunday, August 22, 2021 at 11:11:23 PM UTC-4 jlfo...@berkeley.edu
> wrote:
>
>>
>> I've noticed that few, if any, Go programs use Makefiles. Is that because
>> the overhead of using make is greater than the overhead of just always
>> compiling and linking everything?
>>
>
> Go had built in build caching. So it will not have to "always compile and
> link everything." In addition, Go builds tend to be much, much faster than
> most other compiled languages. As a result, Makefiles are only useful if
> you have other operations to perform that are not part of the normal go
> tooling.
>
>
>> One piece of evidence for this is that the Go compiler leaves no
>> artifacts, like object files, so as is make wouldn't fit into the current
>> build method.
>>
>
What are the alternatives to Makefile that are used by Go developers?
Please comment :-)

I know Make from old C/C++ times. Therefore, my picture is that it is not
very portable and requires for quite many operations the usage of external
tools that again differ between the platforms. Basically Makefiles are
somehow enhanced shell scripts (Linux/Unix) or batch files (Windows).

Currently, at work I deal a lot with Maven, that is a bit too Java
-oriented in spite of being capable in principle to build and compile other
things too. Another, issue is the XML syntax that's makes editing without
tool support very hard.

Gradle would be another candidate. I am just began to explore it. It's a
bit like Maven with human syntax, but lacks again on lifecycle support that
I like with Maven.

BR,
Roland



>
>> Cordially,
>> Jon Forrest
>>
>>
>> --
> 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/449781bc-1605-4acf-b03c-dab98cf710efn%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/CA%2B8p0G2dZGsL6RXTvc0m2_8_9MVUt_R1U3JFdhdHm8v3PwywNw%40mail.gmail.com.


Re: [go-nuts] Re: Whats wrong with my channel

2021-08-19 Thread Roland Müller
Here is a sleepless version. The channel is still unbuffered, but this
should be OK since reading from channel is done in main().
Thus, factorial() writes the result to the channel, and main() reads it
from there. As result main() does not end before factorial() is completed.

https://play.golang.org/p/nTQxU9GnDPj
package main
import (
"fmt"
)

func main() {
d := make(chan int)
go factorial(5, d)
fmt.Println("waiting ...")
fmt.Println(<-d)
fmt.Println("Game over", d)
}

func factorial(n int, d chan int) {
fmt.Println("function starting...")
var a int = 1
for ; n > 0; n-- {
a *= n
}
fmt.Println("result=", a)
d <- a
}





Am Do., 19. Aug. 2021 um 18:35 Uhr schrieb jake...@gmail.com <
jake6...@gmail.com>:

> Jan is correct, and you should probably use a sync.WaitGroup to keep your
> main() alive.
>
> But even if you do that, you have a bigger problem. You channel is
> unbuffered. That means that `d <- a` will block until someone reads from d.
> Since `factorial` is the only goroutine that uses d, that line will block
> forever. (Of course, in your code, main() will exit after 3 seconds, so
> forever is short.) You can 'fix' the code by changing to a buffered
> channel, like: `d := make(chan int, 1)`. Then your code works, since the
> send will no longer block. Although it is pretty pointless to read from a
> channel in the same goroutine that writes to it.
>
> A more common use would be for the goroutine to send the result back to
> main, like this: https://play.golang.org/p/yJHJWhYif5h
> Note that, in this case, the channel read keeps main() from exiting before
> factorial() is finished.
>
> On Thursday, August 19, 2021 at 10:43:32 AM UTC-4 muhorto...@gmail.com
> wrote:
>
>> I just started practicing with channels, after writing to the channel,
>> nothing is output from there
>> func main() {
>> d := make(chan int)
>> go factorial(5, d)
>>  time.Sleep(3 * time.Second)
>> }
>>
>> func factorial(n int, d chan int) {
>> fmt.Println("function starting...")
>> time.Sleep(3 * time.Second)
>> var a int = 1
>> for ; n > 0; n-- {
>> a *= n
>> }
>> d <- a // //nothing works after that
>> fmt.Println(<-d)
>> fmt.Println(a)
>> }
>>
>> 
>> Another question I want to make a recursive function with a factorial,
>> pass it to goroutine in main. But I do not know if it is possible to
>> somehow combine *return* and a channel in the declaration of arguments.
>>
>> -
>> if I first pass in something to the channel from main,
>> a lock occurs.Why? So it's not possible at all?
>>
> --
> 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/e81505fe-3415-4eb0-acf0-4b208e42fa13n%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/CA%2B8p0G1BuEjEOXjG%2BJr_xCU_5ekzR0KCgkeAaMAYXPkbm3h7Hw%40mail.gmail.com.


Re: [go-nuts] Re: How to retrieve content of file uploaded using "curl --upload-file ..." way in Go HttpServer

2021-08-16 Thread Roland Müller
Hello,


Am Mo., 16. Aug. 2021 um 19:11 Uhr schrieb Kannan S :

> messageId := r.URL.Query()["id"][0]
>  out, err := os.Create("./upload/" + messageId + ".mp3")
>
> in your original example file name is retrieved from the request.URL.Path
rather than from an variable named 'id' using request.URL.Query().

This should work when using the curl command below (haven't tried it out).
The line replaces the two lines setting messageId and using message Id for
creating the upload file.

out,err = os.Create("./upload/" + r.URL.Path[1:])

BR,
Roland



>  if err != nil {
> fmt.Fprintf(w, "Unable to create the file for writing. Check your
> write access privilege")
> return
>  }
>
> i added this portion but i am getting an error while trying to upload a
> file using curl
>  error in server is :panic serving 10.10.20.55:62253: runtime error:
> index out of range [0] with length 0
> what is the reason??
>
> On Wednesday, 8 October 2014 at 02:14:13 UTC+5:30 Tobias S. wrote:
>
>> Sorry, I misunderstood your problem, so my code snippet is probably
>> useless for you. But I found this:
>>
>> http://stackoverflow.com/questions/25804092/golang-upload-file-err-runtime-error-index-out-of-range
>> The code sample can be fixed easily and should be what you are after.  I
>> guess it is also better to adapt then the example you cited.
>>
>> Entefunc webUploadHandler(w http.ResponseWriter, r *http.Request) {
>>
>>  file, header, err := r.FormFile("file") // the FormFile function takes
>> in the POST input id file
>>
>>  if err != nil {
>> fmt.Fprintln(w, err)
>> return
>>  }
>>  defer file.Close()
>>
>>  // My error comes here
>>
>>  messageId := r.URL.Query()["id"][0]
>>  out, err := os.Create("./upload/" + messageId + ".mp3")
>>
>>  if err != nil {
>> fmt.Fprintf(w, "Unable to create the file for writing. Check your
>> write access privilege")
>> return
>>  }
>>  defer out.Close()
>>
>>  // write the content from POST to the file
>>  _, err = io.Copy(out, file)
>>  if err != nil {
>> fmt.Fprintln(w, err)
>>  }
>>
>>  fmt.Fprintf(w,"File uploaded successfully : ")
>>  fmt.Fprintf(w, header.Filename)
>>
>> }r code here...
>>
>>
>>
>> On Tuesday, October 7, 2014 3:56:09 PM UTC+2, Budh Ram wrote:
>>
>>> Hi Guys,
>>>
>>> I am newbie in Go language.
>>> I am writing a small HttpServer in Go where I want to upload file to
>>> this server using curl approach as:
>>>
 curl --upload-file foo.txt http://localhost:9090/rp.txt

>>>
>>> I am getting following server logs:
>>> https://gist.github.com/budhrg/355126ba4f03d32008e0
>>>
>>> I searched through docs, existing codes but the closest I found is file
>>> upload using web
>>> .
>>>
>>> Following is my code for HttpServe which I need to update to accept file
>>> content and save in server:
>>>
 package main


> import (

   "fmt"

   "net/http"

 )


> func main() {

   http.Handle("/", http.HandlerFunc(upload))

   http.ListenAndServe("localhost:9090", nil)

 }


> func upload(w http.ResponseWriter, req *http.Request) {

   fmt.Fprintf(w, "file name is : %s",req.URL.Path[1:])

   fmt.Println("method :", req.Method)

   fmt.Println("FileSize : ", req.ContentLength)

   fmt.Println("Header : ",req.Header)

   fmt.Println("Body : ",req.Body)

   fmt.Println("Post form : ",req.PostForm)

 }



>>> Please 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/85f0c138-86e0-4d31-8c1b-4c6ef1d161a6n%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/CA%2B8p0G0K4QiA3F%3DL69zkM0k6QwyDD_sJKKgy-ZT2BnUsHP4maw%40mail.gmail.com.


Re: [go-nuts] Re: Upgrade to Go1.16 from Go1.14 broke my query

2021-06-26 Thread Roland Müller
When the query works with other DBs & their Go  drivers this strongly
suggest that there is some incompatibility of the Firebird vs. Go 16.x.

Thus you should check the suggestion from Jake to update the Firebird
driver for Go.

In the Github project
https://github.com/nakagami/firebirdsql/commits/master


In Commits on Jun 21, 2021 used go version in go.mod was change to 1.15 and
the readme file now startes that go 1.15 or newer is supported. May be this
helps.

BR,
Roland

Am Sa., 26. Juni 2021 um 19:03 Uhr schrieb Hugh Myrie :

> That is a possibility. I didn't try to rebuild under Go1.14., but I will
> give that a try.  Interestingly, one "select query" worked but the others
> failed with similar error messages. After upgrading to G1.16 I ran "go
> tidy" which downloaded the libraries and create a "mod" file in the working
> folder, so I take it that the libraries are correct. I'll try your
> suggestion and let you know.
>
>   I am able to access and read MySQL and MariaDB tables with the updated
> Go version.
>
> On Saturday, June 26, 2021 at 10:43:15 AM UTC-5 jake...@gmail.com wrote:
>
>> Is it possible that the version of the library you are using also changed
>> when you changed versions of Go?
>> Have you tried building again, on the same machine, using Go 1.14 to make
>> sure that the only difference is the Go language version?
>>
>> On Thursday, June 24, 2021 at 11:14:30 AM UTC-4 hugh@gmail.com wrote:
>>
>>> I recently updated my Go version to 1.16 and for all my queries I now
>>> get an error:
>>>
>>> {"error":"Dynamic SQL Error\nSQL error code = -303\narithmetic
>>> exception, numeric overflow, or string truncation\nstring right
>>> truncation\n"}
>>>
>>> I'm using  the package:   _ "github.com/nakagami/firebirdsql"
>>>
>>> The following is a simple function:
>>>
>>> func getSystem(w http.ResponseWriter, r *http.Request) {
>>> type system struct {
>>> Tax1float64  `json:"tax1"`
>>> Fees1  float64  `json:"fees1"`
>>> Fees2   float64  `json:"fees2"`
>>> Minus_stk string `json:"minus_stk"`
>>> Discount1 float64 `json:"discount1"`
>>> Discount2 float64 `json:"discount2"`
>>> Discount3 float64 `json:"discount3"`
>>> Discount4 float64 `json:"discount4"`
>>> Elderly float64 `json:"elderly"`
>>> Message NullString `json:"message"`
>>> Binary4 NullString `json:"binary4"`
>>> }
>>> sysdata := []system{}
>>> sql2 := "select tax1, fees1, fees2, minus_stk, discount1, discount2,
>>> discount3, discount4, elderly, cast(mesg as varchar(400)), binary4 from
>>> system"
>>> conn, _ := sql.Open("firebirdsql",  datapath)
>>> defer conn.Close()
>>> rows, err := conn.Query(sql2)
>>> if err != nil {
>>> respondWithError(w, http.StatusBadRequest, err.Error())
>>> return
>>> }
>>> defer rows.Close()
>>> for rows.Next() {
>>> var p system
>>> err := rows.Scan(, , , _stk,
>>> , , , , ,
>>> , )
>>> if err != nil {
>>> respondWithError(w, http.StatusBadRequest, err.Error())
>>> return
>>> }
>>> sysdata = append(sysdata, p)
>>> }
>>> err = rows.Err()  //  <--- errors seem to thrown here.
>>> if err != nil {
>>> respondWithError(w, http.StatusBadRequest, err.Error())
>>> return
>>> }
>>> respondWithJSON(w, http.StatusOK, sysdata)
>>> }
>>>
>>> Your help would be appreciated.
>>>
>>> I'm using Firebird 2.5. Everything worked under the previous version of
>>> Go. I am scanning for null values so I don't believe that is the issue.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/90a32eff-32c0-4d6d-a822-e843bbc5b31an%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/CA%2B8p0G2tm0x9GxKUuy95JGS8HZQOqR3K3qmxwZ8Hxty0m-F9VA%40mail.gmail.com.


Re: [go-nuts] Upgrade to Go1.16 from Go1.14 broke my query

2021-06-25 Thread Roland Müller
Hello,

Am Do., 24. Juni 2021 um 18:14 Uhr schrieb Hugh Myrie :

> I recently updated my Go version to 1.16 and for all my queries I now get
> an error:
>
> {"error":"Dynamic SQL Error\nSQL error code = -303\narithmetic exception,
> numeric overflow, or string truncation\nstring right truncation\n"}
>
> I'm using  the package:   _ "github.com/nakagami/firebirdsql"
>
> The following is a simple function:
>
> func getSystem(w http.ResponseWriter, r *http.Request) {
> type system struct {
> Tax1float64  `json:"tax1"`
> Fees1  float64  `json:"fees1"`
> Fees2   float64  `json:"fees2"`
> Minus_stk string `json:"minus_stk"`
> Discount1 float64 `json:"discount1"`
> Discount2 float64 `json:"discount2"`
> Discount3 float64 `json:"discount3"`
> Discount4 float64 `json:"discount4"`
> Elderly float64 `json:"elderly"`
> Message NullString `json:"message"`
> Binary4 NullString `json:"binary4"`
> }
> sysdata := []system{}
> sql2 := "select tax1, fees1, fees2, minus_stk, discount1, discount2,
> discount3, discount4, elderly, cast(mesg as varchar(400)), binary4 from
> system"
> conn, _ := sql.Open("firebirdsql",  datapath)
> defer conn.Close()
> rows, err := conn.Query(sql2)
> if err != nil {
> respondWithError(w, http.StatusBadRequest, err.Error())
> return
> }
> defer rows.Close()
> for rows.Next() {
> var p system
> err := rows.Scan(, , , _stk, ,
> , , , , ,
> )
> if err != nil {
> respondWithError(w, http.StatusBadRequest, err.Error())
> return
> }
> sysdata = append(sysdata, p)
> }
> err = rows.Err()  //  <--- errors seem to thrown here.
> if err != nil {
> respondWithError(w, http.StatusBadRequest, err.Error())
> return
> }
> respondWithJSON(w, http.StatusOK, sysdata)
> }
>
> Your help would be appreciated.
>
> I'm using Firebird 2.5. Everything worked under the previous version of
> Go. I am scanning for null values so I don't believe that is the issue.
>
> ust a wild guess not "biased" by any close knowledge of Firebird DB or the
above mentioned Go module: there has something changed with handling of
rows.Next() when the last row of data has been passed. This guess is based
on the fact that your mark the error only occurs after reading all data
rows.

I would try to log a warning to server log and try to return the JSON data
instead of returning http.StatusBadRequest. It may be that the data is
valid.

BR,
Roland

-- 
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/CA%2B8p0G0RaDFSysB6RXTj0DP4MQQKuvO82boU64%3D-LAgKUeYeCQ%40mail.gmail.com.


Re: [go-nuts] Understanding how []byte("astring") works

2021-06-13 Thread Roland Müller
Hello,

Am Mo., 14. Juni 2021 um 03:24 Uhr schrieb Amit Saha :

> Hi - My main motivation to understand this is i always had to google
> this - how to convert a string to a byte slice.
>
> Is []byte a type that has been defined in the compiler?
>
> Or, is that an internal level detail that an earlier stage (parsing)
> takes care of when the compiler sees that statement?
>
> Thanks,
> Amit
>
>
a []byte is a sequence of octets and strings in Go consistent of a bytes.
These bytes represent an sequence of unicode characters according to UTF-8.
One such character consists of either a single or two bytes. ASCII -only
strings than have as many bytes as UTF characters.

In the example I made two loop functions loopStringByBytes(s)
and loopStringByChars(s) and checked them against a ASCII string and a
cyrillic string. You can see that for second string every character
occupies 2 bytes.

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


BR,
Roland



> --
> 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/CANODV3nBYmshDLFwUUdnnyVuvpjhWnwBJOb%3DwrZKEHXmtBgbSg%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/CA%2B8p0G1_iVNyc4MQ_RDFigDRRNVqGzLX_b0E3YSdPXeYbuWZXw%40mail.gmail.com.


Re: [go-nuts] gonum plot : font error

2021-05-18 Thread Roland Müller
Hello,

applying Carlas's solution I got a failure in line 20 since plot.New()
returns a pointer but no pointer, error pair.

Only after changing usage of New() I got the scatter-demo running. May be
error message can be enhanced :-)

scatter-demo]$ go build

# scatter-demo
./main.go:20:9: assignment mismatch: 2 variables but plot.New returns 1
values

 20 p := plot.New() 21 if p == nil { 22 panic("Plotter
cannot be created") 23 }


BR,
Roland


Am Mo., 17. Mai 2021 um 16:38 Uhr schrieb Fred :

> Thanks Carla and Sébastien for your quick answer !
>
> Carla your solution works, when I use modules I do not have font errors.
>
> What is strange is that I was not using modules in any computer to try
> this example and it was working in one an not the other :)
>
> Le lundi 17 mai 2021 à 15:10:55 UTC+2, Sebastien Binet a écrit :
>
>> Salut Fred,
>>
>> On Mon May 17, 2021 at 14:11 CET, Fred wrote:
>> > Hi,
>> > I have 2 computers with Linux Manjaro and go version 1.16.3.
>> > The same scatter plot
>> > 
>> works
>> > on
>> > one computer and produces on the other these already known errors :
>> > 
>> >
>> > # gonum.org/v1/plot/text
>> > /home/fred/GO/src/gonum.org/v1/plot/text/latex.go:153:3: cannot use
>> > hdlr.Fonts.Lookup(rm, fnt.Size).Face (type *sfnt.Font) as type
>> > *truetype.Font in field value
>> > /home/fred/GO/src/gonum.org/v1/plot/text/latex.go:154:3: cannot use
>> > hdlr.Fonts.Lookup(rm, fnt.Size).Face (type *sfnt.Font) as type
>> > *truetype.Font in field value
>> > /home/fred/GO/src/gonum.org/v1/plot/text/latex.go:155:3: cannot use
>> > hdlr.Fonts.Lookup(it, fnt.Size).Face (type *sfnt.Font) as type
>> > *truetype.Font in field value
>> > /home/fred/GO/src/gonum.org/v1/plot/text/latex.go:156:3: cannot use
>> > hdlr.Fonts.Lookup(bf, fnt.Size).Face (type *sfnt.Font) as type
>> > *truetype.Font in field value
>> > /home/fred/GO/src/gonum.org/v1/plot/text/latex.go:157:3: cannot use
>> > hdlr.Fonts.Lookup(bfit, fnt.Size).Face (type *sfnt.Font) as type
>> > *truetype.Font in field value
>> > /home/fred/GO/src/gonum.org/v1/plot/text/latex.go:221:3: cannot use
>> > op.Glyph.Font (type *truetype.Font) as type *sfnt.Font in field value
>>
>> this should indeed be fixed w/ gonum/pl...@v0.9.0.
>>
>> >
>> > an update does not fix the error.
>> >
>> > go get -u gonum.org/v1/plot/...
>> > # cd /home/fred/GO/src/github.com/go-latex/latex; git pull --ff-only
>> > Votre information de configuration indique de fusionner avec la
>> > référence
>> > 'refs/heads/master'
>> > du serveur distant, mais cette référence n'a pas été récupérée.
>> > package github.com/go-latex/latex/drawtex: exit status 1
>>
>> this error may come from the fact that go-latex/latex is now using
>> 'main' as its main branch in lieu of 'master'.
>>
>> hth,
>> -s
>>
> --
> 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/efb3fb0c-cbeb-4815-a0d9-ee7a4b638ad8n%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/CA%2B8p0G04%2B_HsOaNtojqWsy8gLpQfFa%3DKe9%3DyZ_RRnAMOpBSLmg%40mail.gmail.com.


Re: [go-nuts] json objects

2021-01-01 Thread Roland Müller
To have a JSon format with lower-case field names one has to (1) use field
names beginning with upper case - to enable export and (2) use json
annotations to force a field name.
Just have a look at the following example:
https://gobyexample.com/json  


Am Sa., 26. Dez. 2020 um 01:30 Uhr schrieb Amit Saha :

>
>
> On Sat, 26 Dec 2020, 10:25 am Hamsa Hesham, 
> wrote:
>
>> package main
>> import "encoding/json"
>> import "log"
>> import "fmt"
>>
>> type book struct {
>> IDint
>> title string
>> pubDate   string
>> authorstring
>> genre string
>> publisher string
>> language  string
>> }
>> func main(){
>> b := book{
>> ID:1,
>> title:   "Standard",
>> pubDate:  "Standard",
>> author: "Second-rate",
>> genre: "Standard",
>> publisher: "Standard",
>> language: "Standard",
>> }
>>
>> var jsonData []byte
>> jsonData, err := json.Marshal(b)
>> if err != nil {
>> log.Println(err)
>> }
>> fmt.Println(string(jsonData))
>>
>> }
>>
>> The output is {"ID":1}  .. why?!!
>>
>
> Your struct fields will need to start with a capital letter to be
> exportable into JSON. Since ID is the only field here, you only see that in
> your output.
>
>
> --
>> 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/44b561be-30eb-48cb-ae0c-5d56f09e1c2cn%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/CANODV3krc-uo7FO%2BpFnmqYaBdiD4C1wPeFxo6NW_mt96Vt8gqQ%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/CA%2B8p0G0tNU5uHgXbaxT%3DYSXkVvsFj_KY0C5dU85gXfaRqf52jA%40mail.gmail.com.


Re: [go-nuts] Positional arguments and flag package

2020-10-15 Thread Roland Müller
I guess it's usage of flag is meant in to behave like parsing flags in
Unix/LInux, or Python' argparse:

   - after the command you have the flags denoted by '-'
   - after flags follow rest of command line args where elements can be
   every character string

BR,
Roland

Am Fr., 9. Okt. 2020 um 07:10 Uhr schrieb Amit Saha :

> Hi all, I realize that the flag package stops parsing os.Args[] once it
> finds a non "-" character. This means, if I invoke my program as:
>
> $ ./myprog arg1 -d value
>
> flag.Parse() will stop parsing the moment it sees arg1 and result in
> NArg() returning 2 instead of 1.
>
> Is there a recommended workaround to handle both $./myprog -d value arg1
> and $./myprog arg1 -d value correctly?
>
> Thanks for any suggestions.
>
> Thanks,
> Amit.
>
> --
> 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/d1399079-4589-454f-91d3-820a60aa239dn%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/CA%2B8p0G1EdVcShAPDHGp-abCKFwUvLpLEiNUV9Owy03G1m3aSEA%40mail.gmail.com.


Re: [go-nuts] Positional arguments and flag package

2020-10-15 Thread Roland Müller
Actually, it's explicitly documented, so I don't have to guess:
https://golang.org/pkg/flag/#hdr-Command_line_flag_syntax


Am Do., 15. Okt. 2020 um 08:22 Uhr schrieb Roland Müller :

> I guess it's usage of flag is meant in to behave like parsing flags in
> Unix/LInux, or Python' argparse:
>
>- after the command you have the flags denoted by '-'
>- after flags follow rest of command line args where elements can be
>every character string
>
> BR,
> Roland
>
> Am Fr., 9. Okt. 2020 um 07:10 Uhr schrieb Amit Saha  >:
>
>> Hi all, I realize that the flag package stops parsing os.Args[] once it
>> finds a non "-" character. This means, if I invoke my program as:
>>
>> $ ./myprog arg1 -d value
>>
>> flag.Parse() will stop parsing the moment it sees arg1 and result in
>> NArg() returning 2 instead of 1.
>>
>> Is there a recommended workaround to handle both $./myprog -d value arg1
>> and $./myprog arg1 -d value correctly?
>>
>> Thanks for any suggestions.
>>
>> Thanks,
>> Amit.
>>
>> --
>> 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/d1399079-4589-454f-91d3-820a60aa239dn%40googlegroups.com
>> <https://groups.google.com/d/msgid/golang-nuts/d1399079-4589-454f-91d3-820a60aa239dn%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

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