Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the path 21_interfaces/04_method-sets/04_pointer-receiver_value-type/main.go coding is error #76

Open
Toin1779712664 opened this issue May 14, 2024 · 1 comment

Comments

@Toin1779712664
Copy link

the path 21_interfaces/04_method-sets/04_pointer-receiver_value-type/main.go coding is error

@Toin1779712664
Copy link
Author

Toin1779712664 commented May 14, 2024

package main

import (
	"fmt"
	"math"
)

type circle struct {
	radius float64
}

type shape interface {
	area() float64
}

func (c *circle) area() float64 {
	return math.Pi * c.radius * c.radius
}

func info(s shape) {
	fmt.Println("area", s.area())
}

func main() {
	c := circle{5}    // this is error
        /*
             c:=&circle{5}
             or
             info(&c)
       */
	info(c)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant