Re: [go-nuts] developing local packages with modules

2020-06-07 Thread 'Michael Stiller' via golang-nuts
Hi,

if the you want to use is on the local system you can add something like this 
to the go.mod file:

replace github.com/yourrepo/module  => ../pkg/module

See also here:

https://thewebivore.com/using-replace-in-go-mod-to-point-to-your-local-module/

and here:

https://starkandwayne.com/blog/switching-to-go-modules/

Best regards,

Michael


> On 7. Jun 2020, at 15:20, Erwin Driessens  wrote:
> 
> Hello people
> i have always found modules very scary and complicated but now there seems to 
> be no way round any longer.
> I have a lot of packages that i do now want to put in repositories. I want 
> them to be locally accessible, without internet access. 
> Everything always worked great for me with the old GOPATH setup. 
> Yesterday i installed go 1.14 on a new machine, and thought, ok lets try the 
> modules. I followed "How to write Go code" (https://golang.org/doc/code.html) 
> and was happy to read the following:
> "
> Note that you don't need to publish your code to a remote repository before 
> you can build it. A module can be defined locally without belonging to a 
> repository. However, it's a good habit to organize your code as if you will 
> publish it someday.
> "
> I did indeed get the hello module to work well.
> 
> However, my next quest was to import the hello/morestrings package in another 
> module and use it there. I can get it to work :(
> Does anyone know of a good document/wiki/tutorial about developing go code 
> that is not on remote repositories?  Go was great but now i feel totally 
> handicapped...
> 
>  
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google 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/186c785e-f328-439b-a8e5-87f6f0faba90o%40googlegroups.com.

-- 
2scale GmbH, Schanzenstr. 20, 40549 Düsseldorf
Amtsgericht:Düsseldorf HRB 50718
Geschäftsführer:Georg von Zezschwitz, Dirk Vleugels
USt-IdNr.:  DE 210936505





-- 
You received this message because you are subscribed to the Google 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/DE42BBA0-5C6E-494E-AEAF-77FCECD2028B%402scale.net.


Re: [go-nuts] tail -F with cmd.StdoutPipe, tail blocks in write

2020-05-16 Thread 'Michael Stiller' via golang-nuts
>> 
>> tail is from coreutils 8.25-2ubuntu3~16.04, kernel 4.4.0-1083-aws
>> 
>> It looks like i cannot read lines that way and tail is blocking in write(1, 
>> ...
> 
> Running "tail -F" never terminates.  That's how it works.  Your call
> to Wait will never complete.

Hi Ian,

of course you are correct and this is expected. 

> 
> I don't understand what else is going wrong.  Sorry if I missed it.

I continued debugging and it turned out, that in fact it did read lines from 
tail correctly,
but some other part in the program which worked with the read lines blocked due 
to a misbehaving
rabbitmq. But thanks for looking!

Best regards,

Michael

-- 
2scale GmbH, Schanzenstr. 20, 40549 Düsseldorf
Amtsgericht:Düsseldorf HRB 50718
Geschäftsführer:Georg von Zezschwitz, Dirk Vleugels
USt-IdNr.:  DE 210936505





-- 
You received this message because you are subscribed to the Google 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/590865DE-61FE-40FA-A401-741DB7A1AB2C%402scale.net.


[go-nuts] tail -F with cmd.StdoutPipe, tail blocks in write

2020-05-16 Thread 'Michael Stiller' via golang-nuts
Hi,

i try to read tailed lines of a logfile using this approach:

if env.TailEnabled {
   log.Println("setup tail command")
   cmd := exec.Command("/usr/bin/tail", "-F", "logfile.log")
   log.Println("setup tail pipe")
   tailPipe, err := cmd.StdoutPipe()
   if err != nil {
  log.Fatalln("could not open stdin pipe from tail:", err)
   }
   log.Println("starting tail pipe scanner")

   scanner = bufio.NewScanner(tailPipe)

   go func() {
  log.Println("starting tail command")
  err = cmd.Start()

  if err != nil {
 log.Fatalln("could not start tail:", err)
  }
  log.Println("tail pid:", cmd.Process.Pid)
  log.Println("waiting for tail to exit")
  err = cmd.Wait()
   }()
}
log.Println("starting scanner")
for scanner.Scan() {
   data := scanner.Bytes()
   …
}

Output:

2020/05/16 11:21:11 setup tail command
2020/05/16 11:21:11 setup tail pipe
2020/05/16 11:21:11 starting tail pipe scanner
2020/05/16 11:21:11 rate limiter: &{limit:3000 burst:100 mu:{state:0 sema:0} 
tokens:0 last:{wall:0 ext:0 loc:} lastEvent:{wall:0 ext:0 loc:}}
2020/05/16 11:21:11 starting scanner
2020/05/16 11:21:11 starting tail command
2020/05/16 11:21:11 tail pid: 30823
2020/05/16 11:21:11 waiting for tail to exit
… nothing more

tail is from coreutils 8.25-2ubuntu3~16.04, kernel 4.4.0-1083-aws

It looks like i cannot read lines that way and tail is blocking in write(1, ...

according to strace. 

Lsof of tail:

COMMAND   PID USER   FD  TYPE DEVICESIZE/OFF  NODE NAME
tail30693 root  cwd   DIR  202,14096410091 
tail30693 root  rtd   DIR  202,14096 2 /
tail30693 root  txt   REG  202,1   64432  9792 /usr/bin/tail
tail30693 root  mem   REG  202,1 1868984395274 
/lib/x86_64-linux-gnu/libc-2.23.so
tail30693 root  mem   REG  202,1  162632395259 
/lib/x86_64-linux-gnu/ld-2.23.so
tail30693 root0r  CHR1,3 0t0 6 /dev/null
tail30693 root1w FIFO   0,10 0t0 273545577 pipe
tail30693 root2w  CHR1,3 0t0 6 /dev/null
tail30693 root3r  REG  251,0 14629013611   3276805 /logfile.log
tail30693 root4r  a_inode   0,11   0  9126 inotify

Lsof of goprog:

COMMAND PID USER   FD  TYPEDEVICE SIZE/OFF  NODE NAME
goprog 30688 root  cwd   DIR 202,1 4096410091 /service/goprog
goprog 30688 root  rtd   DIR 202,1 4096 2 /
goprog 30688 root  txt   REG 202,1 17914743397448 
/service/goprog/goprog
goprog 30688 root0r  CHR   1,3  0t0 6 /dev/null
goprog 30688 root1w FIFO  0,10  0t0 273482973 pipe
goprog 30688 root2w FIFO  0,10  0t0 273482973 pipe
goprog 30688 root3u IPv4 273546843  0t0   TCP redacted
goprog 30688 root4u  a_inode  0,110  9126 [eventpoll]
goprog 30688 root5r FIFO  0,10  0t0 273549055 pipe
goprog 30688 root6w FIFO  0,10  0t0 273549055 pipe
goprog 30688 root7u IPv4 273550072  0t0   TCP redacted
goprog 30688 root8r FIFO  0,10  0t0 273545577 pipe
goprog 30688 root9u IPv6 273546849  0t0   TCP redacted
goprog 30688 root   14u IPv6 273549061  0t0   TCP *:9290 (LISTEN)

any clues?

Best regards,

Michael



-- 
You received this message because you are subscribed to the Google 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/FF3BB441-E4FE-4538-BFEA-94B10B448190%402scale.net.


Re: [go-nuts] link order in executable

2020-01-25 Thread 'Michael Stiller' via golang-nuts
Thank you Ian.

Best regards,

Michael


> On 24. Jan 2020, at 22:19, Ian Lance Taylor  wrote:
> 
> On Fri, Jan 24, 2020 at 1:10 PM 'Michael Stiller' via golang-nuts
>  wrote:
>> 
>> playing around with tamago i noticed that if i compile with this command:
>> 
>> GO_EXTLINK_ENABLED=0 CGO_ENABLED=0 GOOS=tamago GOARM=6 GOARCH=arm \
>>  ${TAMAGO} build -ldflags "-v -T 0x8000 -E _rt0_arm_tamago -R 0x1000" $@
>> 
>> The generated (elf) binary has the following symbols:
>> 
>> nm main | sort | head
>> 8000 T internal/cpu.Initialize
>> 8000 t runtime.text
>> 8144 T internal/cpu.processOptions
>> 87d4 T internal/cpu.indexByte
>> 8848 T type..hash.internal/cpu.CacheLinePad
>> 8858 T type..eq.internal/cpu.CacheLinePad
>> 8868 T type..hash.internal/cpu.arm
>> 88b0 T type..eq.internal/cpu.arm
>> 88ec T type..hash.internal/cpu.arm64
>> 8934 T type..eq.internal/cpu.arm64
>> 
>> What determines and is this configurable that internal/cpu.Initialize gets 
>> linked at 0x8000?
>> 
>> What i want to achieve is, that the -E entry symbol gets linked first at 
>> 0x8000.
> 
> Nothing in particular determines that that symbol is a 0x8000.  The -T
> option says that the text segment will start at 0x8000.  The Go linker
> doesn't have any support for ordering the symbols in the text segment.
> They just wind up being placed based on the order in which the linker
> processes its inputs, which is unpredictable and subject to change.
> 
> The -E option sets the value stored in the ELF ehdr's e_entry field.
> 
> 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/109F6334-906B-4E8E-B1B0-D24563A1CEF5%40ymail.com.


[go-nuts] link order in executable

2020-01-24 Thread 'Michael Stiller' via golang-nuts
Hi,

playing around with tamago i noticed that if i compile with this command:

GO_EXTLINK_ENABLED=0 CGO_ENABLED=0 GOOS=tamago GOARM=6 GOARCH=arm \
  ${TAMAGO} build -ldflags "-v -T 0x8000 -E _rt0_arm_tamago -R 0x1000" $@

The generated (elf) binary has the following symbols:

nm main | sort | head
8000 T internal/cpu.Initialize
8000 t runtime.text
8144 T internal/cpu.processOptions
87d4 T internal/cpu.indexByte
8848 T type..hash.internal/cpu.CacheLinePad
8858 T type..eq.internal/cpu.CacheLinePad
8868 T type..hash.internal/cpu.arm
88b0 T type..eq.internal/cpu.arm
88ec T type..hash.internal/cpu.arm64
8934 T type..eq.internal/cpu.arm64

What determines and is this configurable that internal/cpu.Initialize gets 
linked at 0x8000?

What i want to achieve is, that the -E entry symbol gets linked first at 0x8000.

Thanks.

Best regards,

Michael

-- 
You received this message because you are subscribed to the Google 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/95CFBC2D-40C9-47EA-8170-C839D88BCC2C%40ymail.com.


Re: [go-nuts] A question about performance when traverse the array with row-wise and column-wise

2019-09-29 Thread 'Michael Stiller' via golang-nuts
On my machine using an intel 9880H with a L2 Cache: Unified, 256 KiB, 4-way set 
associative,

rows vs. columns performance is basically the same as long as the array size 
fits into the L2 cache.

This seems to be the case for a rowSize = colSize = 180. For slightly higher 
values (190) the 
column bench gets slower as the row bench. 

If you print the array sizes using

fmt.Println("array size:", unsafe.Sizeof(array))

you get:

180: array size: 259200

190: array size: 288800

If log the array’s element addresses to the code like this:

for r := 0; r < rowSize; r++ {
   for c := 0; c < colSize; c++ {
  log.Printf("rows: %x", &array[r][c])
  sum += array[r][c]
   }
}

and 

for c := 0; c < colSize; c++ {
   for r := 0; r < rowSize; r++ {
  log.Printf("cols: %x", &array[r][c])
  sum += array[r][c]
   }
}

It seems that the “row method” looks more cache (line) friendly:

2019/09/29 17:33:59 rows: 1198400
2019/09/29 17:33:59 rows: 1198408
2019/09/29 17:33:59 rows: 1198410
2019/09/29 17:33:59 rows: 1198418
2019/09/29 17:33:59 rows: 1198420
2019/09/29 17:33:59 rows: 1198428
2019/09/29 17:33:59 rows: 1198430
…

2019/09/29 17:33:59 cols: 1198400
2019/09/29 17:33:59 cols: 1198450
2019/09/29 17:33:59 cols: 11984a0
2019/09/29 17:33:59 cols: 11984f0
2019/09/29 17:33:59 cols: 1198540
2019/09/29 17:33:59 cols: 1198590
2019/09/29 17:33:59 cols: 11985e0
2019/09/29 17:33:59 cols: 1198630
…

Cheers,

-Michael 


-- 
You received this message because you are subscribed to the Google 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/BCFF37EA-F36A-4202-93DF-8A46EF8DD28A%402scale.net.


Re: [go-nuts] sudo ./main command throwing error

2019-06-24 Thread &#x27;Michael Stiller&#x27; via golang-nuts
Hi,

i think sudo kills the LD_LIBRARY_PATH variable. 

But this is configurable, try something like:

Defaultsenv_keep += “LD_LIBRARY_PATH"

in /etc/sudoers and / or consult the sudo man page.

Best regards,

Michael


> On 24. Jun 2019, at 18:48, Nitish Saboo  wrote:
> 
> Hi ,
> 
> I am using cgo in this project where I need the following given .so files.
> After building the go code, I get the binary 'main'.
> 
> ubuntu@hexint09-ingest-0693b91d:/opt/tap-parsing/bin$ ls -lrt
> total 17000
> -rwxr-xr-x 1 parsing parsing 17405424 Jun 24 11:14 main
> 
> './main' works fine whereas 'sudo ./main' throws the following error:
> 
> ubuntu@hexint09-ingest-0693b91d:/opt/tap-parsing/bin$ sudo ./main
> ./main: error while loading shared libraries: libsyslog-ng-3.6.so.0: cannot 
> open shared object file: No such file or directory
> 
> Following is the LD_LIBRARY_PATH set to:
> --
> ubuntu@hexint09-ingest-0693b91d:/opt/tap-parsing/bin$ echo $LD_LIBRARY_PATH
>  
> /opt/tap-parsing/dep/syslog/syslog-ng-3.6.2/install/lib/syslog-ng:/opt/tap-parsing/dep/syslog/syslog-ng-3.6.2/install/lib
> 
> 
> ubuntu@hexint09-ingest-0693b91d:/opt/tap-parsing/bin$ cd 
> /opt/tap-parsing/dep/syslog/syslog-ng-3.6.2/install/lib/
> ubuntu@hexint09-ingest-0693b91d:/opt/tap-parsing/dep/syslog/syslog-ng-3.6.2/install/lib$
>  ls -lrt
> total 2544
> -rwxr-xr-x 1 parsing parsing 861259 Jun 24 11:14 libsyslog-ng.so
> -rwxr-xr-x 1 parsing parsing   1405 Jun 24 11:14 libsyslog-ng.la
> -rwxr-xr-x 1 parsing parsing 861259 Jun 24 11:14 libsyslog-ng-3.6.so.0.0.0
> -rwxr-xr-x 1 parsing parsing 861259 Jun 24 11:14 libsyslog-ng-3.6.so.0
> drwxr-xr-x 2 parsing parsing   4096 Jun 24 11:25 pkgconfig
> drwxr-xr-x 3 parsing parsing   4096 Jun 24 11:25 syslog-ng
> 
> Parsing user details:
> =
> 
> ubuntu@hexint09-ingest-0693b91d:~$ cat /etc/passwd | grep parsing
> parsing:x:1004:1006::/home/parsing:
> 
> ubuntu@hexint09-ingest-0693b91d:~$ cat /etc/group | grep parsing
> parsing:x:1006:
> 
> 
> makefile:
> ===
> 
> .PHONY: all clean
> 
> all: main
> 
> main:./lib/syslog-node.so main.go ./lib/syslog-node1.h
>   go build -v -x main.go
> 
> ./lib/syslog-node.so: ./lib/syslog-node.c ./lib/syslog-node1.h
>   gcc -L/usr/local/lib -lsyslog-ng -o ./lib/syslog-node.so 
> -L/usr/local/lib/syslog-ng -ldbparser -c `pkg-config --libs --cflags 
> glib-2.0` -I/usr/local/include/syslog-ng/ -I./lib/syslog-ng-3.6.2/ 
> -I/usr/local/include/eventlog/ ./lib/syslog-node.c
> 
> clean:
>   rm main
>   rm ./lib/syslog-node.so
> 
> 
> I understand I am missing a very small point here but couldn't just figure it 
> out.
> Can someone please guide me here ?
> 
> 
> Thanks,
> Ntiish
> 
> -- 
> You received this message because you are subscribed to the Google 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/3cc0a8f8-8b39-4948-9084-55a0b6628399%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
2scale GmbH, Schanzenstr. 20, 40549 Düsseldorf
Amtsgericht:Düsseldorf HRB 50718
Geschäftsführer:Georg von Zezschwitz, Dirk Vleugels
USt-IdNr.:  DE 210936505





-- 
You received this message because you are subscribed to the Google 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/E4EFBEC1-40E7-452F-B2BC-68BECE7C7AA0%402scale.net.
For more options, visit https://groups.google.com/d/optout.