Google appengine saying my import is incorrect? - google-app-engine

First time using google AppEngine and I am trying to launch this is my current files
├── app.yaml
├── controllers
│   ├── admin
│   │   └── admin.go
│   ├── auth
│   │   ├── login.go
│   │   ├── register.go
│   │   └── validate.go
│   ├── common
│   │   ├── common.go
│   │   └── dbstructs.go
│   ├── forum
│   │   └── forum.go
│   ├── home
│   │   └── home.go
│   └── user
│   └── user.go
then I do goapp serve and I get :
2015/12/13 22:16:29 go-app-builder: Failed parsing input: parser: bad import "../common" in controllers/home/home.go
I'm not sure why it's a bad import or of appengine makes its own environment or something any help would be great.

Use absolute an absolute path in the import statement:
import (
"controllers/common"
)

Related

Attempted import error : 'createLocation' is not exported from 'history' with conflicting History and React-router-dom versions

I was trying to set up an existing project in a new development server. However I get the following error:
./node_modules/react-router-dom/esm/react-router-dom.js
Attempted import error : 'createLocation' is not exported from 'history'.
Searching for a solution I found that it might be because there are conflicting versions of the history and react-router-dom. It seems that react-router-dom 5.2.0 works with history 4.9.0, and I have history 5.0.0. The solution should be downgrading history to 4.9.0, but in the existing project, with the same versions, this error does not appear.
I checked the libraries versions with npm list -depth=0
├── #ant-design/compatible#1.0.8
├── #ant-design/icons#4.2.2
├── #babel/preset-env#7.11.5
├── #babel/preset-react#7.10.4
├── #craco/craco#5.7.0
├── #types/jest#26.0.14
├── #types/jwt-decode#2.2.1
├── #types/node#14.11.1
├── #types/react-dom#16.9.8
├── #types/react-highlight-words#0.16.1
├── #types/react-redux#7.1.9
├── #types/react-resizable#1.7.2
├── #types/react-router-dom#5.1.5
├── #types/react-table#7.0.23
├── #types/react#16.9.49
├── #types/redux-logger#3.0.8
├── #typescript-eslint/eslint-plugin#3.10.1
├── #typescript-eslint/parser#3.10.1
├── antd#4.10.2
├── axios#0.19.2
├── bootstrap#4.5.2
├── craco-less#1.17.0
├── env-cmd#10.1.0
├── eslint-plugin-react-hooks#4.1.2
├── eslint-plugin-react#7.20.6
├── eslint#6.8.0
├── history#5.0.0
├── js-file-download#0.4.12
├── jwt-decode#3.1.2
├── lodash#4.17.20
├── mocker-data-generator#2.9.0
├── moment#2.28.0
├── node-sass#4.14.1
├── password-validator#5.1.0
├── prettier#1.19.1
├── query-string#6.13.2
├── react-dom#16.13.1
├── react-highlight-words#0.16.0
├── react-redux#7.2.1
├── react-resizable#1.11.0
├── react-router-dom#5.2.0
├── react-scripts#3.4.3
├── react-test-renderer#16.13.1
├── react#16.13.1
├── redux-devtools-extension#2.13.8
├── redux-logger#3.0.6
├── redux-thunk#2.3.0
├── redux#4.0.5
├── resize-observer-polyfill#1.5.1
├── rsuite#4.8.2
├── typescript#3.9.7
├── webpack-dev-middleware#3.7.2
└── webpack-hot-middleware#2.25.0
Ideally I wanted to use the same versions as the existing project, however I dont understand how the project is working with the conflicting versions of history and react-router-dom.
History 5.x.x does not export createLocation. Therefore it will never work if you have that history version in your root package.json and trying to do that import from your project.

.c file is not recgnized

I cannot build c project.
I am novice of C language, so I can't understand what is problem.
Webstorm setting, or setting of cmake ?
Why I cannot build my projects.
Environment:
Editor: Clion
Created Project from C Executable
Lnaguage standard: C99
Error message
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake --build /Users/me/CLionProjects/test/cmake-build-debug --target test -- -j 2
[ 50%] Linking C executable test
Undefined symbols for architecture x86_64:
"_test", referenced from:
_main in main.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [test] Error 1
make[2]: *** [CMakeFiles/test.dir/all] Error 2
make[1]: *** [CMakeFiles/test.dir/rule] Error 2
make: *** [test] Error 2
I wrote main.c
#include "header.h"
int main() {
test();
return 0;
}
header.h file
void test();
header.c file
#include "header.h"
void test() {
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(test C)
set(CMAKE_C_STANDARD 99)
add_executable(test main.c)
dicrectory structure is like this.
.
├── CMakeLists.txt
├── cmake-build-debug
│   ├── CMakeCache.txt
│   ├── CMakeFiles
│   │   ├── 3.15.3
│   │   │   ├── CMakeCCompiler.cmake
│   │   │   ├── CMakeDetermineCompilerABI_C.bin
│   │   │   ├── CMakeSystem.cmake
│   │   │   └── CompilerIdC
│   │   │   ├── CMakeCCompilerId.c
│   │   │   ├── a.out
│   │   │   └── tmp
│   │   ├── CMakeDirectoryInformation.cmake
│   │   ├── CMakeOutput.log
│   │   ├── CMakeTmp
│   │   ├── Makefile.cmake
│   │   ├── Makefile2
│   │   ├── Progress
│   │   │   ├── 2
│   │   │   └── count.txt
│   │   ├── TargetDirectories.txt
│   │   ├── clion-environment.txt
│   │   ├── clion-log.txt
│   │   ├── cmake.check_cache
│   │   ├── progress.marks
│   │   └── test.dir
│   │   ├── C.includecache
│   │   ├── DependInfo.cmake
│   │   ├── build.make
│   │   ├── cmake_clean.cmake
│   │   ├── depend.internal
│   │   ├── depend.make
│   │   ├── flags.make
│   │   ├── link.txt
│   │   ├── main.c.o
│   │   ├── progress.make
│   │   └── src
│   ├── Makefile
│   ├── cmake_install.cmake
│   └── test.cbp
├── header.c
├── header.h
├── main.c
└── src

Rename multiple files from directory name

I have multiple directories with multiple files on each. Each file on each directory follows the same structure.
enter code here
.
├── one
│   ├── alpha.yaml
│   └── beta.yaml
├── three
│   ├── alpha.yaml
│   └── beta.yaml
└── two
├── alpha.yaml
└── beta.yaml
I would to rename all files with their relevant directory name, ie:
.
├── one
│   ├── one_alpha.yaml
│   └── one_beta.yaml
├── three
│   ├── three_alpha.yaml
│   └── three_beta.yaml
└── two
├── two_alpha.yaml
└── two_beta.yaml
I tried some for loop commands but these are deleting:
for i in *; do mv "$i/_alpha.yaml" "$i/$i_alpha.yaml" ; do
You can do it using os.rename in python:
import os
basepath = './'
for dirname, dirnames, filenames in os.walk(basepath):
for singleFile in filenames:
os.rename(singleFile, dirname + '_' + singleFile)
Let me know if it works

How can I set up paths for reading input from a file in check unit test?

I am learning to use check for unit testing my code. I have my project set up with autotools, and I have check set up to do some tests.
The program I'm making is a red black tree that I want to be able to use for other projects. For one of my tests, I want to read input from a file to use as test data to insert into the tree. I have a file called words.txt in my tests directory that I want to read from. I like to keep my build tree separate though. So how can set up my makefiles to put the words file in the right place? Then can I just read it from the directory that make check runs in?
Here's what everything looks like:
Project Directory:
├── aclocal.m4
├── autom4te.cache
│   ├── output.0
│   ├── output.1
│   ├── requests
│   ├── traces.0
│   └── traces.1
├── build-aux
│   ├── ar-lib
│   ├── compile
│   ├── depcomp
│   ├── install-sh
│   ├── missing
│   └── test-driver
├── config.h.in
├── config.h.in~
├── configure
├── configure.ac
├── Makefile.am
├── Makefile.in
├── src
│   ├── libredblack.c
│   ├── libredblack.h
│   ├── main.c
│   ├── Makefile.am
│   └── Makefile.in
└── tests
├── check_libredblack.c
├── Makefile.am
├── Makefile.in
└── words.txt
tests/Makefile.am:
TESTS = check_libredblack
check_PROGRAMS = check_libredblack
check_libredblack_SOURCES = check_libredblack.c $(top_builddir)/src/libredblack.h
check_libredblack_CFLAGS = #CHECK_CFLAGS#
check_libredblack_LDADD = $(top_builddir)/src/libredblack.a #CHECK_LIBS#
One way is to let the Makefile tell the test program where to find it.
Add to your test program's CPPFLAGS something like -DWORDS_LOCATION="\"$(top_srcdir)/tests/data/words.txt\"" and then the path to the data file will be available to your program as a string, defined in the macro WORDS_LOCATION.

build error using flex-lexer and cmake

i'm learning cmake and flex-lexer but i get a build problem with error code 2 according to the error message from make:
$ make
/usr/bin/cmake -H/home/dac/ClionProjects/openshell -B/home/dac/ClionProjects/openshell --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/dac/ClionProjects/openshell/CMakeFiles /home/dac/ClionProjects/openshell/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/dac/ClionProjects/openshell'
make -f CMakeFiles/lemon.dir/build.make CMakeFiles/lemon.dir/depend
make[2]: Entering directory '/home/dac/ClionProjects/openshell'
cd /home/dac/ClionProjects/openshell && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell/CMakeFiles/lemon.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/dac/ClionProjects/openshell'
make -f CMakeFiles/lemon.dir/build.make CMakeFiles/lemon.dir/build
make[2]: Entering directory '/home/dac/ClionProjects/openshell'
make[2]: Nothing to be done for 'CMakeFiles/lemon.dir/build'.
make[2]: Leaving directory '/home/dac/ClionProjects/openshell'
/usr/bin/cmake -E cmake_progress_report /home/dac/ClionProjects/openshell/CMakeFiles 1
[ 14%] Built target lemon
make -f CMakeFiles/openshell.dir/build.make CMakeFiles/openshell.dir/depend
make[2]: Entering directory '/home/dac/ClionProjects/openshell'
/usr/bin/cmake -E cmake_progress_report /home/dac/ClionProjects/openshell/CMakeFiles 2
[ 28%] [FLEX][openshell] Building scanner with flex 2.5.39
/usr/bin/flex -oshellparser.c shellscanner.l
cd /home/dac/ClionProjects/openshell && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell/CMakeFiles/openshell.dir/DependInfo.cmake --color=
Scanning dependencies of target openshell
make[2]: Leaving directory '/home/dac/ClionProjects/openshell'
make -f CMakeFiles/openshell.dir/build.make CMakeFiles/openshell.dir/build
make[2]: Entering directory '/home/dac/ClionProjects/openshell'
/usr/bin/cmake -E cmake_progress_report /home/dac/ClionProjects/openshell/CMakeFiles 3
[ 42%] Building C object CMakeFiles/openshell.dir/shellparser.c.o
/usr/bin/cc -Wall -Werror -O3 -std=c99 -I/usr/include/readline -o CMakeFiles/openshell.dir/shellparser.c.o -c /home/dac/ClionProjects/openshell/shellparser.c
shellparser.c: In function ‘yy_init_buffer’:
shellparser.c:1432:48: error: implicit declaration of function ‘fileno’ [-Werror=implicit-function-declaration]
b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
^
shellscanner.l: At top level:
shellparser.c:1181:17: error: ‘yyunput’ defined but not used [-Werror=unused-function]
static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
^
shellparser.c:1223:16: error: ‘input’ defined but not used [-Werror=unused-function]
static int input (yyscan_t yyscanner)
^
cc1: all warnings being treated as errors
CMakeFiles/openshell.dir/build.make:62: recipe for target 'CMakeFiles/openshell.dir/shellparser.c.o' failed
make[2]: *** [CMakeFiles/openshell.dir/shellparser.c.o] Error 1
make[2]: Leaving directory '/home/dac/ClionProjects/openshell'
CMakeFiles/Makefile2:98: recipe for target 'CMakeFiles/openshell.dir/all' failed
make[1]: *** [CMakeFiles/openshell.dir/all] Error 2
make[1]: Leaving directory '/home/dac/ClionProjects/openshell'
Makefile:78: recipe for target 'all' failed
make: *** [all] Error 2
My build file is
cmake_minimum_required(VERSION 3.0)
project(openshell)
find_package(FLEX)
FLEX_TARGET(openshell shellscanner.l shellparser.c)
add_executable(openshell shellparser.c ${FLEX_ShellScanner_OUTPUTS} main.c openshell.h errors.c errors.h util.c util.h stack.c stack.h shellscanner.l shellscanner.h)
set(CMAKE_VERBOSE_MAKEFILE on)
include_directories(/usr/include/readline)
#### Lemon bootstrap ####
ADD_EXECUTABLE(lemon lemon.c)
file(GLOB SOURCES "./*.c")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -O3 -std=c99")
target_link_libraries(openshell ${READLINE_LIBRARY} ${FLEX_LIBRARIES})
Is it the compiler options that I must change? My file structure is:
$ tree
.
├── CMakeCache.txt
├── CMakeFiles
│   ├── 3.2.2
│   │   ├── CMakeCCompiler.cmake
│   │   ├── CMakeCXXCompiler.cmake
│   │   ├── CMakeDetermineCompilerABI_C.bin
│   │   ├── CMakeDetermineCompilerABI_CXX.bin
│   │   ├── CMakeSystem.cmake
│   │   ├── CompilerIdC
│   │   │   ├── a.out
│   │   │   └── CMakeCCompilerId.c
│   │   └── CompilerIdCXX
│   │   ├── a.out
│   │   └── CMakeCXXCompilerId.cpp
│   ├── cmake.check_cache
│   ├── CMakeDirectoryInformation.cmake
│   ├── CMakeOutput.log
│   ├── CMakeRuleHashes.txt
│   ├── CMakeTmp
│   ├── feature_tests.bin
│   ├── feature_tests.c
│   ├── feature_tests.cxx
│   ├── lemon.dir
│   │   ├── build.make
│   │   ├── C.includecache
│   │   ├── cmake_clean.cmake
│   │   ├── DependInfo.cmake
│   │   ├── depend.internal
│   │   ├── depend.make
│   │   ├── flags.make
│   │   ├── lemon.c.o
│   │   ├── link.txt
│   │   └── progress.make
│   ├── Makefile2
│   ├── Makefile.cmake
│   ├── openshell.dir
│   │   ├── build.make
│   │   ├── C.includecache
│   │   ├── cmake_clean.cmake
│   │   ├── DependInfo.cmake
│   │   ├── depend.internal
│   │   ├── depend.make
│   │   ├── flags.make
│   │   ├── flex
│   │   │   ├── lemon.c.o
│   │   │   └── shellparser.c.o
│   │   ├── lemon.c.o
│   │   ├── link.txt
│   │   ├── progress.make
│   │   ├── stack.c.o
│   │   └── util.c.o
│   ├── parser.dir
│   │   ├── build.make
│   │   ├── cmake_clean.cmake
│   │   ├── DependInfo.cmake
│   │   ├── depend.internal
│   │   ├── depend.make
│   │   └── progress.make
│   ├── Progress
│   │   ├── 1
│   │   ├── 2
│   │   ├── 3
│   │   └── count.txt
│   ├── progress.marks
│   └── TargetDirectories.txt
├── cmake_install.cmake
├── CMakeLists.txt
├── digenv.c
├── errors.c
├── errors.h
├── example.c
├── example.h
├── flex
│   ├── digenv.c
│   ├── errors.c
│   ├── errors.h
│   ├── example.c
│   ├── example.h
│   ├── lemon
│   ├── lemon.c
│   ├── lempar.c
│   ├── lex.yy.c
│   ├── main.c
│   ├── main.c~
│   ├── main.h
│   ├── main.o
│   ├── Makefile
│   ├── Makefile~
│   ├── miniShell2.c
│   ├── openshell
│   ├── openshell.c
│   ├── openshell.h
│   ├── openshell.l
│   ├── pipeline.c
│   ├── README.md
│   ├── shell
│   ├── shellparser.c
│   ├── shellparser.h
│   ├── shellparser.hpp
│   ├── shellparser.o
│   ├── shellparser.out
│   ├── shellparser.y
│   ├── shellparser.y~
│   ├── shellscanner.h
│   ├── shellscanner.l
│   ├── shellscanner.o
│   ├── snazzle
│   ├── util.c
│   └── util.h
├── lemon
├── lemon.c
├── lempar.c
├── lex.yy.c
├── main.c
├── main.h
├── main.o
├── Makefile
├── miniShell2.c
├── openshell
├── openshell.c
├── openshell.h
├── pipeline.c
├── README.md
├── shellparser.c
├── shellparser.h
├── shellparser.hpp
├── shellparser.o
├── shellparser.out
├── shellparser.y
├── shellscanner.h
├── shellscanner.l
├── shellscanner.o
├── snazzle
├── snazzle.l~
├── stack.c
├── stack.h
├── util.c
└── util.h
11 directories, 127 files
dac#dac-Latitude-E7450:~/ClionProjects/openshell$
My flex grammar is
%include {
#include <stdio.h>
#include <assert.h>
}
%token_type {const char*}
%syntax_error
{
fprintf(stderr, "Error parsing command\n");
}
start ::= in .
in ::= .
in ::= in commandList EOL .
{
printf("in ::= in commandList EOL .\n");
printf("> ");
}
commandList ::= command PIPE commandList .
{
printf("commandList ::= command PIPE commandList .\n");
}
commandList ::= command .
{
printf("commandList ::= command .\n");
}
command ::= FILENAME argumentList .
{
printf("command ::= FILENAME argumentList .\n");
}
command ::= FILENAME .
{
printf("command ::= FILENAME .\n");
}
argumentList ::= argument argumentList .
{
printf("argumentList ::= argument argumentList .\n");
}
argumentList ::= argument .
{
printf("argumentList ::= argument .\n");
}
argument ::= ARGUMENT .
{
printf("argument ::= ARGUMENT .\n");
}
argument ::= FILENAME .
{
printf("argument ::= FILENAME .\n");
}
The combination of -Wall and -Werror in your compiler flags is too strict for the code generated by flex. You can tell the compiler to treat the specific errors as regular warnings by adding a couple more options:
-Wno-error=implicit-function-declaration
-Wno-error=unused-function
Basically just inserting no- into the -Werror= diagnostics the compiler printed.
Best practice would be to only add these compiler options to the specific source files generated by flex, not your entire project. In your case it might look like this:
set_source_files_properties(shellparser.c PROPERTIES COMPILE_FLAGS
-Wno-error=implicit-function-declaration
-Wno-error=unused-function
)
Or if you want to avoid the warnings entirely for this file, which might be a good idea so you don't grow accustomed to tolerating warnings:
set_source_files_properties(shellparser.c PROPERTIES COMPILE_FLAGS
-Wno-implicit-function-declaration
-Wno-unused-function
)
Finally, you may actually be able to fix the undeclared fileno issue by adding this at the top of your flex grammar file:
%{
#include <stdio.h>
%}
With compiler flag -Werror all warnings are treated as errors.
You must delete this flag and compilation will be finished without errors.

Resources