How a get the values?

type Lock struct {
	User_key string
	Date           string
}

type Rules struct {
	Write float64
	Read  float64
	Lock  []Lock
}


temp.Read = rul.Read
temp.Write = rul.Write
temp.Lock = rul.Lock // <- this is []Lock

I give back from function

return &Rules{
		Write: temp.Write,
		Read:  temp.Read,
		Lock:  temp.Lock,
	}

The Write & Read -value get with

myreturn.Write
myreturn.Read

when I try a values from myreturn.Lock give me a failure

`
myreturn.Lock.User_key
`

How di I get the value from myreturn.Lock.User_key??

Hey @Moo,

If Lock is a slice you can not simply call myreturn.Lock.User_key.

You will need to index a specific Lock from the slice of Locks, for example: myreturn.Lock[0].User_key.

Thx it works!!!

I still have so my problem with slices, maps and array…

Glad to help!

That’s okay, you’ll get the hang of it the more you write programs with Go :slight_smile:
Feel free to ask a question anytime you get stuck anyway!

Who I do! This is the right place for help. :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.