On Sat, Sep 12, 2020 at 4:25 AM 'Axel Wagner' via golang-nuts <
golang-nuts@googlegroups.com> wrote:
> Hi y'all,
>
> given that the concern here seems to be performance (though, TBH, I doubt
> this particular case is much of a bottleneck), this seems to be far simpler
> to address as a compiler
Hi y'all,
given that the concern here seems to be performance (though, TBH, I doubt
this particular case is much of a bottleneck), this seems to be far simpler
to address as a compiler optimization - if the compiler can prove there are
no other references to a `[]byte`, it can do the conversion
There is a prerequisite to transfer ownership: it must be proved that
no other values share ownership of the byte slice returned by
ioutil.ReadFile.
On Saturday, September 12, 2020 at 3:42:14 AM UTC-4 tapi...@gmail.com wrote:
> Is it good to introduce owner transfer based string<->[]byte
Is it good to introduce owner transfer based string<->[]byte conversions?
After the conversion, the being converted string/[]byte values mustn't be
used any more.
Such as
tlsCertData, _ = ioutil.ReadFile("/etc/ssl/mycert")
var tlsCert string = bultin.ByteSlice2String(tlsCertData)
// forbid
On 2020-09-11 19:08, Ian Lance Taylor wrote:
> The way Go works, ioutil.ReadFile is compiled with the io/ioutil
> package. It can't change based on how it is called. So it is always
> going to return []byte.
Ok. I figured it might save an allocation as well if the coder made clear their
On Fri, Sep 11, 2020 at 9:45 AM Kevin Chadwick wrote:
>
> I apologise if this has already been discussed. Google didn't turn up anything
> directly related.
>
> If you read a file using the following that returns a byte slice.
>
> tlsCertb, err := ioutil.ReadFile("/etc/ssl/mycert")
> if err !=
I apologise if this has already been discussed. Google didn't turn up anything
directly related.
If you read a file using the following that returns a byte slice.
tlsCertb, err := ioutil.ReadFile("/etc/ssl/mycert")
if err != nil {
log.Fatal(err)
}
tlsCert = string(tlsCertb)
Is there a way to