Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Notes Golang

Similar presentations


Presentation on theme: "Programming Notes Golang"— Presentation transcript:

1 Programm ing NOTE S I N G o l a n g Programming Language

2 GOLA NG introdu ction GO @ GOOGLE Created by Google in 2007 Robert Griesemer, Rob Pike, and Ken Thompson Inspired by Pascal, Oberon, & C

3 Page 06 of 15 INTENDED GOALS Quick to compile Manageable code Garbage collection Concurrency Support for processors with multiple cores alfredo torres

4 WHY DO DEVELOPERS NEED GARBAGE COLLECTION creative portfolio Page 02 of 15 Side Notes Developers need to focus on the program logic instead of keeping memory spaces clean from unused objects and variables. Go has automatic garbage collection so they do not have to worry about writing unmanegeable code to handle and free up memory

5 IS G A o COMPILED LANGUAGE Golang has compilation time meaning more errors can be checked which is good for software performance and also portability Page 10 of 15 alfredo torres

6 Preparing environment Create project folder and navigate to it mkdir project_name && cd $_ Create venv for the project python -m venv env_name Activate environnement (Replace "bin" by "Scripts" in Windows) source env_name\bin\activate Install Django (and others dependencies if needed) pip install django Create requirements file pip freeze > requirements.txt Install all required files based on your pip freeze command pip install -r requirements.txt Carla Missiona

7 STARTING PROJECT django-admin startproject mysite (or I like to call it config) This will create a mysite directory in your current directory the manage.py file Navigate to the root project folder Create the app running the command $python manage.py startapp Inform Django that a new “app” is registered (this is not done automatically) by adding “app name” to INSTALLED_APPS section in the core settings file Execute Django migration and we are good to go with the new app python manage.py runserver Carla Missiona

8 MOD ELS package main import ( "fmt" "math" ) func main() { fmt.Printf("Hello random no.#", math.Sqrt(7)) } Instead of using single line import import "fmt" import "math" use parentheses Carla Missiona

9 MOD ELS Open up mysite/settings.py configure database driver If you wish to use another database, install the appropriate database bindings and change the following keys in the DATABASES 'default' item to match your database connection settings Carla Missiona

10 MODEL REPRESENT ATION Model Relationships # One-to-Many: (use double quotes if the entity is not yet declare) ex. "Supplier" # Many-to-Many: tags = models.ManyToManyField(Tag, blank=True) # One to One User = models.OneToOneField(User, on_delete=models.CASCADE) Carla Missiona

11 MODU LAR PROJE CT Create an app_name with startapp command then plug it in your project Apps are "plugable", that will "plug in" the app into the project Into urls.py from project folder, inculde app urls to project Carla Missiona

12 MODELS Carla Missiona

13 ADMIN MODULE Create a user who can login to the admin site python manage.py createsuperuser Into app_name/admin.py, add the model to administration site admin.site.register(ModelName) Carla Missiona

14 ADMIN MODULE Carla Missiona

15 RENDERING VIEWS

16 Carla Missiona

17 ROUTING from django.contrib import admin from django.urls import path from. import views urlPatterns = [ path('admin/', admin.site.urls), path('', views.index, name='index'), path('about/', views.about, name='about'), ]

18 FORMS Carla Missiona

19 FORMS Carla Missiona

20 RENDERING FORMS Carla Missiona

21 INTERVIEW QUESTIONS & ANSWERS Carla Missiona

22 WHAT ARE THE FEATURES OF DJANGO? SEO Optimized Extremely fast Fully loaded framework that comes along with authentications, content administrations, RSS feeds, etc Very secure thereby helping developers avoid common security mistakes such as cross-site request forgery (csrf), clickjacking, cross-site scripting, etc It is exceptionally scalable which in turn helps meet the heaviest traffic demands Immensely versatile which allows you to develop any kind of websites Carla Missiona

23 HOW DO YOU CHECK FOR THE VERSION OF DJANGO INSTALLED ON YOUR SYSTEM? To check for the version of Django installed on your system, you can open the command prompt and enter the following command: python -m django –version Carla Missiona

24 EXPLAIN DJANGO ARCHITECTURE Django follows the MVT or Model View Template architecture whcih is based on the MVC or Model View Controller architecture. The main difference between these two is that Django itself takes care of the controller part. Carla Missiona

25 HOW DO YOU CONNECT YOUR DJANGO PROJECT TO THE DATABASE? Django comes with a default database which is SQLite. To connect your project to this database, use the following commands: 1.python manage.py migrate (migrate command looks at the INSTALLED_APPS settings and creates database tables accordingly) 2.python manage.py makemigrations (tells Django you have created/ changed your models) 3.python manage.py sqlmigrate (sqlmigrate takes the migration names and returns their SQL) Carla Missiona

26 Djang o NOT ES Notes Reference www. codewithharry. COM DEVT O EDURE KA Page 10 of 15 alfredo torres CHEATography COURSERA I BM

27 www.reallygreatsite.com Page 06 of 15 VISION Presentation are communication tools that can be used as demontrations, lectures, reports, and more. it is mostly presented before an audience. MISSION Presentation are communication tools that can be used as demontrations, lectures, reports, and more. it is mostly presented before an audience. m o r e alfredo torres

28 table of creative portfolio Page 03 of 15 CONTENT Presentation are communication tools that can be used as demontrations, lectures, reports, and more. it is mostly presented before an audience. about me work experience v i s i on / mission portfolio personal skills contact

29 www.reallygreatsite.com Alfredo Torres Page 07 of 15 personal SKILLS Presentation are communication tools that can be used as demontrations, lectures, reports, and more. it is mostly presented before an audience. GRAPHIC DESIGNER PHOTOGRA PHER

30 www.reallygreatsite.com Page 08 of 15 EDUCATION BACKGROUND 20192020 2021 High school Presentation are communication tools that can be used as demontrations, lectures, reports, and more. school of design Presentation are communication tools that can be used as demontrations, lectures, reports, and more. school of art Presentation are communication tools that can be used as demontrations, lectures, reports, and more. alfredo torres

31 www.reallygreatsite.com Page 09 of 15 work EXPERIE NCE Presentation are communication tools that can be used as demontrations, lectures, reports, and more. graphic designer project event alfredo torres

32 www.reallygreatsite.com Page 11 of 15 PROJEC T 01 Presentation are communication tools that can be used as demontrations, lectures, reports, and more. alfredo torres

33 www.reallygreatsite.com Page 12 of 15 PROJECT 02 Presentation are communication tools that can be used as demontrations, lectures, reports, and more. alfredo torres

34 www.reallygreatsite.com Page 13 of 15 PROJEC T 03 Presentation are communication tools that can be used as demontrations, lectures, reports, and more. alfredo torres

35 www.reallygreatsite.com Page 14 of 15 NOTABLE PROJECT project 01project 02project 03 alfredo torres

36 +123-456-7890hello@reallygreatsite.comwww.reallygreatsite.com let's work togeth er creative portfolio Page 15 of 15


Download ppt "Programming Notes Golang"

Similar presentations


Ads by Google