Topics

[Edgex-devel] git, gofmt, and line endings

James.White2@...
 

Thanks for this Tony. It is hard to believe isn't it.

Let's discuss at the next meeting, but I believe per our previous Go build/CI discussions we are planning to automate the use gofmt in the build/CI. Need to check that with devops and work through the details with Jeremy, but definitely something we should keep on focus and look for an alternative if this does't pan out.
Jim
________________________________________
From: edgex-devel-bounces@... <edgex-devel-bounces@...> on behalf of espy <espy@...>
Sent: Tuesday, October 31, 2017 5:41 PM
To: edgex-golang@...; edgex-devel@...
Subject: [Edgex-devel] git, gofmt, and line endings

One of my first code contributions to EdgeX was a change to a Go package
(not yet public), and at the time I was surprised when reviewing the
diff to see "^M" characters at the ends of lines.

My subsequent Google search/investigation left me with a bit of
headache. Who could think that in 2017, we still have differing ways of
denoting line endings on different OSes?

The crux of the biscuit (as Frank Zappa would've said) is that Linux and
OS X/macOS use LF to terminate lines of text, whereas Windows uses CRLF.

There are various ways to deal with this problem, however after reading
multiple blog posts about this, it's still not super clear what our
recommended approach should be. For a good primer on the problem,
checkout [1] or [2].

It turns out that the Go community has gone a bit further than git
community, and mandated use of LF as it's standard. The gofmt tool will
automatically convert CRLFs to LFs, and there doesn't appear to be
anyway to disable this [3]. So, if we stand by our decision to always
use gofmt (which is standard practice in the Go community), then we all
need to be aware of the issue, and may have some short term pain
converting any code which originated on Windows.

I'd like to propose that we discuss this at the next core WG meeting, as
well as the next Go meeting.

Regards,
/tony

[1] http://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/
[2] https://help.github.com/articles/dealing-with-line-endings/
[3] https://github.com/golang/go/issues/2242
_______________________________________________
EdgeX-Devel mailing list
EdgeX-Devel@...
https://lists.edgexfoundry.org/mailman/listinfo/edgex-devel

espy
 

On 10/31/2017 10:39 PM, James.White2@... wrote:
Thanks for this Tony. It is hard to believe isn't it.
Let's discuss at the next meeting, but I believe per our previous Go build/CI discussions we are planning to automate the use gofmt in the build/CI.
Yes, we had agreed on that.

That said, it might be a good idea to run gofmt on all of the new Dell Go code before contributing it to github, otherwise we'll end up with failed builds from the get go. If you agree this is a good idea, I can certainly help with that effort.

/tony

James.White2@...
 

Agree Tony. I'll make sure our guys are doing that with the code before we submit to GitHub.
If we need assistance, I'll reach out.
________________________________________
From: espy <espy@...>
Sent: Wednesday, November 1, 2017 4:49 PM
To: White2, James; edgex-golang@...; edgex-devel@...
Subject: Re: [Edgex-devel] git, gofmt, and line endings

On 10/31/2017 10:39 PM, James.White2@... wrote:
Thanks for this Tony. It is hard to believe isn't it.

Let's discuss at the next meeting, but I believe per our previous Go build/CI discussions we are planning to automate the use gofmt in the build/CI.
Yes, we had agreed on that.

That said, it might be a good idea to run gofmt on all of the new Dell
Go code before contributing it to github, otherwise we'll end up with
failed builds from the get go. If you agree this is a good idea, I can
certainly help with that effort.

/tony