@ Louki Sumirniy
Slices are values AFAIK. There is no passby pointer.
And the point is, race detector does not flag anything:
https://play.golang.org/p/NC8mBwS1-0P
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group a
Regarding "Accept interfaces, return concrete types", how can it be applied
for structs that represent a payload/value?
For example in package first, logger is defined as:
type logger interface {
Debugf(template string, args ...interface{})
Errorf(template string, args ...interface{})
On Sat, Apr 21, 2018 at 1:52 PM Kaveh Shahbazian
wrote:
> Is there a way to actually achieve this?
>
Either change `second.cloner` to return an interface, or (IMO better) just
import `second`. I don't understand why you'd want to avoid that.
--
You received this message because you are subscri
var someInterfaceValue interface{}
switch {
case someInterfaceValue: // proposal: compile error: non-bool used as
condition
case someInterfaceValue == true: // OK
}
Sometimes carefulness is just not enough.
One may type a wrong variable as the case condition, or a incomplete
condition.
Why
How do you get golang on iOS?
On Friday, April 20, 2018 at 4:19:40 PM UTC-4, Haydon Ryan wrote:
>
> url := "https://google.com/";
> req, err := http.NewRequest("GET", url, nil)
> if err != nil {
> log.Fatal(err)
> fmt.Printf(err.Error())
> return
> }
> r
@Kaveh
Slices are values but they refer to the same back array location. You have
created localized v which is appended inside goroutine which refer to a
location containing its own byte array of len=10. So, you are not really
referencing the same memory location as other v slice in the gorouti
What did you do?
https://play.golang.org/p/aryK9Btv5kH
What did you expect to see?
There should be a error "declared and not used"
What did you see instead?
It seems work fine.
System details
```
go version go1.10.1 windows/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="C:\Users\zps
On Friday, April 20, 2018 at 4:19:40 PM UTC-4, Haydon Ryan wrote:
>
> url := "https://google.com/";
> req, err := http.NewRequest("GET", url, nil)
> if err != nil {
> log.Fatal(err)
> fmt.Printf(err.Error())
> return
> }
> res, err := http.DefaultClient
Unless you pass pointers in Go, every time you hop in and out of a new
scope any changes are discarded. This is why unless you type-bind with
pointers you don't actually have an OOP method, as the function will not
act upon the parent variable/structure.
I think if you change your playground co
On Sat, Apr 21, 2018 at 3:30 PM wrote:
> Why is this special? Because it's commonly used.
Is it? I don't think I ever used an interface value in a switch.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop r
On Sat, Apr 21, 2018 at 3:30 PM wrote:
How do you propose to formulate the exception to the existing rules?
Note that this is essentially the same "problem":
https://play.golang.org/p/vMc8hyQrigq
package main
import (
"fmt"
)
func main() {
var
@Ankit That's what I thought. Yet the code is accessing the same underlying
array. That is the part that worries me and -race does not complain.
@Louki Still no complain from -race! https://play.golang.org/p/dUt0QE63RDK
On Saturday, April 21, 2018 at 7:01:25 PM UTC+4:30, Louki Sumirniy wrote:
>
You might be right. Probably I am fixating on something that I do not
understand well and just have a not positive feeling about it. But two
things:
1 - Other packages (will) have implementations that satisfies first.cloner
so there might be:
type cloner interface {
Clone() (*third.State,
package main
import (
"fmt"
"log"
"strings"
"golang.org/x/net/html"
)
func main() {
const src = `
message
`
doc, err := html.Parse(strings.NewReader(src))
if err != nil {
log.Fatal(err)
}
var f func(*html.Node)
f = func(n *html.Node) {
if n.Type == html.ElementNode && n.Data == "img" {
for
I only just finally wrapped my head around this stuff and forgive me if I
have missed the point of the question but this is what my code has:
type AbstractType alias/struct {}
type abstractthing interface {
DoSomething(interface{})
}
func (a *AbstractType) DoSomething(b AbstractType) {
}
an
Your syntax is wrong. I think you mean this:
var someInterfaceValue interface{}
// do something that puts a value in above variable
switch someInterfaceValue {
case true:
// do something
default:
// do something else
}
On Saturday, 21 April 2018 16:30:22 UTC+3, b97...@gmail.com wrot
Hi Kaveh,
Change the line:
*ptr = append(*ptr, []byte(fmt.Sprint*f("%02d"*, k1))...)
to
*ptr = append(*ptr, []byte(fmt.Sprintf(*"%15d"*, k1))...)
The buckets will overlap (more than 10 bytes) and you will get the race
triggered in the detector
Silviu
On Saturday, 21 April 2018 12:40:04 UTC-4
I'm a new Go programmer (learning in my spare time) and decided to share my
initial fumbles and what? why? moments while they're still fresh.
First suggestion: allow a colon to be inserted between the name(s) and type
in declarations. For example
x : int
func random(): real
Back in th
18 matches
Mail list logo