Go + Revel: How to import custom package? - import

I am following tutorial of chat room covered here
I changed it to import a local package instead of using the sample from ravel's github. I changed it into something like this in one of the controllers (refresh.go in the tuts):
import (
"./../chatroom"
"github.com/revel/revel"
)
And chatroom was in the right directory:
- app
- chatroom
- chatroom.go
- controllers
- refresh.go
- app.go
package chatroom was also initialized already in chatroom.go.
But when running the code, I received this error:
The Go code app/tmp/main.go does not compile: local import "./../chatroom" in non-local package
What am I doing wrong here?

It would be best, following this answer to not use a relative path, but a path from the $GOPATH/src
In your case, is $GOPAHT/src includes app chatroom, you would use
import app/chatroom
The OP comments:
working, but I have to include my app name, something like myapp/app/chatroom,
That makes sense, if $GOPATH/src contains the folder myapp.

Related

Ag Grid Properties do not exist while using TypeScript

I'm trying to use TypeScript and AgGrid and using an example similar to https://www.ag-grid.com/react-data-grid/column-sizing/#resizing-example
The issue is that when using TypeScript I get different values than when I'm trying to use regular JavaScript.The main property I'm trying to get back is api
https://gitpodio-templatetypescr-ze7tjimg9lm.ws-us43.gitpod.io/ - here is a gitpod that I created. If you look at the console.log I get most of the same properties, but I'm not getting the api property to make changes.
*** Edit ***
Actually one thing I just noticed is that if I use
import { AgGridReact } from 'ag-grid-react'; it works properly
but if I use
import { AgGridReact } from '#ag-grid-community/react'; it doesn't work. Why would there be a difference and what am I missing?
*** Edit 2 ***
Why do I need to at least put in one module to get the api? Is there a core module that I can put in, instead of something like the ClientSideRowModelModule to trigger the api?

Don't import implementation files from another package when import a public class in flutter

When I import a public class in Flutter like this:
import 'package:wheel/src/log/app_log_handler.dart';
shows the waring:
Don't import implementation files from another package.
this is the waring detail:
why give this tips? what is the best way to handle it? I really want the log handler to public because I want all of my project use the same log handler, I do not want put the log handler to every project every time by the copy paste way.By the way, I import package like this:
wheel:
git:
url: https://github.com/jiangxiaoqiang/wheel.git
ref: main
TLDR
The package should have a file that only shows the selected files such as `'package:wheel/wheel.dart``
You should not import the 'package:wheel/src/log/app_log_handler.dart';directly.
Instead import 'package:wheel/wheel.dart`;
This import will export all required public types needed to work with the library.
Normally this files content will be just exports like this
export 'package:wheel/src/log/app_log_handler.dart';
export 'package:wheel/src/widgets/wheel_btn.dart';
export 'package:wheel/src/widgets/wheel_switch_two.dart';
export 'package:wheel/src/widgets/wheel_switch.dart';
See also the documentation on this.

Google Places API in Flutter

I am working on google places API with Flutter. I am working by referring the example. But I got errors for google places API classes as
Eg:
Undefined class 'GoogleMapsPlaces'.
Try changing the name to the name of an existing class, or creating a class with the name
I imported the flutter_google_places in my dart file as:
import 'package:flutter_google_places/flutter_google_places.dart'; But still I got the error for all classes.
Using flutter_google_places version 0.2.3.
GoogleMapPlaces is available on different library, not in flutter_google_places...
it's available on https://pub.dev/packages/google_maps_webservice
you can find another package for google place google_place
var googlePlace = GooglePlace("Your-Key");
var result = await googlePlace.autocomplete.get("1600 Amphitheatre");
You need to import
import 'package:google_maps_webservice/places.dart'; in your main.dart.

Having problems extending Quill

I'm hitting some problems extending Quill.
I want to modify the List and ListItem classes in Quill, so I tried to copy formats/list.js into my code base as a starting point. I then import my local copy and register it with Quill like so...
import { List, ListItem } from './quill/list';
Quill.register({
'formats/list': List,
'formats/list/item': ListItem
}, true);
However, when I attempt to create a list in the editor the code crashes in the List class with the following error:
ParchmentError {message: "[Parchment] Unable to create list-item blot", name: "ParchmentError"}
This happens on this line... https://github.com/quilljs/quill/blob/develop/formats/list.js#L99
I assume it relates to the imports I was forced to change, but I can't figure out what's wrong. I've not made any other changes to list.js. The original file has the following:-
import Block from '../blots/block';
import Container from '../blots/container';
Which I changed to this:-
import Quill from 'quill';
let Block = Quill.import('blots/block');
let Container = Quill.import('blots/container');
Is the way I am importing wrong? What is causing the error?
Figured it out (well a colleague did).
I needed to import Parchment like so :-
let Parchment = Quill.import('parchment');
instead of import Parchment from 'parchment';
This is because you'll end up with a different static Parchment class to the one used internally to Quill, so asking Quill for it's instance ensures you are both working with the same one (ie, the one where the blots were registered).
I came across that problem a couple hours ago.
In Quill's source code, List is a default export while ListItem is a named export.
So your import should look like this:
import List, { ListItem } from './quill/list';
Be sure to export them appropriately on your custom list.js file.
Good luck!

Import {} from location is not found in VS Code using TypeScript and Angular 2

I am trying out the new Angular 2 Forms. My import statements are as follows:
import {bootstrap, onChange, NgIf, Component, Directive, View, Ancestor} from 'angular2/angular2';
import {formDirectives, NgControl, Validators, NgForm} from 'angular2/forms';
import {RegExpWrapper, print, isPresent} from 'angular2/src/facade/lang';
import {reflector} from 'angular2/src/reflection/reflection';
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
The 'angular2/angular2' resolves fine, but none of the other "from" locations resolve. The error is:
Cannot find module 'angular2/forms'.
All of these components are currently in my node_modules directory. If I put in the full path:
import {formDirectives, ControlDirective, Validators, TemplateDrivenFormDirective} from 'C:/Users/Deb/node_modules/angular2/forms';
then it works. However, I should not need to use the full path. Am I missing something when I set up the tsconfig or is there something else wrong?
Problem was that the example application did not match with the version of Angular 2 currently available for download.
If anyone is interested, I now have a working example of Angular2 forms with TypeScript and Visual Studio Code here:
https://github.com/DeborahK/AngularU2015-Angular2Forms
Hope this helps anyone else standing on the "bleeding edge".