Re: [go-nuts] Build problems with modules in Docker

2019-04-04 Thread Marcus Franke
Hello,

On Wed, Apr 3, 2019 at 3:49 PM David Riley  wrote:

> A few things. Responses inline.
>

Will answer inline aswell

>
> > I have a Makefile does some simple tasks for building, it creates a
> tarball of my code directory and starts a docker build -t  job.
>
> Why make a tarball? You'll get a lot more mileage out of just copying the
> files from the Docker context, which Docker is already tarring up to pass
> around anyway.  You'll get fewer surprises that way.
>

To be honest I failed to test COPY and realize it does a recursive copy of
all files and subdirectories to the image layer.


> In our Dockerfiles, we generally have the following as preamble (we also
> add some non-root permissioning, which is more complex than you really need
> right now):
>
> # Provide arguments for the module name (required) and the
> # optional module proxy for hermetic builds
> ARG MOD_NAME=modname
> ARG GOPROXY
> ENV GOPROXY ${GOPROXY}
>
> # Set a variable for our working directory (make sure it matches
> # the module name)
> ENV D $HOME/build/$MOD_NAME
> RUN mkdir -p $D
> WORKDIR $D
>
> # Copy go.sum/go.mod and warm up the module cache (so that this
> # rather long step can be cached if go.mod/go.sum don't change)
> COPY go.* $D/
> CMD go mod download
>

I think this is a quite clever solution, to put the dependency download in
its own layer. Added it directly to my Dockerfile.
Just the CMD for the `go mod download` must be a RUN, otherwise it does not
downlad but prepares that other kind of entrypoint.

> RUN cd cmd/asm
>
> This doesn't doo what you think it does; it does not change the working
> directory.  For that, you want the WORKDIR directive. However...
>
> >
> > Why does the go tool try to kind of resolve the import path of my
> project itself? I thought this would be defined by the module directive in
> my go.mod file, at the source root of my project directory?
>
> It is, the Go tool generally uses that to specify where the package
> "lives" if it's working properly. This looks to me almost like it's not
> seeing go.mod correctly.
>

The error is, as stated above and by Tamás, that my `RUN cd .. ` did not
enter the directory with my main.go file.

In fact, the compiler finds my go.mod and go.sum files and starts the
download and then something strange happens. It does not find any *.go
files as there are none in the top level directory and the message I get
with "can't load package .." is the error message for not finding anything
it could compile. I get this error on my local box as well as soon as I try
to `go build` inside the same root directory.

Now, looking back at yesterday, I understand what confused me the most.

Inside my $GOPATH the error message is quite similar but a bit more
distinct:
can't load package: package github.com/Comradin/go-experiments: no Go files
in /Users/marcus/go/src/github.com/Comradin/go-experiments

`no Go files`, but in the module directory this changes to `unknown import
path`


Many thanks, I raised a level of experience and everything builds just fine
now,
Marcus

-- 
pedo mellon a minno

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


[go-nuts] Build problems with modules in Docker

2019-04-03 Thread Marcus Franke
Hello,

I have a small project here at work, that does not compile using modules
inside the golang docker image.

The software resides inside a rather monorepo like repository inside the
organizations private repository at github. So far, a great place for the
modules, as I can develop the software outside my GOPATH and building it on
my machine works great.

My code resides inside this private repository inside an arbitrary path,
which is not fully part of the name I initiated the module with. Which does
not impose a problem when building on my laptop.

My go.mod file looks like this:
```
module github.com/org/repo/asm

go 1.12

require (
github.com/aws/aws-sdk-go v1.19.5
github.com/kr/pretty v0.1.0
github.com/stretchr/testify v1.3.0 // indirect
golang.org/x/net v0.0.0-20190327091125-710a502c58a2 // indirect
gopkg.in/yaml.v2 v2.2.2
)
```

I have a Makefile does some simple tasks for building, it creates a tarball
of my code directory and starts a docker build -t  job.

My simplified Dockerfile:
```
FROM golang:1.12
ENV GO111MODULE=on
CMD mkdir asm
WORKDIR /go/asm
ADD code.tar .
CMD tar xvf code.tar
RUN cd cmd/asm
RUN go build -o asm
```

When I execute the build, I get the following error output:
```
Step 10/10 : RUN go build -o asm
 ---> Running in 243e73e7ed25
go: finding github.com/stretchr/testify v1.3.0
go: finding github.com/kr/pretty v0.1.0
go: finding github.com/aws/aws-sdk-go v1.19.5
go: finding gopkg.in/yaml.v2 v2.2.2
go: finding golang.org/x/net v0.0.0-20190327091125-710a502c58a2
go: finding github.com/kr/text v0.1.0
go: finding github.com/davecgh/go-spew v1.1.0
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding github.com/stretchr/objx v0.1.0
go: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: finding golang.org/x/text v0.3.0
go: finding github.com/kr/pty v1.1.1
go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
go: finding github.com/jmespath/go-jmespath
v0.0.0-20180206201540-c2b33e8439af
can't load package: package github.com/org/repo/asm: unknown import path "
github.com/org/repo/asm": cannot find module providing package
github.com/org/repo/asm
The command '/bin/sh -c go build -o asm' returned a non-zero code: 1
```

Why does the go tool try to kind of resolve the import path of my project
itself? I thought this would be defined by the module directive in my
go.mod file, at the source root of my project directory?

My repository contains two internal packages below a pkg/ directory and
these are being imported just fine with "github.com/org/repo/asm/pkg/foo"
and "github.com/org/repo/asm/pkg/bar" in my code. On my laptop the compiler
can, as written above, compile the project just fine. Here it seems it does
not fumble with finding that particular and rather virtual module name.

Am I doing something wrong or did I just misunderstand the way modules work?


Kind and puzzled regards,
Marcus

-- 
pedo mellon a minno

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


Re: [go-nuts] Re: Reading os.Stdin, Unbuffered

2017-11-28 Thread Marcus Franke
Hi,

Looking at the repository I see there are termios_darwin_amd64,
termios_freebsd_amd64, and termios_linux_amd64 files.

That package has code for these three operating systems, but no windows
support.

A terminal on a different OS isn't as standardized as you seem to assume.

Robert Solomon  schrieb am Mi., 29. Nov. 2017, 02:03:

> I trying to learn how to use pseudo-terminal-go.  It works fine under
> Ubuntu 16.04 amd64.  But not fine on win10 64 bit.
>
> go get github.com/carmark/pseudo-terminal-go/terminal
>
> #github.com/carmark/pseudo-terminal-go/terminal
> github.com\carmark\pseudo-terminal-go\terminal\terminal.go:715:15:
> Undefined State
> github.com\carmark\pseudo-terminal-go\terminal\terminal.go:719:2::
> Undefined Restore
> github.com\carmark\pseudo-terminal-go\terminal\terminal.go:724:18:
> Undefined MakeRaw
>
> I tried it with the -u flag also and got the same result.  And it doesn't
> matter if I use \ or / on that command line.
>
> I also use github's termbox-go on this win10 box, and that works fine.
>
> What's up?
>
> --rob solomon
>
>
> On Monday, November 27, 2017 at 9:59:52 AM UTC-5, dc0d wrote:
>>
>> Is there a way to read from `os.Stdin` in an unbuffered way? (Not waiting
>> for a `\n` or anything).
>>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [go-nuts] Re: ssh access

2017-11-28 Thread Marcus Franke
Hi,

When you get the password dialog, your connection was made without the ssh
key.

You will need both versions of your private key. The putty ppk file for
putty and the openssh one for your program.

Btw, you could install something like the git bash shell on your windows
system, this contains a ssh client that works with the openssh version of
your key.

tactician  schrieb am Di., 28. Nov. 2017,
20:48:

> Alexei, converted key to openssh, but when I tried to access my ubuntu
> server I was asked for a password, wg=hich I do not have - just passphrase.
> So not sure openssh key will do it for me.
>
>
> On Tuesday, 28 November 2017 15:19:44 UTC, tactician wrote:
>
>> Hi, am trying to access a ubuntu server running Go from a windows
>> machine. My ubuntu access is via a PuTTy  ssh-rsa private/public key. I am
>> now seeking to access my server from a Go program on windows. All attempts
>> to cobble together something using ssh that compiles have failed. Any
>> suggestions. I cannot change my server or client.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [go-nuts] How to Upload a file using angular4 for browsing and api created in golang?

2017-11-11 Thread Marcus Franke
>
> I am working on an application in which I need to upload a file using
> Golang and Angular 4.Suppose I have an input type file and an upload button
> on the screen. When I browse a file from my system and clicks upload
> button.Now following are my queries regarding file upload:
>
> 1. How will angular process the file at front end?
>

Why should your angular frontend process the file at all?

2. If it processes the file then what it will return to the rest api as
> data.
>

The easiest way, I guess, will be a simple form based upload. The file will
be uploaded to the endpoint you specify. Thats a POST action.

The handler responsible for the upload can copy the request body in a file
object and you are done.

```
r *http.Request
file, handler, err := r.FormFile("fileupload")
f, err := os.OpenFile(somePath+"/"+handler.Filename, os.O_WRONLY|os.O_CREATE
, 0644)
_, err = io.Copy(f, file)
```

4. Can file be uploaded via angular script and it will give download url to
> rest api?
>

Its upon your code what you write into the response. Of course could you
return the file location where you did save the file.

5. The uploaded file should not be executable.
>

Look at the flags I set in os.Open(). There you control if a file will be
executable or not. But that is only relevant for the server you save your
files.

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


Re: [go-nuts] Problems with regexp

2017-08-30 Thread Marcus Franke
On Mon, Aug 28, 2017 at 07:37:52PM -0700, Hugh S. Myers wrote:
> (.*) is greedy… try ([^\[]+) this should consume all till it runs into the
> open bracket, your next group…

There is this nice webpage https://regex101.com

It supports golang as regex flavor, and does a great job at
explaining the capture groups. I use that one all the time to
test my regular expressions.

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


Re: [go-nuts] Re: Go UDP performance

2017-02-21 Thread Marcus Franke
Hi,
an additional note, don't forget to monitor the netstat udp counter on both
servers.

% netstat -auns | grep -A 7 "Udp:"
Udp:
9381 packets received
0 packets to unknown port received
0 packet receive errors
1009 packets sent
0 receive buffer errors
0 send buffer errors
IgnoredMulti: 1264

Maybe your client is dropping the packets and it is not your sender.



Rich  schrieb am Di., 21. Feb. 2017 um 03:16 Uhr:

> I would wireshark the data coming in to both sides so that you can see
> when the packet was transmitted, and when it was received by the other
> side. That way you can isolate if it's network or Go.
>
>
> On Monday, February 20, 2017 at 4:02:28 PM UTC-5, Tharaneedharan
> Vilwanathan wrote:
>
> Hi All,
>
> I am trying to send a lot of UDP packets from Go code but I realized UDP
> performance is too low. The max I was able to do is about 160Mbps. This is
> in Ubuntu 16.10 on x86_64 (i7-6700HQ).
>
> I tried to google on this and it looks like this is about the performance
> we can get. I am a bit surprised.
>
> Am I missing something? Any suggestions on how to improve the performance?
>
> Thanks
> dharani
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [go-nuts] Re: golang-beginners channel?

2017-01-05 Thread Marcus Franke
Hi,

You should join the gophers slack. There is a golang-newbies channel.



pacninja  schrieb am Do., 5. Jan. 2017, 16:28:

> I'm in if someone starts the channel.
>
>
> On Thursday, January 5, 2017 at 11:44:16 AM UTC+5:30, Jason E. Aten wrote:
>
> I noticed that rust has a rust-beginners irc channel. That seems like a
> very welcoming idea
>
>

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


Re: [go-nuts] Re: Chrome not accepting generate_cert.go self-signed SSL certificate

2016-12-29 Thread Marcus Franke
Chrome, like the other browsers use your systems certificate store. Just
import the root CA's certificate and you will have a valid chain of trust.

Darren Hoo  schrieb am Do., 29. Dez. 2016, 09:04:

> Try starting chrome from command line with option --ignore-certificate-errors
> ?
>
>
> On Friday, March 13, 2015 at 7:19:07 PM UTC+8, Alex wrote:
>
>
> I made a certificate with the generate_cert.go file in the http package,
> and it works fine on firefox, but chrome wont accept it (with no options to
> allow), and I cant find it in the certificates settings in chrome to
> manually allow the certificate either.
>
> I used the -ca=true flag when creating the certificate.
>
> Does anyone know if there is something I can modify when creating the
> certificate to make it work in chrome?
>
> Thanks,
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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