interface-package

command
v0.0.0-...-cf25b83 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2021 License: MIT Imports: 1 Imported by: 0

README

interface-package example

The same example as the previous example but the interface and methods placed in a package.

This example is based on the previous example interface.

GitHub Webpage

THE BOTTOM LINE

This is exactly the same as the previous example except I am using a package. This makes the beauty of the interface come out, since we just make the interface and use the interface. Everything is hidden in the package except for the following,

  • type MyInterfacer interface {
  • func MakemyStructA(name string) MyInterfacer {
  • func MakemyStructB(x, y int) MyInterfacer {
  • func Magic(i MyInterfacer) {

As you can see it makes things easy.

I did add one thing, the ability to update the data for StructA.

  • func UpdateName(i MyInterfacer, name string) {

RUN

go run interface-package.go

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL