FAQ
Maybe this helps:
http://objectscape.blogspot.de/2013/09/inner-pattern-to-mimic-method.html

Am Dienstag, 23. Juni 2015 07:57:38 UTC+2 schrieb prajakta....@gmail.com:
I am trying to pass the parent struct type to a method

package main

import "fmt"

type Child struct {
Parent //embed
Attr string
}

type Parent struct {
Attr1 string
}

func setf(p Parent) {
fmt.Println(p)
}


func main() {
var ch Child
ch.Attr = "1"
ch.Attr1 = "2"

setf(ch) // This does not work - cannot use ch (type Child) as type
Parent in argument to setf
}

How do I resolve this problem?
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 8 of 9 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJun 23, '15 at 5:57a
activeJun 25, '15 at 8:32a
posts9
users6
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase