Skip to content

Property-Finder-Patika/week-1-homework-1-denizcamalan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

week-1-homework-1

Weekly Contents

  • Go Code Structure and Analysis
  • Global and Local Variables
  • Constants
  • Variables, Basic Data Types
  • Scope
  • Type Conversions

Chapter1

Main Properties

  • Automatic memory management via garbage collection
  • First-class functions
  • Lexical (static) scope
  • Standard library and APIs for basic structures such as collections (containers), networking, I/O, text processing, etc.
  • Go and all of its libraries and tools are open-source.
  • It is a compiled language

Object-Oriented Programming (OOP) in Go

  1. Struct
  • Go does not support custom types through classes but structs.
  1. Encapsulation
  • It means hiding sensitive data from users.

Note: if function/struct is public as it begins with a capital letter, else it begins with a lower case.

  1. Inheritance
  • subclass/child class are the terms used for the class which acquire properties in golang with struct.
  1. Interfaces
  • The interface is a custom type that is used to specify a set of one or more method signatures.By treating objects of different types in a consistent way, as long as they stick to one interface, Golang implements polymorphism.

Functional Programming in Go

Golang is not a functional language but has a lot of features that enable to turning our code more elegant, concise, maintainable, easier to understand and test.

  • Functions are first-class citizens.
  • Supports anonymous functions or closures.

CommandLine Arguments

  • os.Args is a slice of strings.

Lecture 1 Codes

Lecture Codes

Exercises

Chapter2

Names

  • Go programmers use "camel case" when forming names by combining words; that is, interior capital letters are preferred over interior underscores.

Declarations

  • Four major kinds of declarations: var, const, type, and func.

Variables

  • A pointer value is the address of a variable.
  • Pointers are key to the flag package, which uses a program's command-line arguments to set the values of cer tain variables distributed throughout the program.
  • The expression new(T) creates an unnamed variable of typ e T.

Assignments

  • Tuple assignment

Type Declarations

type Celsius float64
type Fahrenheit float64
  • Two types, Celsius and Fahrenheit, for the two units of temperature. Even though both have the same underlying typ e, float64, they are not the same type, so they cannot be compared or combined in arithmetic expressions.

Scope

  • If a name is declared in both an outer block and an inner block, the inner declaration will be found first.

Exercises

Chapter3

Integers

    & bitwise AND
    | bitwise OR
    ^ bitwise XOR
    &^ bit cle ar (AND NOT)
    << lef t shif t
    >> right shif t

Floating-Point Numbers

Complex Numbers

Booleans

Strings

Constants

Exercises

Documentation

Go Doc GoPL book GeeksForGreeks

About

week-1-homework-1-denizcamalan created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages