Assign new values later to the underlying object of the interface in go
The interface variable s contains a copy of the shape value. To modify it like you attempted to do, it has to contain a pointer to that shape:
var s Shape
c := Circle{Radius: 0, Name: "My Circle"}
s = &c

and in the function modifying them, you have to type-assert the pointer value:
func assignRadius(s Shape, radius float64, name string) {
    switch s := s.(type) {
    case *Circle:
        s.Radius = radius
        s.Name = name
    case *Rectangle:
        s.Length = radius
        s.Name = name
    }




I am trying to assign new values to the underlying structure of an interface in code below. But it keeps the older values. Below is the example code.
package main

import (
    "fmt"
    "math"
)

type Shape interface {
    Area() float64
}

type Circle struct {
    Radius float64
    Name   string
}

func (c Circle) Area() float64 {
    return math.Pi * c.Radius * c.Radius
}

type Rectangle struct {
    Length float64
    Width  float64
    Name   string
}

func (r Rectangle) Area() float64 {
    return r.Length * r.Width
}

func assignRadius(s Shape, radius float64, name string) {
    switch s := s.(type) {
    case Circle:
        s.Radius = radius
        s.Name = name
    case Rectangle:
        s.Length = radius
        s.Name = name
    }
}

func main() {
    var s Shape
    c := Circle{Radius: 0, Name: "My Circle"}
    s = c
    fmt.Println(s.Area())
    fmt.Println(c.Radius)
    fmt.Println(c.Name)
    assignRadius(s, 10, "My New Circle")
    fmt.Println(c.Radius)
    fmt.Println(c.Name)
}

The type of Shape isn't known beforehand in the assignRadius. I know it has something to do with the pointers. But can't figure it out.
